@@ -291,16 +291,16 @@ |
||
291 | 291 | Duis bibendum elementum justo. Duis posuere. Fusce nulla odio, posuere eget, condimentum nec, venenatis eu, elit. In hac habitasse platea dictumst. Aenean ac sem in enim imperdiet feugiat. Integer tincidunt lectus at elit. Integer magna lacus, vehicula quis, eleifend eget, suscipit vitae, leo. Nunc porta augue nec enim. Curabitur vehicula volutpat enim. Aliquam consequat. Vestibulum rhoncus tellus vitae erat. Integer est. Quisque fermentum leo nec odio. Suspendisse lobortis sollicitudin augue. Nullam urna mi, suscipit eu, sagittis laoreet, ultrices ac, sem. Aliquam enim tortor, hendrerit non, cursus a, tristique sit amet, sapien. Suspendisse potenti. Aenean semper placerat neque.'; |
292 | 292 | switch($type) |
293 | 293 | { |
294 | - case 'description': |
|
294 | + case 'description': |
|
295 | 295 | $descriptions = explode(".",$dummy_text); |
296 | 296 | return $descriptions[rand(0,count($descriptions)-1)]; |
297 | 297 | break; |
298 | - case 'title': |
|
298 | + case 'title': |
|
299 | 299 | $dummy_text = str_replace(array("\n",'.',',',"\t"),array(' ','','',' '),$dummy_text); |
300 | 300 | $titles = explode(" ",$dummy_text); |
301 | 301 | return trim($titles[rand(0,count($titles)-1)]); |
302 | 302 | break; |
303 | - case 'text': |
|
303 | + case 'text': |
|
304 | 304 | $texts = explode("\n",$dummy_text); |
305 | 305 | return $texts[rand(0,count($texts)-1)]; |
306 | 306 | break; |
@@ -6,112 +6,111 @@ discard block |
||
6 | 6 | * |
7 | 7 | * Contains several functions dealing with displaying, |
8 | 8 | * editing,... of a blog |
9 | - |
|
10 | 9 | * @package chamilo.blogs |
11 | 10 | * @author Toon Keppens <[email protected]> |
12 | 11 | * @author Julio Montoya - Cleaning code |
13 | 12 | */ |
14 | 13 | class Blog |
15 | 14 | { |
16 | - /** |
|
17 | - * Get the title of a blog |
|
18 | - * @author Toon Keppens |
|
19 | - * |
|
20 | - * @param int $blog_id |
|
21 | - * |
|
22 | - * @return String Blog Title |
|
23 | - */ |
|
24 | - public static function get_blog_title ($blog_id) |
|
25 | - { |
|
26 | - $course_id = api_get_course_int_id(); |
|
27 | - |
|
28 | - if (is_numeric($blog_id)) { |
|
29 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
30 | - |
|
31 | - $sql = "SELECT blog_name |
|
15 | + /** |
|
16 | + * Get the title of a blog |
|
17 | + * @author Toon Keppens |
|
18 | + * |
|
19 | + * @param int $blog_id |
|
20 | + * |
|
21 | + * @return String Blog Title |
|
22 | + */ |
|
23 | + public static function get_blog_title ($blog_id) |
|
24 | + { |
|
25 | + $course_id = api_get_course_int_id(); |
|
26 | + |
|
27 | + if (is_numeric($blog_id)) { |
|
28 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
29 | + |
|
30 | + $sql = "SELECT blog_name |
|
32 | 31 | FROM " . $tbl_blogs . " |
33 | 32 | WHERE c_id = $course_id AND blog_id = " . intval($blog_id); |
34 | 33 | |
35 | - $result = Database::query($sql); |
|
36 | - $blog = Database::fetch_array($result); |
|
37 | - |
|
38 | - return stripslashes($blog['blog_name']); |
|
39 | - } |
|
40 | - } |
|
41 | - |
|
42 | - |
|
43 | - /** |
|
44 | - * Get the description of a blog |
|
45 | - * @author Toon Keppens |
|
46 | - * |
|
47 | - * @param Integer $blog_id |
|
48 | - * |
|
49 | - * @return String Blog description |
|
50 | - */ |
|
51 | - public static function get_blog_subtitle($blog_id) |
|
52 | - { |
|
53 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
54 | - $course_id = api_get_course_int_id(); |
|
55 | - $sql = "SELECT blog_subtitle FROM $tbl_blogs |
|
34 | + $result = Database::query($sql); |
|
35 | + $blog = Database::fetch_array($result); |
|
36 | + |
|
37 | + return stripslashes($blog['blog_name']); |
|
38 | + } |
|
39 | + } |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * Get the description of a blog |
|
44 | + * @author Toon Keppens |
|
45 | + * |
|
46 | + * @param Integer $blog_id |
|
47 | + * |
|
48 | + * @return String Blog description |
|
49 | + */ |
|
50 | + public static function get_blog_subtitle($blog_id) |
|
51 | + { |
|
52 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
53 | + $course_id = api_get_course_int_id(); |
|
54 | + $sql = "SELECT blog_subtitle FROM $tbl_blogs |
|
56 | 55 | WHERE c_id = $course_id AND blog_id ='".intval($blog_id)."'"; |
57 | - $result = Database::query($sql); |
|
58 | - $blog = Database::fetch_array($result); |
|
59 | - |
|
60 | - return stripslashes($blog['blog_subtitle']); |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * Get the users of a blog |
|
65 | - * @author Toon Keppens |
|
66 | - * |
|
67 | - * @param Integer $blog_id |
|
68 | - * |
|
69 | - * @return Array Returns an array with [userid]=>[username] |
|
70 | - */ |
|
71 | - public static function get_blog_users($blog_id) |
|
72 | - { |
|
73 | - // Database table definitions |
|
74 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
75 | - $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
76 | - |
|
77 | - $course_id = api_get_course_int_id(); |
|
78 | - |
|
79 | - // Get blog members |
|
80 | - $sql = "SELECT user.user_id, user.firstname, user.lastname |
|
56 | + $result = Database::query($sql); |
|
57 | + $blog = Database::fetch_array($result); |
|
58 | + |
|
59 | + return stripslashes($blog['blog_subtitle']); |
|
60 | + } |
|
61 | + |
|
62 | + /** |
|
63 | + * Get the users of a blog |
|
64 | + * @author Toon Keppens |
|
65 | + * |
|
66 | + * @param Integer $blog_id |
|
67 | + * |
|
68 | + * @return Array Returns an array with [userid]=>[username] |
|
69 | + */ |
|
70 | + public static function get_blog_users($blog_id) |
|
71 | + { |
|
72 | + // Database table definitions |
|
73 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
74 | + $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
75 | + |
|
76 | + $course_id = api_get_course_int_id(); |
|
77 | + |
|
78 | + // Get blog members |
|
79 | + $sql = "SELECT user.user_id, user.firstname, user.lastname |
|
81 | 80 | FROM " . $tbl_blogs_rel_user . " blogs_rel_user |
82 | 81 | INNER JOIN " . $tbl_users . " user |
83 | 82 | ON blogs_rel_user.user_id = user.user_id |
84 | 83 | WHERE |
85 | 84 | blogs_rel_user.c_id = $course_id AND |
86 | 85 | blogs_rel_user.blog_id = '" . (int)$blog_id."'"; |
87 | - $result = Database::query($sql); |
|
88 | - $blog_members = array (); |
|
89 | - while($user = Database::fetch_array($result)) { |
|
90 | - $blog_members[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']); |
|
91 | - } |
|
92 | - |
|
93 | - return $blog_members; |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * Creates a new blog in the given course |
|
98 | - * @author Toon Keppens |
|
99 | - * @param string $title |
|
100 | - */ |
|
101 | - public static function create_blog($title, $subtitle) |
|
102 | - { |
|
103 | - $_user = api_get_user_info(); |
|
86 | + $result = Database::query($sql); |
|
87 | + $blog_members = array (); |
|
88 | + while($user = Database::fetch_array($result)) { |
|
89 | + $blog_members[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']); |
|
90 | + } |
|
91 | + |
|
92 | + return $blog_members; |
|
93 | + } |
|
94 | + |
|
95 | + /** |
|
96 | + * Creates a new blog in the given course |
|
97 | + * @author Toon Keppens |
|
98 | + * @param string $title |
|
99 | + */ |
|
100 | + public static function create_blog($title, $subtitle) |
|
101 | + { |
|
102 | + $_user = api_get_user_info(); |
|
104 | 103 | $course_id = api_get_course_int_id(); |
105 | 104 | |
106 | - $current_date=date('Y-m-d H:i:s',time()); |
|
107 | - $session_id = api_get_session_id(); |
|
108 | - // Tabel definitions |
|
105 | + $current_date=date('Y-m-d H:i:s',time()); |
|
106 | + $session_id = api_get_session_id(); |
|
107 | + // Tabel definitions |
|
109 | 108 | $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
110 | 109 | $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST); |
111 | 110 | $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
112 | 111 | |
113 | - //verified if exist blog |
|
114 | - $sql = 'SELECT COUNT(*) as count FROM '.$tbl_blogs.' |
|
112 | + //verified if exist blog |
|
113 | + $sql = 'SELECT COUNT(*) as count FROM '.$tbl_blogs.' |
|
115 | 114 | WHERE |
116 | 115 | c_id = '.$course_id.' AND |
117 | 116 | blog_name="'.Database::escape_string($title).'" AND |
@@ -120,9 +119,9 @@ discard block |
||
120 | 119 | $info_count = Database::result($res, 0, 0); |
121 | 120 | |
122 | 121 | if ($info_count == 0) { |
123 | - // Create the blog |
|
122 | + // Create the blog |
|
124 | 123 | $params = [ |
125 | - 'blog_id' => 0, |
|
124 | + 'blog_id' => 0, |
|
126 | 125 | 'c_id' => $course_id, |
127 | 126 | 'blog_name' => $title, |
128 | 127 | 'blog_subtitle' => $subtitle, |
@@ -130,14 +129,14 @@ discard block |
||
130 | 129 | 'visibility' => 1 , |
131 | 130 | 'session_id' => $session_id, |
132 | 131 | ]; |
133 | - $this_blog_id = Database::insert($tbl_blogs, $params); |
|
132 | + $this_blog_id = Database::insert($tbl_blogs, $params); |
|
134 | 133 | |
135 | - if ($this_blog_id > 0) { |
|
134 | + if ($this_blog_id > 0) { |
|
136 | 135 | |
137 | 136 | $sql = "UPDATE $tbl_blogs SET blog_id = iid WHERE iid = $this_blog_id"; |
138 | 137 | Database::query($sql); |
139 | 138 | |
140 | - // insert into item_property |
|
139 | + // insert into item_property |
|
141 | 140 | api_item_property_update( |
142 | 141 | api_get_course_info(), |
143 | 142 | TOOL_BLOGS, |
@@ -145,12 +144,12 @@ discard block |
||
145 | 144 | 'BlogAdded', |
146 | 145 | api_get_user_id() |
147 | 146 | ); |
148 | - } |
|
147 | + } |
|
149 | 148 | |
150 | - // Make first post. :) |
|
149 | + // Make first post. :) |
|
151 | 150 | |
152 | 151 | $params = [ |
153 | - 'post_id' => 0, |
|
152 | + 'post_id' => 0, |
|
154 | 153 | 'c_id' => $course_id, |
155 | 154 | 'title' => get_lang("Welcome"), |
156 | 155 | 'full_text' => get_lang('FirstPostText'), |
@@ -164,10 +163,10 @@ discard block |
||
164 | 163 | Database::query($sql); |
165 | 164 | } |
166 | 165 | |
167 | - // Put it on course homepage |
|
168 | - $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, session_id, target) |
|
166 | + // Put it on course homepage |
|
167 | + $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, session_id, target) |
|
169 | 168 | VALUES ($course_id, '".Database::escape_string($title)."','blog/blog.php?blog_id=".(int)$this_blog_id."','blog.gif','1','0','pastillegris.gif',0,'$session_id', '')"; |
170 | - Database::query($sql); |
|
169 | + Database::query($sql); |
|
171 | 170 | |
172 | 171 | $toolId = Database::insert_id(); |
173 | 172 | if ($toolId) { |
@@ -175,35 +174,35 @@ discard block |
||
175 | 174 | Database::query($sql); |
176 | 175 | } |
177 | 176 | |
178 | - // Subscribe the teacher to this blog |
|
179 | - Blog::set_user_subscribed($this_blog_id, $_user['user_id']); |
|
180 | - } |
|
181 | - } |
|
182 | - |
|
183 | - /** |
|
184 | - * Update title and subtitle of a blog in the given course |
|
185 | - * @author Toon Keppens |
|
186 | - * @param string $title |
|
187 | - */ |
|
188 | - public static function edit_blog($blog_id, $title, $subtitle) |
|
189 | - { |
|
190 | - // Table definitions |
|
191 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
192 | - $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST); |
|
177 | + // Subscribe the teacher to this blog |
|
178 | + Blog::set_user_subscribed($this_blog_id, $_user['user_id']); |
|
179 | + } |
|
180 | + } |
|
181 | + |
|
182 | + /** |
|
183 | + * Update title and subtitle of a blog in the given course |
|
184 | + * @author Toon Keppens |
|
185 | + * @param string $title |
|
186 | + */ |
|
187 | + public static function edit_blog($blog_id, $title, $subtitle) |
|
188 | + { |
|
189 | + // Table definitions |
|
190 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
191 | + $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST); |
|
193 | 192 | |
194 | 193 | $course_id = api_get_course_int_id(); |
195 | 194 | |
196 | - // Update the blog |
|
197 | - $sql = "UPDATE $tbl_blogs SET |
|
195 | + // Update the blog |
|
196 | + $sql = "UPDATE $tbl_blogs SET |
|
198 | 197 | blog_name = '".Database::escape_string($title)."', |
199 | 198 | blog_subtitle = '".Database::escape_string($subtitle)."' |
200 | 199 | WHERE |
201 | 200 | c_id = $course_id AND |
202 | 201 | blog_id ='".Database::escape_string((int)$blog_id)."' |
203 | 202 | LIMIT 1"; |
204 | - Database::query($sql); |
|
203 | + Database::query($sql); |
|
205 | 204 | |
206 | - //update item_property (update) |
|
205 | + //update item_property (update) |
|
207 | 206 | api_item_property_update( |
208 | 207 | api_get_course_info(), |
209 | 208 | TOOL_BLOGS, |
@@ -212,21 +211,21 @@ discard block |
||
212 | 211 | api_get_user_id() |
213 | 212 | ); |
214 | 213 | |
215 | - // Update course homepage link |
|
216 | - $sql = "UPDATE $tbl_tool SET |
|
214 | + // Update course homepage link |
|
215 | + $sql = "UPDATE $tbl_tool SET |
|
217 | 216 | name = '".Database::escape_string($title)."' |
218 | 217 | WHERE c_id = $course_id AND link = 'blog/blog.php?blog_id=".(int)$blog_id."' LIMIT 1"; |
219 | - Database::query($sql); |
|
220 | - } |
|
221 | - |
|
222 | - /** |
|
223 | - * Deletes a blog and it's posts from the course database |
|
224 | - * @author Toon Keppens |
|
225 | - * @param Integer $blog_id |
|
226 | - */ |
|
227 | - public static function delete_blog($blog_id) |
|
228 | - { |
|
229 | - // Init |
|
218 | + Database::query($sql); |
|
219 | + } |
|
220 | + |
|
221 | + /** |
|
222 | + * Deletes a blog and it's posts from the course database |
|
223 | + * @author Toon Keppens |
|
224 | + * @param Integer $blog_id |
|
225 | + */ |
|
226 | + public static function delete_blog($blog_id) |
|
227 | + { |
|
228 | + // Init |
|
230 | 229 | $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
231 | 230 | $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
232 | 231 | $tbl_blogs_comment = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
@@ -237,34 +236,34 @@ discard block |
||
237 | 236 | $course_id = api_get_course_int_id(); |
238 | 237 | $blog_id = intval($blog_id); |
239 | 238 | |
240 | - // Delete posts from DB and the attachments |
|
241 | - delete_all_blog_attachment($blog_id); |
|
239 | + // Delete posts from DB and the attachments |
|
240 | + delete_all_blog_attachment($blog_id); |
|
242 | 241 | |
243 | - //Delete comments |
|
244 | - $sql = "DELETE FROM $tbl_blogs_comment WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
245 | - Database::query($sql); |
|
242 | + //Delete comments |
|
243 | + $sql = "DELETE FROM $tbl_blogs_comment WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
244 | + Database::query($sql); |
|
246 | 245 | |
247 | - // Delete posts |
|
248 | - $sql = "DELETE FROM $tbl_blogs_posts WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
249 | - Database::query($sql); |
|
246 | + // Delete posts |
|
247 | + $sql = "DELETE FROM $tbl_blogs_posts WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
248 | + Database::query($sql); |
|
250 | 249 | |
251 | - // Delete tasks |
|
252 | - $sql = "DELETE FROM $tbl_blogs_tasks WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
253 | - Database::query($sql); |
|
250 | + // Delete tasks |
|
251 | + $sql = "DELETE FROM $tbl_blogs_tasks WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
252 | + Database::query($sql); |
|
254 | 253 | |
255 | - // Delete ratings |
|
256 | - $sql = "DELETE FROM $tbl_blogs_rating WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
257 | - Database::query($sql); |
|
254 | + // Delete ratings |
|
255 | + $sql = "DELETE FROM $tbl_blogs_rating WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
256 | + Database::query($sql); |
|
258 | 257 | |
259 | - // Delete blog |
|
260 | - $sql ="DELETE FROM $tbl_blogs WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
261 | - Database::query($sql); |
|
258 | + // Delete blog |
|
259 | + $sql ="DELETE FROM $tbl_blogs WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
260 | + Database::query($sql); |
|
262 | 261 | |
263 | - // Delete from course homepage |
|
264 | - $sql = "DELETE FROM $tbl_tool WHERE c_id = $course_id AND link = 'blog/blog.php?blog_id=".$blog_id."'"; |
|
265 | - Database::query($sql); |
|
262 | + // Delete from course homepage |
|
263 | + $sql = "DELETE FROM $tbl_tool WHERE c_id = $course_id AND link = 'blog/blog.php?blog_id=".$blog_id."'"; |
|
264 | + Database::query($sql); |
|
266 | 265 | |
267 | - //update item_property (delete) |
|
266 | + //update item_property (delete) |
|
268 | 267 | api_item_property_update( |
269 | 268 | api_get_course_info(), |
270 | 269 | TOOL_BLOGS, |
@@ -272,152 +271,152 @@ discard block |
||
272 | 271 | 'delete', |
273 | 272 | api_get_user_id() |
274 | 273 | ); |
275 | - } |
|
276 | - |
|
277 | - /** |
|
278 | - * Creates a new post in a given blog |
|
279 | - * @author Toon Keppens |
|
280 | - * @param String $title |
|
281 | - * @param String $full_text |
|
282 | - * @param Integer $blog_id |
|
283 | - */ |
|
284 | - public static function create_post($title, $full_text, $file_comment, $blog_id) |
|
285 | - { |
|
286 | - $_user = api_get_user_info(); |
|
287 | - $_course = api_get_course_info(); |
|
288 | - $course_id = $_course['real_id']; |
|
289 | - |
|
290 | - $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
291 | - $upload_ok=true; |
|
292 | - $has_attachment=false; |
|
293 | - $current_date = api_get_utc_datetime(); |
|
294 | - |
|
295 | - if (!empty($_FILES['user_upload']['name'])) { |
|
296 | - $upload_ok = process_uploaded_file($_FILES['user_upload']); |
|
297 | - $has_attachment=true; |
|
298 | - } |
|
299 | - |
|
300 | - if ($upload_ok) { |
|
301 | - // Table Definitions |
|
302 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
303 | - |
|
304 | - // Create the post |
|
305 | - $sql = "INSERT INTO $tbl_blogs_posts (c_id, title, full_text, date_creation, blog_id, author_id ) |
|
274 | + } |
|
275 | + |
|
276 | + /** |
|
277 | + * Creates a new post in a given blog |
|
278 | + * @author Toon Keppens |
|
279 | + * @param String $title |
|
280 | + * @param String $full_text |
|
281 | + * @param Integer $blog_id |
|
282 | + */ |
|
283 | + public static function create_post($title, $full_text, $file_comment, $blog_id) |
|
284 | + { |
|
285 | + $_user = api_get_user_info(); |
|
286 | + $_course = api_get_course_info(); |
|
287 | + $course_id = $_course['real_id']; |
|
288 | + |
|
289 | + $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
290 | + $upload_ok=true; |
|
291 | + $has_attachment=false; |
|
292 | + $current_date = api_get_utc_datetime(); |
|
293 | + |
|
294 | + if (!empty($_FILES['user_upload']['name'])) { |
|
295 | + $upload_ok = process_uploaded_file($_FILES['user_upload']); |
|
296 | + $has_attachment=true; |
|
297 | + } |
|
298 | + |
|
299 | + if ($upload_ok) { |
|
300 | + // Table Definitions |
|
301 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
302 | + |
|
303 | + // Create the post |
|
304 | + $sql = "INSERT INTO $tbl_blogs_posts (c_id, title, full_text, date_creation, blog_id, author_id ) |
|
306 | 305 | VALUES ($course_id, '".Database::escape_string($title)."', '".Database::escape_string($full_text)."','".$current_date."', '".(int)$blog_id."', '".(int)$_user['user_id']."');"; |
307 | 306 | |
308 | - Database::query($sql); |
|
309 | - $last_post_id = Database::insert_id(); |
|
307 | + Database::query($sql); |
|
308 | + $last_post_id = Database::insert_id(); |
|
310 | 309 | |
311 | 310 | if ($last_post_id) { |
312 | 311 | $sql = "UPDATE $tbl_blogs_posts SET post_id = iid WHERE iid = $last_post_id"; |
313 | 312 | Database::query($sql); |
314 | 313 | } |
315 | 314 | |
316 | - if ($has_attachment) { |
|
317 | - $courseDir = $_course['path'].'/upload/blog'; |
|
318 | - $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
319 | - $updir = $sys_course_path.$courseDir; |
|
320 | - |
|
321 | - // Try to add an extension to the file if it hasn't one |
|
322 | - $new_file_name = add_ext_on_mime(stripslashes($_FILES['user_upload']['name']), $_FILES['user_upload']['type']); |
|
323 | - |
|
324 | - // user's file name |
|
325 | - $file_name = $_FILES['user_upload']['name']; |
|
326 | - |
|
327 | - if (!filter_extension($new_file_name)) { |
|
328 | - Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); |
|
329 | - } else { |
|
330 | - $new_file_name = uniqid(''); |
|
331 | - $new_path = $updir.'/'.$new_file_name; |
|
332 | - $result = @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path); |
|
333 | - $comment = Database::escape_string($file_comment); |
|
334 | - |
|
335 | - // Storing the attachments if any |
|
336 | - if ($result) { |
|
337 | - $sql = 'INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size, blog_id,comment_id) '. |
|
338 | - "VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$last_post_id."', '".intval($_FILES['user_upload']['size'])."', '".$blog_id."', '0' )"; |
|
339 | - Database::query($sql); |
|
315 | + if ($has_attachment) { |
|
316 | + $courseDir = $_course['path'].'/upload/blog'; |
|
317 | + $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
318 | + $updir = $sys_course_path.$courseDir; |
|
319 | + |
|
320 | + // Try to add an extension to the file if it hasn't one |
|
321 | + $new_file_name = add_ext_on_mime(stripslashes($_FILES['user_upload']['name']), $_FILES['user_upload']['type']); |
|
322 | + |
|
323 | + // user's file name |
|
324 | + $file_name = $_FILES['user_upload']['name']; |
|
325 | + |
|
326 | + if (!filter_extension($new_file_name)) { |
|
327 | + Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); |
|
328 | + } else { |
|
329 | + $new_file_name = uniqid(''); |
|
330 | + $new_path = $updir.'/'.$new_file_name; |
|
331 | + $result = @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path); |
|
332 | + $comment = Database::escape_string($file_comment); |
|
333 | + |
|
334 | + // Storing the attachments if any |
|
335 | + if ($result) { |
|
336 | + $sql = 'INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size, blog_id,comment_id) '. |
|
337 | + "VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$last_post_id."', '".intval($_FILES['user_upload']['size'])."', '".$blog_id."', '0' )"; |
|
338 | + Database::query($sql); |
|
340 | 339 | $id = Database::insert_id(); |
341 | 340 | if ($id) { |
342 | 341 | $sql = "UPDATE $blog_table_attachment SET id = iid WHERE iid = $id"; |
343 | 342 | Database::query($sql); |
344 | 343 | } |
345 | - } |
|
346 | - } |
|
347 | - } |
|
348 | - } else { |
|
349 | - Display::display_error_message(get_lang('UplNoFileUploaded')); |
|
350 | - } |
|
351 | - } |
|
352 | - |
|
353 | - /** |
|
354 | - * Edits a post in a given blog |
|
355 | - * @author Toon Keppens |
|
356 | - * @param Integer $blog_id |
|
357 | - * @param String $title |
|
358 | - * @param String $full_text |
|
359 | - * @param Integer $blog_id |
|
360 | - */ |
|
361 | - public static function edit_post($post_id, $title, $full_text, $blog_id) |
|
362 | - { |
|
363 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
344 | + } |
|
345 | + } |
|
346 | + } |
|
347 | + } else { |
|
348 | + Display::display_error_message(get_lang('UplNoFileUploaded')); |
|
349 | + } |
|
350 | + } |
|
351 | + |
|
352 | + /** |
|
353 | + * Edits a post in a given blog |
|
354 | + * @author Toon Keppens |
|
355 | + * @param Integer $blog_id |
|
356 | + * @param String $title |
|
357 | + * @param String $full_text |
|
358 | + * @param Integer $blog_id |
|
359 | + */ |
|
360 | + public static function edit_post($post_id, $title, $full_text, $blog_id) |
|
361 | + { |
|
362 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
364 | 363 | $course_id = api_get_course_int_id(); |
365 | 364 | |
366 | - // Create the post |
|
367 | - $sql = "UPDATE $tbl_blogs_posts SET |
|
365 | + // Create the post |
|
366 | + $sql = "UPDATE $tbl_blogs_posts SET |
|
368 | 367 | title = '" . Database::escape_string($title)."', |
369 | 368 | full_text = '" . Database::escape_string($full_text)."' |
370 | 369 | WHERE c_id = $course_id AND post_id ='".(int)$post_id."' AND blog_id ='".(int)$blog_id."' |
371 | 370 | LIMIT 1 "; |
372 | - Database::query($sql); |
|
373 | - } |
|
374 | - |
|
375 | - /** |
|
376 | - * Deletes an article and it's comments |
|
377 | - * @author Toon Keppens |
|
378 | - * @param int $blog_id |
|
379 | - * @param int $post_id |
|
380 | - */ |
|
381 | - public static function delete_post($blog_id, $post_id) |
|
382 | - { |
|
383 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
384 | - $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
385 | - $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
371 | + Database::query($sql); |
|
372 | + } |
|
373 | + |
|
374 | + /** |
|
375 | + * Deletes an article and it's comments |
|
376 | + * @author Toon Keppens |
|
377 | + * @param int $blog_id |
|
378 | + * @param int $post_id |
|
379 | + */ |
|
380 | + public static function delete_post($blog_id, $post_id) |
|
381 | + { |
|
382 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
383 | + $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
384 | + $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
386 | 385 | |
387 | 386 | $course_id = api_get_course_int_id(); |
388 | 387 | |
389 | - // Delete ratings on this comment |
|
390 | - $sql = "DELETE FROM $tbl_blogs_rating |
|
388 | + // Delete ratings on this comment |
|
389 | + $sql = "DELETE FROM $tbl_blogs_rating |
|
391 | 390 | WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND item_id = '".(int)$post_id."' AND rating_type = 'post'"; |
392 | - Database::query($sql); |
|
391 | + Database::query($sql); |
|
393 | 392 | |
394 | - // Delete the post |
|
395 | - $sql = "DELETE FROM $tbl_blogs_posts |
|
393 | + // Delete the post |
|
394 | + $sql = "DELETE FROM $tbl_blogs_posts |
|
396 | 395 | WHERE c_id = $course_id AND post_id = '".(int)$post_id."'"; |
397 | - Database::query($sql); |
|
396 | + Database::query($sql); |
|
398 | 397 | |
399 | - // Delete the comments |
|
400 | - $sql = "DELETE FROM $tbl_blogs_comments |
|
398 | + // Delete the comments |
|
399 | + $sql = "DELETE FROM $tbl_blogs_comments |
|
401 | 400 | WHERE c_id = $course_id AND post_id = '".(int)$post_id."' AND blog_id = '".(int)$blog_id."'"; |
402 | - Database::query($sql); |
|
403 | - |
|
404 | - // Delete posts and attachments |
|
405 | - delete_all_blog_attachment($blog_id,$post_id); |
|
406 | - } |
|
407 | - |
|
408 | - /** |
|
409 | - * Creates a comment on a post in a given blog |
|
410 | - * @author Toon Keppens |
|
411 | - * @param String $title |
|
412 | - * @param String $full_text |
|
413 | - * @param Integer $blog_id |
|
414 | - * @param Integer $post_id |
|
415 | - * @param Integer $parent_id |
|
416 | - */ |
|
417 | - public static function create_comment($title, $full_text, $file_comment, $blog_id, $post_id, $parent_id, $task_id = 'NULL') |
|
418 | - { |
|
419 | - $_user = api_get_user_info(); |
|
420 | - $_course = api_get_course_info(); |
|
401 | + Database::query($sql); |
|
402 | + |
|
403 | + // Delete posts and attachments |
|
404 | + delete_all_blog_attachment($blog_id,$post_id); |
|
405 | + } |
|
406 | + |
|
407 | + /** |
|
408 | + * Creates a comment on a post in a given blog |
|
409 | + * @author Toon Keppens |
|
410 | + * @param String $title |
|
411 | + * @param String $full_text |
|
412 | + * @param Integer $blog_id |
|
413 | + * @param Integer $post_id |
|
414 | + * @param Integer $parent_id |
|
415 | + */ |
|
416 | + public static function create_comment($title, $full_text, $file_comment, $blog_id, $post_id, $parent_id, $task_id = 'NULL') |
|
417 | + { |
|
418 | + $_user = api_get_user_info(); |
|
419 | + $_course = api_get_course_info(); |
|
421 | 420 | $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
422 | 421 | |
423 | 422 | $upload_ok = true; |
@@ -425,55 +424,55 @@ discard block |
||
425 | 424 | $current_date = api_get_utc_datetime(); |
426 | 425 | $course_id = api_get_course_int_id(); |
427 | 426 | |
428 | - if (!empty($_FILES['user_upload']['name'])) { |
|
429 | - $upload_ok = process_uploaded_file($_FILES['user_upload']); |
|
430 | - $has_attachment=true; |
|
431 | - } |
|
427 | + if (!empty($_FILES['user_upload']['name'])) { |
|
428 | + $upload_ok = process_uploaded_file($_FILES['user_upload']); |
|
429 | + $has_attachment=true; |
|
430 | + } |
|
432 | 431 | |
433 | - if ($upload_ok) { |
|
434 | - // Table Definition |
|
435 | - $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
432 | + if ($upload_ok) { |
|
433 | + // Table Definition |
|
434 | + $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
436 | 435 | |
437 | - // Create the comment |
|
438 | - $sql = "INSERT INTO $tbl_blogs_comments (c_id, title, comment, author_id, date_creation, blog_id, post_id, parent_comment_id, task_id ) |
|
436 | + // Create the comment |
|
437 | + $sql = "INSERT INTO $tbl_blogs_comments (c_id, title, comment, author_id, date_creation, blog_id, post_id, parent_comment_id, task_id ) |
|
439 | 438 | VALUES ($course_id, '".Database::escape_string($title)."', '".Database::escape_string($full_text)."', '".(int)$_user['user_id']."','".$current_date."', '".(int)$blog_id."', '".(int)$post_id."', '".(int)$parent_id."', '".(int)$task_id."')"; |
440 | - Database::query($sql); |
|
439 | + Database::query($sql); |
|
441 | 440 | |
442 | - // Empty post values, or they are shown on the page again |
|
443 | - $last_id = Database::insert_id(); |
|
441 | + // Empty post values, or they are shown on the page again |
|
442 | + $last_id = Database::insert_id(); |
|
444 | 443 | |
445 | 444 | if ($last_id) { |
446 | 445 | $sql = "UPDATE $tbl_blogs_comments SET comment_id = iid WHERE iid = $last_id"; |
447 | 446 | Database::query($sql); |
448 | 447 | } |
449 | 448 | |
450 | - if ($has_attachment) { |
|
451 | - $courseDir = $_course['path'].'/upload/blog'; |
|
452 | - $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
453 | - $updir = $sys_course_path.$courseDir; |
|
454 | - |
|
455 | - // Try to add an extension to the file if it hasn't one |
|
456 | - $new_file_name = add_ext_on_mime( |
|
457 | - stripslashes($_FILES['user_upload']['name']), |
|
458 | - $_FILES['user_upload']['type'] |
|
459 | - ); |
|
460 | - |
|
461 | - // user's file name |
|
462 | - $file_name =$_FILES['user_upload']['name']; |
|
463 | - |
|
464 | - if (!filter_extension($new_file_name)) { |
|
465 | - Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); |
|
466 | - } else { |
|
467 | - $new_file_name = uniqid(''); |
|
468 | - $new_path=$updir.'/'.$new_file_name; |
|
469 | - $result= @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path); |
|
470 | - $comment = Database::escape_string($file_comment); |
|
471 | - |
|
472 | - // Storing the attachments if any |
|
473 | - if ($result) { |
|
474 | - $sql='INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size,blog_id,comment_id) '. |
|
475 | - "VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$post_id."', '".$_FILES['user_upload']['size']."', '".$blog_id."', '".$last_id."' )"; |
|
476 | - Database::query($sql); |
|
449 | + if ($has_attachment) { |
|
450 | + $courseDir = $_course['path'].'/upload/blog'; |
|
451 | + $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
452 | + $updir = $sys_course_path.$courseDir; |
|
453 | + |
|
454 | + // Try to add an extension to the file if it hasn't one |
|
455 | + $new_file_name = add_ext_on_mime( |
|
456 | + stripslashes($_FILES['user_upload']['name']), |
|
457 | + $_FILES['user_upload']['type'] |
|
458 | + ); |
|
459 | + |
|
460 | + // user's file name |
|
461 | + $file_name =$_FILES['user_upload']['name']; |
|
462 | + |
|
463 | + if (!filter_extension($new_file_name)) { |
|
464 | + Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); |
|
465 | + } else { |
|
466 | + $new_file_name = uniqid(''); |
|
467 | + $new_path=$updir.'/'.$new_file_name; |
|
468 | + $result= @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path); |
|
469 | + $comment = Database::escape_string($file_comment); |
|
470 | + |
|
471 | + // Storing the attachments if any |
|
472 | + if ($result) { |
|
473 | + $sql='INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size,blog_id,comment_id) '. |
|
474 | + "VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$post_id."', '".$_FILES['user_upload']['size']."', '".$blog_id."', '".$last_id."' )"; |
|
475 | + Database::query($sql); |
|
477 | 476 | |
478 | 477 | $id = Database::insert_id(); |
479 | 478 | |
@@ -481,91 +480,91 @@ discard block |
||
481 | 480 | $sql = "UPDATE $blog_table_attachment SET id = iid WHERE iid = $id"; |
482 | 481 | Database::query($sql); |
483 | 482 | } |
484 | - } |
|
485 | - } |
|
486 | - } |
|
487 | - } |
|
488 | - } |
|
489 | - |
|
490 | - /** |
|
491 | - * Deletes a comment from a blogpost |
|
492 | - * @author Toon Keppens |
|
493 | - * @param int $blog_id |
|
494 | - * @param int $comment_id |
|
495 | - */ |
|
496 | - public static function delete_comment($blog_id, $post_id, $comment_id) |
|
497 | - { |
|
498 | - $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
499 | - $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
500 | - $blog_id = intval($blog_id); |
|
501 | - $post_id = intval($post_id); |
|
502 | - $comment_id = intval($comment_id); |
|
483 | + } |
|
484 | + } |
|
485 | + } |
|
486 | + } |
|
487 | + } |
|
488 | + |
|
489 | + /** |
|
490 | + * Deletes a comment from a blogpost |
|
491 | + * @author Toon Keppens |
|
492 | + * @param int $blog_id |
|
493 | + * @param int $comment_id |
|
494 | + */ |
|
495 | + public static function delete_comment($blog_id, $post_id, $comment_id) |
|
496 | + { |
|
497 | + $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
498 | + $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
499 | + $blog_id = intval($blog_id); |
|
500 | + $post_id = intval($post_id); |
|
501 | + $comment_id = intval($comment_id); |
|
503 | 502 | $course_id = api_get_course_int_id(); |
504 | 503 | |
505 | - delete_all_blog_attachment($blog_id, $post_id, $comment_id); |
|
504 | + delete_all_blog_attachment($blog_id, $post_id, $comment_id); |
|
506 | 505 | |
507 | - // Delete ratings on this comment |
|
508 | - $sql = "DELETE FROM $tbl_blogs_rating |
|
506 | + // Delete ratings on this comment |
|
507 | + $sql = "DELETE FROM $tbl_blogs_rating |
|
509 | 508 | WHERE |
510 | 509 | c_id = $course_id AND |
511 | 510 | blog_id = '".$blog_id."' AND |
512 | 511 | item_id = '".$comment_id."' AND |
513 | 512 | rating_type = 'comment'"; |
514 | - Database::query($sql); |
|
513 | + Database::query($sql); |
|
515 | 514 | |
516 | - // select comments that have the selected comment as their parent |
|
517 | - $sql = "SELECT comment_id FROM $tbl_blogs_comments |
|
515 | + // select comments that have the selected comment as their parent |
|
516 | + $sql = "SELECT comment_id FROM $tbl_blogs_comments |
|
518 | 517 | WHERE c_id = $course_id AND parent_comment_id = '".$comment_id."'"; |
519 | - $result = Database::query($sql); |
|
518 | + $result = Database::query($sql); |
|
520 | 519 | |
521 | - // Delete them recursively |
|
522 | - while ($comment = Database::fetch_array($result)) { |
|
523 | - Blog::delete_comment($blog_id,$post_id,$comment['comment_id']); |
|
524 | - } |
|
520 | + // Delete them recursively |
|
521 | + while ($comment = Database::fetch_array($result)) { |
|
522 | + Blog::delete_comment($blog_id,$post_id,$comment['comment_id']); |
|
523 | + } |
|
525 | 524 | |
526 | - // Finally, delete the selected comment to |
|
527 | - $sql = "DELETE FROM $tbl_blogs_comments |
|
525 | + // Finally, delete the selected comment to |
|
526 | + $sql = "DELETE FROM $tbl_blogs_comments |
|
528 | 527 | WHERE c_id = $course_id AND comment_id = '".$comment_id."'"; |
529 | - Database::query($sql); |
|
530 | - } |
|
531 | - |
|
532 | - /** |
|
533 | - * Creates a new task in a blog |
|
534 | - * @author Toon Keppens |
|
535 | - * @param Integer $blog_id |
|
536 | - * @param String $title |
|
537 | - * @param String $description |
|
538 | - * @param String $color |
|
539 | - */ |
|
540 | - public static function create_task($blog_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color) |
|
541 | - { |
|
542 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
543 | - $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
544 | - |
|
545 | - $course_id = api_get_course_int_id(); |
|
546 | - |
|
547 | - // Create the task |
|
548 | - $sql = "INSERT INTO $tbl_blogs_tasks (c_id, blog_id, title, description, color, system_task) |
|
528 | + Database::query($sql); |
|
529 | + } |
|
530 | + |
|
531 | + /** |
|
532 | + * Creates a new task in a blog |
|
533 | + * @author Toon Keppens |
|
534 | + * @param Integer $blog_id |
|
535 | + * @param String $title |
|
536 | + * @param String $description |
|
537 | + * @param String $color |
|
538 | + */ |
|
539 | + public static function create_task($blog_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color) |
|
540 | + { |
|
541 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
542 | + $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
543 | + |
|
544 | + $course_id = api_get_course_int_id(); |
|
545 | + |
|
546 | + // Create the task |
|
547 | + $sql = "INSERT INTO $tbl_blogs_tasks (c_id, blog_id, title, description, color, system_task) |
|
549 | 548 | VALUES ($course_id , '".(int)$blog_id."', '" . Database::escape_string($title)."', '" . Database::escape_string($description)."', '" . Database::escape_string($color)."', '0');"; |
550 | - Database::query($sql); |
|
549 | + Database::query($sql); |
|
551 | 550 | |
552 | - $task_id = Database::insert_id(); |
|
551 | + $task_id = Database::insert_id(); |
|
553 | 552 | |
554 | 553 | if ($task_id) { |
555 | 554 | $sql = "UPDATE $tbl_blogs_tasks SET task_id = iid WHERE iid = $task_id"; |
556 | 555 | Database::query($sql); |
557 | 556 | } |
558 | 557 | |
559 | - $tool = 'BLOG_' . $blog_id; |
|
558 | + $tool = 'BLOG_' . $blog_id; |
|
560 | 559 | |
561 | - if ($articleDelete == 'on') { |
|
562 | - $sql = " INSERT INTO " . $tbl_tasks_permissions . " ( c_id, task_id, tool, action) VALUES ( |
|
560 | + if ($articleDelete == 'on') { |
|
561 | + $sql = " INSERT INTO " . $tbl_tasks_permissions . " ( c_id, task_id, tool, action) VALUES ( |
|
563 | 562 | '" . (int)$course_id . "', |
564 | 563 | '" . (int)$task_id . "', |
565 | 564 | '" . Database::escape_string($tool) . "', |
566 | 565 | 'article_delete' |
567 | 566 | )"; |
568 | - Database::query($sql); |
|
567 | + Database::query($sql); |
|
569 | 568 | |
570 | 569 | $id = Database::insert_id(); |
571 | 570 | |
@@ -575,171 +574,171 @@ discard block |
||
575 | 574 | } |
576 | 575 | } |
577 | 576 | |
578 | - if ($articleEdit == 'on') { |
|
579 | - $sql = " |
|
577 | + if ($articleEdit == 'on') { |
|
578 | + $sql = " |
|
580 | 579 | INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action ) VALUES ( |
581 | 580 | '" . (int)$course_id . "', |
582 | 581 | '" . (int)$task_id . "', |
583 | 582 | '" . Database::escape_string($tool) . "', |
584 | 583 | 'article_edit' |
585 | 584 | )"; |
586 | - Database::query($sql); |
|
585 | + Database::query($sql); |
|
587 | 586 | $id = Database::insert_id(); |
588 | 587 | |
589 | 588 | if ($id) { |
590 | 589 | $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id"; |
591 | 590 | Database::query($sql); |
592 | 591 | } |
593 | - } |
|
592 | + } |
|
594 | 593 | |
595 | - if ($commentsDelete == 'on') { |
|
596 | - $sql = " |
|
594 | + if ($commentsDelete == 'on') { |
|
595 | + $sql = " |
|
597 | 596 | INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action ) VALUES ( |
598 | 597 | '" . (int)$course_id . "', |
599 | 598 | '" . (int)$task_id . "', |
600 | 599 | '" . Database::escape_string($tool) . "', |
601 | 600 | 'article_comments_delete' |
602 | 601 | )"; |
603 | - Database::query($sql); |
|
602 | + Database::query($sql); |
|
604 | 603 | $id = Database::insert_id(); |
605 | 604 | |
606 | 605 | if ($id) { |
607 | 606 | $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id"; |
608 | 607 | Database::query($sql); |
609 | 608 | } |
610 | - } |
|
611 | - } |
|
612 | - |
|
613 | - /** |
|
614 | - * Edit a task in a blog |
|
615 | - * @author Toon Keppens |
|
616 | - * @param Integer $task_id |
|
617 | - * @param String $title |
|
618 | - * @param String $description |
|
619 | - * @param String $color |
|
620 | - */ |
|
621 | - public static function edit_task($blog_id, $task_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color) |
|
622 | - { |
|
623 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
624 | - $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
609 | + } |
|
610 | + } |
|
611 | + |
|
612 | + /** |
|
613 | + * Edit a task in a blog |
|
614 | + * @author Toon Keppens |
|
615 | + * @param Integer $task_id |
|
616 | + * @param String $title |
|
617 | + * @param String $description |
|
618 | + * @param String $color |
|
619 | + */ |
|
620 | + public static function edit_task($blog_id, $task_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color) |
|
621 | + { |
|
622 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
623 | + $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
625 | 624 | |
626 | 625 | $course_id = api_get_course_int_id(); |
627 | 626 | |
628 | - // Create the task |
|
629 | - $sql = "UPDATE $tbl_blogs_tasks SET |
|
627 | + // Create the task |
|
628 | + $sql = "UPDATE $tbl_blogs_tasks SET |
|
630 | 629 | title = '".Database::escape_string($title)."', |
631 | 630 | description = '".Database::escape_string($description)."', |
632 | 631 | color = '".Database::escape_string($color)."' |
633 | 632 | WHERE c_id = $course_id AND task_id ='".(int)$task_id."' LIMIT 1"; |
634 | - Database::query($sql); |
|
633 | + Database::query($sql); |
|
635 | 634 | |
636 | - $tool = 'BLOG_' . $blog_id; |
|
635 | + $tool = 'BLOG_' . $blog_id; |
|
637 | 636 | |
638 | - $sql = "DELETE FROM " . $tbl_tasks_permissions . " |
|
637 | + $sql = "DELETE FROM " . $tbl_tasks_permissions . " |
|
639 | 638 | WHERE c_id = $course_id AND task_id = '" . (int)$task_id."'"; |
640 | - Database::query($sql); |
|
639 | + Database::query($sql); |
|
641 | 640 | |
642 | - if ($articleDelete == 'on') { |
|
643 | - $sql = "INSERT INTO " . $tbl_tasks_permissions . " ( c_id, task_id, tool, action) VALUES ( |
|
641 | + if ($articleDelete == 'on') { |
|
642 | + $sql = "INSERT INTO " . $tbl_tasks_permissions . " ( c_id, task_id, tool, action) VALUES ( |
|
644 | 643 | '" . (int)$course_id . "', |
645 | 644 | '" . (int)$task_id . "', |
646 | 645 | '" . Database::escape_string($tool) . "', |
647 | 646 | 'article_delete' |
648 | 647 | )"; |
649 | - Database::query($sql); |
|
648 | + Database::query($sql); |
|
650 | 649 | $id = Database::insert_id(); |
651 | 650 | |
652 | 651 | if ($id) { |
653 | 652 | $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id"; |
654 | 653 | Database::query($sql); |
655 | 654 | } |
656 | - } |
|
655 | + } |
|
657 | 656 | |
658 | - if ($articleEdit == 'on') { |
|
659 | - $sql = "INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES ( |
|
657 | + if ($articleEdit == 'on') { |
|
658 | + $sql = "INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES ( |
|
660 | 659 | '" . (int)$course_id . "', |
661 | 660 | '" . (int)$task_id . "', |
662 | 661 | '" . Database::escape_string($tool) . "', |
663 | 662 | 'article_edit' |
664 | 663 | )"; |
665 | - Database::query($sql); |
|
664 | + Database::query($sql); |
|
666 | 665 | $id = Database::insert_id(); |
667 | 666 | |
668 | 667 | if ($id) { |
669 | 668 | $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id"; |
670 | 669 | Database::query($sql); |
671 | 670 | } |
672 | - } |
|
671 | + } |
|
673 | 672 | |
674 | - if ($commentsDelete == 'on') { |
|
675 | - $sql = " INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES ( |
|
673 | + if ($commentsDelete == 'on') { |
|
674 | + $sql = " INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES ( |
|
676 | 675 | '" . (int)$course_id . "', |
677 | 676 | '" . (int)$task_id . "', |
678 | 677 | '" . Database::escape_string($tool) . "', |
679 | 678 | 'article_comments_delete' |
680 | 679 | )"; |
681 | - Database::query($sql); |
|
680 | + Database::query($sql); |
|
682 | 681 | $id = Database::insert_id(); |
683 | 682 | |
684 | 683 | if ($id) { |
685 | 684 | $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id"; |
686 | 685 | Database::query($sql); |
687 | 686 | } |
688 | - } |
|
689 | - } |
|
690 | - |
|
691 | - /** |
|
692 | - * Deletes a task from a blog |
|
693 | - * @param Integer $blog_id |
|
694 | - * @param Integer $task_id |
|
695 | - */ |
|
696 | - public static function delete_task($blog_id, $task_id) |
|
697 | - { |
|
698 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
699 | - $course_id = api_get_course_int_id(); |
|
700 | - |
|
701 | - // Delete posts |
|
702 | - $sql = "DELETE FROM $tbl_blogs_tasks |
|
687 | + } |
|
688 | + } |
|
689 | + |
|
690 | + /** |
|
691 | + * Deletes a task from a blog |
|
692 | + * @param Integer $blog_id |
|
693 | + * @param Integer $task_id |
|
694 | + */ |
|
695 | + public static function delete_task($blog_id, $task_id) |
|
696 | + { |
|
697 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
698 | + $course_id = api_get_course_int_id(); |
|
699 | + |
|
700 | + // Delete posts |
|
701 | + $sql = "DELETE FROM $tbl_blogs_tasks |
|
703 | 702 | WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND task_id = '".(int)$task_id."'"; |
704 | - Database::query($sql); |
|
705 | - } |
|
706 | - |
|
707 | - /** |
|
708 | - * Deletes an assigned task from a blog |
|
709 | - * @param Integer $blog_id |
|
710 | - */ |
|
711 | - public static function delete_assigned_task($blog_id, $task_id, $user_id) |
|
712 | - { |
|
713 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
703 | + Database::query($sql); |
|
704 | + } |
|
705 | + |
|
706 | + /** |
|
707 | + * Deletes an assigned task from a blog |
|
708 | + * @param Integer $blog_id |
|
709 | + */ |
|
710 | + public static function delete_assigned_task($blog_id, $task_id, $user_id) |
|
711 | + { |
|
712 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
714 | 713 | $course_id = api_get_course_int_id(); |
715 | 714 | |
716 | - // Delete posts |
|
717 | - $sql = "DELETE FROM $tbl_blogs_tasks_rel_user |
|
715 | + // Delete posts |
|
716 | + $sql = "DELETE FROM $tbl_blogs_tasks_rel_user |
|
718 | 717 | WHERE |
719 | 718 | c_id = $course_id AND |
720 | 719 | blog_id = '".(int)$blog_id."' AND |
721 | 720 | task_id = '".(int)$task_id."' AND |
722 | 721 | user_id = '".(int)$user_id."'"; |
723 | - Database::query($sql); |
|
724 | - } |
|
725 | - |
|
726 | - /** |
|
727 | - * Get personal task list |
|
728 | - * @author Toon Keppens |
|
729 | - * @return Returns an unsorted list (<ul></ul>) with the users' tasks |
|
730 | - */ |
|
731 | - public static function get_personal_task_list() |
|
732 | - { |
|
733 | - $_user = api_get_user_info(); |
|
734 | - |
|
735 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
736 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
737 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
738 | - |
|
739 | - $course_id = api_get_course_int_id(); |
|
740 | - |
|
741 | - if ($_user['user_id']) { |
|
742 | - $sql = "SELECT task_rel_user.*, task.title, blog.blog_name |
|
722 | + Database::query($sql); |
|
723 | + } |
|
724 | + |
|
725 | + /** |
|
726 | + * Get personal task list |
|
727 | + * @author Toon Keppens |
|
728 | + * @return Returns an unsorted list (<ul></ul>) with the users' tasks |
|
729 | + */ |
|
730 | + public static function get_personal_task_list() |
|
731 | + { |
|
732 | + $_user = api_get_user_info(); |
|
733 | + |
|
734 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
735 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
736 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
737 | + |
|
738 | + $course_id = api_get_course_int_id(); |
|
739 | + |
|
740 | + if ($_user['user_id']) { |
|
741 | + $sql = "SELECT task_rel_user.*, task.title, blog.blog_name |
|
743 | 742 | FROM $tbl_blogs_tasks_rel_user task_rel_user |
744 | 743 | INNER JOIN $tbl_blogs_tasks task |
745 | 744 | ON task_rel_user.task_id = task.task_id |
@@ -753,85 +752,85 @@ discard block |
||
753 | 752 | task_rel_user.user_id = ".(int)$_user['user_id']." |
754 | 753 | ORDER BY target_date ASC"; |
755 | 754 | |
756 | - $result = Database::query($sql); |
|
757 | - |
|
758 | - if (Database::num_rows($result) > 0) { |
|
759 | - echo '<ul>'; |
|
760 | - while ($mytask = Database::fetch_array($result)) { |
|
761 | - echo '<li><a href="blog.php?action=execute_task&blog_id=' . $mytask['blog_id'] . '&task_id='.stripslashes($mytask['task_id']) . '" title="[Blog: '.stripslashes($mytask['blog_name']) . '] ' . get_lang('ExecuteThisTask') . '">'.stripslashes($mytask['title']) . '</a></li>'; |
|
762 | - } |
|
763 | - echo '<ul>'; |
|
764 | - } else { |
|
765 | - echo get_lang('NoTasks'); |
|
766 | - } |
|
767 | - } else { |
|
768 | - echo get_lang('NoTasks'); |
|
769 | - } |
|
770 | - } |
|
771 | - |
|
772 | - /** |
|
773 | - * Changes the visibility of a blog |
|
774 | - * @author Toon Keppens |
|
775 | - * @param Integer $blog_id |
|
776 | - */ |
|
777 | - public static function change_blog_visibility($blog_id) |
|
778 | - { |
|
779 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
780 | - $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST); |
|
781 | - $course_id = api_get_course_int_id(); |
|
782 | - |
|
783 | - // Get blog properties |
|
784 | - $sql = "SELECT blog_name, visibility FROM $tbl_blogs |
|
755 | + $result = Database::query($sql); |
|
756 | + |
|
757 | + if (Database::num_rows($result) > 0) { |
|
758 | + echo '<ul>'; |
|
759 | + while ($mytask = Database::fetch_array($result)) { |
|
760 | + echo '<li><a href="blog.php?action=execute_task&blog_id=' . $mytask['blog_id'] . '&task_id='.stripslashes($mytask['task_id']) . '" title="[Blog: '.stripslashes($mytask['blog_name']) . '] ' . get_lang('ExecuteThisTask') . '">'.stripslashes($mytask['title']) . '</a></li>'; |
|
761 | + } |
|
762 | + echo '<ul>'; |
|
763 | + } else { |
|
764 | + echo get_lang('NoTasks'); |
|
765 | + } |
|
766 | + } else { |
|
767 | + echo get_lang('NoTasks'); |
|
768 | + } |
|
769 | + } |
|
770 | + |
|
771 | + /** |
|
772 | + * Changes the visibility of a blog |
|
773 | + * @author Toon Keppens |
|
774 | + * @param Integer $blog_id |
|
775 | + */ |
|
776 | + public static function change_blog_visibility($blog_id) |
|
777 | + { |
|
778 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
779 | + $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST); |
|
780 | + $course_id = api_get_course_int_id(); |
|
781 | + |
|
782 | + // Get blog properties |
|
783 | + $sql = "SELECT blog_name, visibility FROM $tbl_blogs |
|
785 | 784 | WHERE c_id = $course_id AND blog_id='".(int)$blog_id."'"; |
786 | - $result = Database::query($sql); |
|
787 | - $blog = Database::fetch_array($result); |
|
788 | - $visibility = $blog['visibility']; |
|
789 | - $title = $blog['blog_name']; |
|
790 | - |
|
791 | - if ($visibility == 1) { |
|
792 | - // Change visibility state, remove from course home. |
|
793 | - $sql = "UPDATE $tbl_blogs SET visibility = '0' |
|
785 | + $result = Database::query($sql); |
|
786 | + $blog = Database::fetch_array($result); |
|
787 | + $visibility = $blog['visibility']; |
|
788 | + $title = $blog['blog_name']; |
|
789 | + |
|
790 | + if ($visibility == 1) { |
|
791 | + // Change visibility state, remove from course home. |
|
792 | + $sql = "UPDATE $tbl_blogs SET visibility = '0' |
|
794 | 793 | WHERE c_id = $course_id AND blog_id ='".(int)$blog_id."' LIMIT 1"; |
795 | - Database::query($sql); |
|
794 | + Database::query($sql); |
|
796 | 795 | |
797 | - $sql = "DELETE FROM $tbl_tool |
|
796 | + $sql = "DELETE FROM $tbl_tool |
|
798 | 797 | WHERE c_id = $course_id AND name = '".Database::escape_string($title)."' LIMIT 1"; |
799 | - Database::query($sql); |
|
800 | - } else { |
|
801 | - // Change visibility state, add to course home. |
|
802 | - $sql = "UPDATE $tbl_blogs SET visibility = '1' |
|
798 | + Database::query($sql); |
|
799 | + } else { |
|
800 | + // Change visibility state, add to course home. |
|
801 | + $sql = "UPDATE $tbl_blogs SET visibility = '1' |
|
803 | 802 | WHERE c_id = $course_id AND blog_id ='".(int)$blog_id."' LIMIT 1"; |
804 | - Database::query($sql); |
|
803 | + Database::query($sql); |
|
805 | 804 | |
806 | - $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, target ) |
|
805 | + $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, target ) |
|
807 | 806 | VALUES ($course_id, '".Database::escape_string($title)."', 'blog/blog.php?blog_id=".(int)$blog_id."', 'blog.gif', '1', '0', 'pastillegris.gif', '0', '_self')"; |
808 | - Database::query($sql); |
|
807 | + Database::query($sql); |
|
809 | 808 | $id = Database::insert_id(); |
810 | 809 | |
811 | 810 | if ($id) { |
812 | 811 | $sql = "UPDATE $tbl_tool SET id = iid WHERE iid = $id"; |
813 | 812 | Database::query($sql); |
814 | 813 | } |
815 | - } |
|
816 | - } |
|
817 | - |
|
818 | - /** |
|
819 | - * Shows the posts of a blog |
|
820 | - * @author Toon Keppens |
|
821 | - * |
|
822 | - * @param Integer $blog_id |
|
823 | - */ |
|
824 | - public static function display_blog_posts($blog_id, $filter = '1=1', $max_number_of_posts = 20) |
|
814 | + } |
|
815 | + } |
|
816 | + |
|
817 | + /** |
|
818 | + * Shows the posts of a blog |
|
819 | + * @author Toon Keppens |
|
820 | + * |
|
821 | + * @param Integer $blog_id |
|
822 | + */ |
|
823 | + public static function display_blog_posts($blog_id, $filter = '1=1', $max_number_of_posts = 20) |
|
825 | 824 | { |
826 | - // Init |
|
827 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
828 | - $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
829 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
825 | + // Init |
|
826 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
827 | + $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
828 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
830 | 829 | |
831 | - $course_id = api_get_course_int_id(); |
|
830 | + $course_id = api_get_course_int_id(); |
|
832 | 831 | |
833 | - // Get posts and authors |
|
834 | - $sql = "SELECT post.*, user.lastname, user.firstname, user.username |
|
832 | + // Get posts and authors |
|
833 | + $sql = "SELECT post.*, user.lastname, user.firstname, user.username |
|
835 | 834 | FROM $tbl_blogs_posts post |
836 | 835 | INNER JOIN $tbl_users user |
837 | 836 | ON post.author_id = user.user_id |
@@ -839,131 +838,131 @@ discard block |
||
839 | 838 | post.c_id = $course_id AND |
840 | 839 | $filter |
841 | 840 | ORDER BY post_id DESC LIMIT 0,".(int)$max_number_of_posts; |
842 | - $result = Database::query($sql); |
|
843 | - |
|
844 | - // Display |
|
845 | - if(Database::num_rows($result) > 0) { |
|
846 | - $limit = 200; |
|
847 | - while ($blog_post = Database::fetch_array($result)) { |
|
848 | - // Get number of comments |
|
849 | - $sql = "SELECT COUNT(1) as number_of_comments |
|
841 | + $result = Database::query($sql); |
|
842 | + |
|
843 | + // Display |
|
844 | + if(Database::num_rows($result) > 0) { |
|
845 | + $limit = 200; |
|
846 | + while ($blog_post = Database::fetch_array($result)) { |
|
847 | + // Get number of comments |
|
848 | + $sql = "SELECT COUNT(1) as number_of_comments |
|
850 | 849 | FROM $tbl_blogs_comments |
851 | 850 | WHERE |
852 | 851 | c_id = $course_id AND |
853 | 852 | blog_id = '".(int)$blog_id."' AND |
854 | 853 | post_id = '" . (int)$blog_post['post_id']."'"; |
855 | - $tmp = Database::query($sql); |
|
856 | - $blog_post_comments = Database::fetch_array($tmp); |
|
857 | - |
|
858 | - // Prepare data |
|
859 | - $blog_post_id = $blog_post['post_id']; |
|
860 | - $blog_post_text = make_clickable(stripslashes($blog_post['full_text'])); |
|
861 | - $blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get()); |
|
862 | - |
|
863 | - // Create an introduction text (but keep FULL sentences) |
|
864 | - $words = 0; |
|
865 | - $blog_post_text_cut = cut($blog_post_text, $limit) ; |
|
866 | - $words = strlen($blog_post_text); |
|
867 | - |
|
868 | - if ($words >= $limit) { |
|
869 | - $readMoreLink = ' <div class="link" onclick="document.getElementById(\'blogpost_text_' . $blog_post_id . '\').style.display=\'block\'; document.getElementById(\'blogpost_introduction_' . $blog_post_id . '\').style.display=\'none\'">' . get_lang('ReadMore') . '</div>'; |
|
870 | - $introduction_text = $blog_post_text_cut; |
|
871 | - } else { |
|
872 | - $introduction_text = $blog_post_text; |
|
873 | - $readMoreLink = ''; |
|
874 | - } |
|
875 | - |
|
876 | - $introduction_text = stripslashes($introduction_text); |
|
877 | - |
|
878 | - echo '<div class="blogpost">'; |
|
879 | - echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >'.stripslashes($blog_post['title']) . '</a></span>'; |
|
880 | - echo '<span class="blogpost_date"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . $blog_post_date . '</a></span>'; |
|
881 | - echo '<div class="blogpost_introduction" id="blogpost_introduction_'.$blog_post_id.'">' . $introduction_text.$readMoreLink.'</div>'; |
|
882 | - echo '<div class="blogpost_text" id="blogpost_text_' . $blog_post_id . '" style="display: none">' . $blog_post_text . '</div>'; |
|
883 | - |
|
884 | - $file_name_array = get_blog_attachment($blog_id,$blog_post_id,0); |
|
885 | - |
|
886 | - if (!empty($file_name_array)) { |
|
887 | - echo '<br /><br />'; |
|
888 | - echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
889 | - echo '<a href="download.php?file='; |
|
890 | - echo $file_name_array['path']; |
|
891 | - echo ' "> '.$file_name_array['filename'].' </a><br />'; |
|
892 | - echo '</span>'; |
|
893 | - } |
|
894 | - $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES); |
|
895 | - echo '<span class="blogpost_info">' . get_lang('Author') . ': ' . Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)) .' - <a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . get_lang('Comments') . ': ' . $blog_post_comments['number_of_comments'] . '</a></span>'; |
|
896 | - echo '</div>'; |
|
897 | - } |
|
898 | - } else { |
|
899 | - if($filter == '1=1') { |
|
900 | - echo get_lang('NoArticles'); |
|
901 | - } else { |
|
902 | - echo get_lang('NoArticleMatches'); |
|
903 | - } |
|
904 | - } |
|
854 | + $tmp = Database::query($sql); |
|
855 | + $blog_post_comments = Database::fetch_array($tmp); |
|
856 | + |
|
857 | + // Prepare data |
|
858 | + $blog_post_id = $blog_post['post_id']; |
|
859 | + $blog_post_text = make_clickable(stripslashes($blog_post['full_text'])); |
|
860 | + $blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get()); |
|
861 | + |
|
862 | + // Create an introduction text (but keep FULL sentences) |
|
863 | + $words = 0; |
|
864 | + $blog_post_text_cut = cut($blog_post_text, $limit) ; |
|
865 | + $words = strlen($blog_post_text); |
|
866 | + |
|
867 | + if ($words >= $limit) { |
|
868 | + $readMoreLink = ' <div class="link" onclick="document.getElementById(\'blogpost_text_' . $blog_post_id . '\').style.display=\'block\'; document.getElementById(\'blogpost_introduction_' . $blog_post_id . '\').style.display=\'none\'">' . get_lang('ReadMore') . '</div>'; |
|
869 | + $introduction_text = $blog_post_text_cut; |
|
870 | + } else { |
|
871 | + $introduction_text = $blog_post_text; |
|
872 | + $readMoreLink = ''; |
|
873 | + } |
|
874 | + |
|
875 | + $introduction_text = stripslashes($introduction_text); |
|
876 | + |
|
877 | + echo '<div class="blogpost">'; |
|
878 | + echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >'.stripslashes($blog_post['title']) . '</a></span>'; |
|
879 | + echo '<span class="blogpost_date"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . $blog_post_date . '</a></span>'; |
|
880 | + echo '<div class="blogpost_introduction" id="blogpost_introduction_'.$blog_post_id.'">' . $introduction_text.$readMoreLink.'</div>'; |
|
881 | + echo '<div class="blogpost_text" id="blogpost_text_' . $blog_post_id . '" style="display: none">' . $blog_post_text . '</div>'; |
|
882 | + |
|
883 | + $file_name_array = get_blog_attachment($blog_id,$blog_post_id,0); |
|
884 | + |
|
885 | + if (!empty($file_name_array)) { |
|
886 | + echo '<br /><br />'; |
|
887 | + echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
888 | + echo '<a href="download.php?file='; |
|
889 | + echo $file_name_array['path']; |
|
890 | + echo ' "> '.$file_name_array['filename'].' </a><br />'; |
|
891 | + echo '</span>'; |
|
892 | + } |
|
893 | + $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES); |
|
894 | + echo '<span class="blogpost_info">' . get_lang('Author') . ': ' . Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)) .' - <a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . get_lang('Comments') . ': ' . $blog_post_comments['number_of_comments'] . '</a></span>'; |
|
895 | + echo '</div>'; |
|
896 | + } |
|
897 | + } else { |
|
898 | + if($filter == '1=1') { |
|
899 | + echo get_lang('NoArticles'); |
|
900 | + } else { |
|
901 | + echo get_lang('NoArticleMatches'); |
|
902 | + } |
|
903 | + } |
|
905 | 904 | } |
906 | 905 | |
907 | - /** |
|
908 | - * Display the search results |
|
909 | - * |
|
910 | - * @param Integer $blog_id |
|
911 | - * @param String $query_string |
|
912 | - */ |
|
913 | - public static function display_search_results ($blog_id, $query_string) |
|
914 | - { |
|
915 | - // Init |
|
916 | - $query_string = Database::escape_string($query_string); |
|
917 | - $query_string_parts = explode(' ',$query_string); |
|
918 | - $query_string = array(); |
|
919 | - foreach ($query_string_parts as $query_part) { |
|
920 | - $query_string[] = " full_text LIKE '%" . $query_part."%' OR title LIKE '%" . $query_part."%' "; |
|
921 | - } |
|
922 | - $query_string = '('.implode('OR',$query_string) . ')'; |
|
923 | - |
|
924 | - // Display the posts |
|
925 | - echo '<span class="blogpost_title">' . get_lang('SearchResults') . '</span>'; |
|
926 | - Blog::display_blog_posts($blog_id, $query_string); |
|
927 | - } |
|
928 | - |
|
929 | - /** |
|
930 | - * Display posts from a certain date |
|
931 | - * |
|
932 | - * @param Integer $blog_id |
|
933 | - * @param String $query_string |
|
934 | - */ |
|
935 | - public static function display_day_results($blog_id, $query_string) |
|
936 | - { |
|
937 | - $date_output = $query_string; |
|
938 | - $date = explode('-',$query_string); |
|
939 | - $query_string = ' DAYOFMONTH(date_creation) =' . intval($date[2]) . ' AND MONTH(date_creation) =' . intval($date[1]) . ' AND YEAR(date_creation) =' . intval($date[0]); |
|
940 | - |
|
941 | - // Put date in correct output format |
|
942 | - $date_output = api_format_date($date_output, DATE_FORMAT_LONG); |
|
943 | - |
|
944 | - // Display the posts |
|
945 | - echo '<span class="blogpost_title">' . get_lang('PostsOf') . ': ' . $date_output . '</span>'; |
|
946 | - Blog::display_blog_posts($blog_id, $query_string); |
|
947 | - } |
|
948 | - |
|
949 | - /** |
|
950 | - * Displays a post and his comments |
|
951 | - * |
|
952 | - * @param Integer $blog_id |
|
953 | - * @param Integer $post_id |
|
954 | - */ |
|
955 | - public static function display_post($blog_id, $post_id) |
|
956 | - { |
|
957 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
958 | - $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
959 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
960 | - |
|
961 | - global $charset, $dateFormatLong; |
|
962 | - |
|
963 | - $course_id = api_get_course_int_id(); |
|
964 | - |
|
965 | - // Get posts and author |
|
966 | - $sql = "SELECT post.*, user.lastname, user.firstname, user.username |
|
906 | + /** |
|
907 | + * Display the search results |
|
908 | + * |
|
909 | + * @param Integer $blog_id |
|
910 | + * @param String $query_string |
|
911 | + */ |
|
912 | + public static function display_search_results ($blog_id, $query_string) |
|
913 | + { |
|
914 | + // Init |
|
915 | + $query_string = Database::escape_string($query_string); |
|
916 | + $query_string_parts = explode(' ',$query_string); |
|
917 | + $query_string = array(); |
|
918 | + foreach ($query_string_parts as $query_part) { |
|
919 | + $query_string[] = " full_text LIKE '%" . $query_part."%' OR title LIKE '%" . $query_part."%' "; |
|
920 | + } |
|
921 | + $query_string = '('.implode('OR',$query_string) . ')'; |
|
922 | + |
|
923 | + // Display the posts |
|
924 | + echo '<span class="blogpost_title">' . get_lang('SearchResults') . '</span>'; |
|
925 | + Blog::display_blog_posts($blog_id, $query_string); |
|
926 | + } |
|
927 | + |
|
928 | + /** |
|
929 | + * Display posts from a certain date |
|
930 | + * |
|
931 | + * @param Integer $blog_id |
|
932 | + * @param String $query_string |
|
933 | + */ |
|
934 | + public static function display_day_results($blog_id, $query_string) |
|
935 | + { |
|
936 | + $date_output = $query_string; |
|
937 | + $date = explode('-',$query_string); |
|
938 | + $query_string = ' DAYOFMONTH(date_creation) =' . intval($date[2]) . ' AND MONTH(date_creation) =' . intval($date[1]) . ' AND YEAR(date_creation) =' . intval($date[0]); |
|
939 | + |
|
940 | + // Put date in correct output format |
|
941 | + $date_output = api_format_date($date_output, DATE_FORMAT_LONG); |
|
942 | + |
|
943 | + // Display the posts |
|
944 | + echo '<span class="blogpost_title">' . get_lang('PostsOf') . ': ' . $date_output . '</span>'; |
|
945 | + Blog::display_blog_posts($blog_id, $query_string); |
|
946 | + } |
|
947 | + |
|
948 | + /** |
|
949 | + * Displays a post and his comments |
|
950 | + * |
|
951 | + * @param Integer $blog_id |
|
952 | + * @param Integer $post_id |
|
953 | + */ |
|
954 | + public static function display_post($blog_id, $post_id) |
|
955 | + { |
|
956 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
957 | + $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
958 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
959 | + |
|
960 | + global $charset, $dateFormatLong; |
|
961 | + |
|
962 | + $course_id = api_get_course_int_id(); |
|
963 | + |
|
964 | + // Get posts and author |
|
965 | + $sql = "SELECT post.*, user.lastname, user.firstname, user.username |
|
967 | 966 | FROM $tbl_blogs_posts post |
968 | 967 | INNER JOIN $tbl_users user |
969 | 968 | ON post.author_id = user.user_id |
@@ -972,113 +971,113 @@ discard block |
||
972 | 971 | post.blog_id = '".(int)$blog_id."' AND |
973 | 972 | post.post_id = '".(int)$post_id."' |
974 | 973 | ORDER BY post_id DESC"; |
975 | - $result = Database::query($sql); |
|
976 | - $blog_post = Database::fetch_array($result); |
|
974 | + $result = Database::query($sql); |
|
975 | + $blog_post = Database::fetch_array($result); |
|
977 | 976 | |
978 | - // Get number of comments |
|
979 | - $sql = "SELECT COUNT(1) as number_of_comments |
|
977 | + // Get number of comments |
|
978 | + $sql = "SELECT COUNT(1) as number_of_comments |
|
980 | 979 | FROM $tbl_blogs_comments |
981 | 980 | WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND post_id = '".(int)$post_id."'"; |
982 | - $result = Database::query($sql); |
|
983 | - $blog_post_comments = Database::fetch_array($result); |
|
981 | + $result = Database::query($sql); |
|
982 | + $blog_post_comments = Database::fetch_array($result); |
|
984 | 983 | |
985 | - // Prepare data |
|
986 | - $blog_post_text = make_clickable(stripslashes($blog_post['full_text'])); |
|
987 | - $blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get()); |
|
988 | - $blog_post_actions = ""; |
|
984 | + // Prepare data |
|
985 | + $blog_post_text = make_clickable(stripslashes($blog_post['full_text'])); |
|
986 | + $blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get()); |
|
987 | + $blog_post_actions = ""; |
|
989 | 988 | |
990 | - $task_id = (isset($_GET['task_id']) && is_numeric($_GET['task_id'])) ? intval($_GET['task_id']) : 0; |
|
989 | + $task_id = (isset($_GET['task_id']) && is_numeric($_GET['task_id'])) ? intval($_GET['task_id']) : 0; |
|
991 | 990 | |
992 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_edit', $task_id)) { |
|
993 | - $blog_post_actions .= '<a href="blog.php?action=edit_post&blog_id=' . $blog_id . '&post_id=' . $post_id . '&article_id=' . $blog_post['post_id'] . '&task_id=' . $task_id . '" title="' . get_lang('EditThisPost') . '">'; |
|
994 | - $blog_post_actions .= Display::return_icon('edit.png'); |
|
995 | - $blog_post_actions .= '</a>'; |
|
991 | + if (api_is_allowed('BLOG_' . $blog_id, 'article_edit', $task_id)) { |
|
992 | + $blog_post_actions .= '<a href="blog.php?action=edit_post&blog_id=' . $blog_id . '&post_id=' . $post_id . '&article_id=' . $blog_post['post_id'] . '&task_id=' . $task_id . '" title="' . get_lang('EditThisPost') . '">'; |
|
993 | + $blog_post_actions .= Display::return_icon('edit.png'); |
|
994 | + $blog_post_actions .= '</a>'; |
|
996 | 995 | } |
997 | 996 | |
998 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_delete', $task_id)) { |
|
999 | - $blog_post_actions .= '<a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $post_id . '&do=delete_article&article_id=' . $blog_post['post_id'] . '&task_id=' . $task_id . '" title="' . get_lang('DeleteThisArticle') . '" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;">'; |
|
997 | + if (api_is_allowed('BLOG_' . $blog_id, 'article_delete', $task_id)) { |
|
998 | + $blog_post_actions .= '<a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $post_id . '&do=delete_article&article_id=' . $blog_post['post_id'] . '&task_id=' . $task_id . '" title="' . get_lang('DeleteThisArticle') . '" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;">'; |
|
1000 | 999 | $blog_post_actions .= Display::return_icon('delete.png'); |
1001 | 1000 | $blog_post_actions .= '</a>'; |
1002 | 1001 | } |
1003 | 1002 | |
1004 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_rate')) |
|
1005 | - $rating_select = Blog::display_rating_form('post',$blog_id,$post_id); |
|
1003 | + if (api_is_allowed('BLOG_' . $blog_id, 'article_rate')) |
|
1004 | + $rating_select = Blog::display_rating_form('post',$blog_id,$post_id); |
|
1006 | 1005 | |
1007 | - $blog_post_text=stripslashes($blog_post_text); |
|
1006 | + $blog_post_text=stripslashes($blog_post_text); |
|
1008 | 1007 | |
1009 | - // Display post |
|
1010 | - echo '<div class="blogpost">'; |
|
1011 | - echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '" title="' . get_lang('ReadPost') . '" >'.stripslashes($blog_post['title']) . '</a></span>'; |
|
1012 | - echo '<span class="blogpost_date">' . $blog_post_date . '</span>'; |
|
1013 | - echo '<span class="blogpost_text">' . $blog_post_text . '</span><br />'; |
|
1008 | + // Display post |
|
1009 | + echo '<div class="blogpost">'; |
|
1010 | + echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '" title="' . get_lang('ReadPost') . '" >'.stripslashes($blog_post['title']) . '</a></span>'; |
|
1011 | + echo '<span class="blogpost_date">' . $blog_post_date . '</span>'; |
|
1012 | + echo '<span class="blogpost_text">' . $blog_post_text . '</span><br />'; |
|
1014 | 1013 | |
1015 | - $file_name_array = get_blog_attachment($blog_id, $post_id); |
|
1014 | + $file_name_array = get_blog_attachment($blog_id, $post_id); |
|
1016 | 1015 | |
1017 | 1016 | if (!empty($file_name_array)) { |
1018 | - echo ' <br />'; |
|
1019 | - echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
1020 | - echo '<a href="download.php?file='; |
|
1021 | - echo $file_name_array['path']; |
|
1022 | - echo ' "> '.$file_name_array['filename'].' </a>'; |
|
1023 | - echo '</span>'; |
|
1024 | - echo '<span class="attachment_comment">'; |
|
1025 | - echo $file_name_array['comment']; |
|
1026 | - echo '</span>'; |
|
1027 | - echo '<br />'; |
|
1028 | - } |
|
1017 | + echo ' <br />'; |
|
1018 | + echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
1019 | + echo '<a href="download.php?file='; |
|
1020 | + echo $file_name_array['path']; |
|
1021 | + echo ' "> '.$file_name_array['filename'].' </a>'; |
|
1022 | + echo '</span>'; |
|
1023 | + echo '<span class="attachment_comment">'; |
|
1024 | + echo $file_name_array['comment']; |
|
1025 | + echo '</span>'; |
|
1026 | + echo '<br />'; |
|
1027 | + } |
|
1029 | 1028 | $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES); |
1030 | - echo '<span class="blogpost_info">'.get_lang('Author').': ' .Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)).' - '.get_lang('Comments').': '.$blog_post_comments['number_of_comments'].' - '.get_lang('Rating').': '.Blog::display_rating('post',$blog_id,$post_id).$rating_select.'</span>'; |
|
1031 | - echo '<span class="blogpost_actions">' . $blog_post_actions . '</span>'; |
|
1032 | - echo '</div>'; |
|
1033 | - |
|
1034 | - // Display comments if there are any |
|
1035 | - if($blog_post_comments['number_of_comments'] > 0) { |
|
1036 | - echo '<div class="comments">'; |
|
1037 | - echo '<span class="blogpost_title">' . get_lang('Comments') . '</span><br />'; |
|
1038 | - Blog::get_threaded_comments(0, 0, $blog_id, $post_id, $task_id); |
|
1039 | - echo '</div>'; |
|
1040 | - } |
|
1041 | - |
|
1042 | - // Display comment form |
|
1043 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_comments_add')) { |
|
1044 | - Blog::display_new_comment_form($blog_id, $post_id, $blog_post['title']); |
|
1045 | - } |
|
1046 | - } |
|
1047 | - |
|
1048 | - /** |
|
1049 | - * Adds rating to a certain post or comment |
|
1050 | - * @author Toon Keppens |
|
1051 | - * |
|
1052 | - * @param String $type |
|
1053 | - * @param Integer $blog_id |
|
1054 | - * @param Integer $item_id |
|
1055 | - * @param Integer $rating |
|
1056 | - * |
|
1057 | - * @return Boolean success |
|
1058 | - */ |
|
1059 | - public static function add_rating($type, $blog_id, $item_id, $rating) |
|
1060 | - { |
|
1061 | - $_user = api_get_user_info(); |
|
1062 | - |
|
1063 | - // Init |
|
1064 | - $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
1065 | - $course_id = api_get_course_int_id(); |
|
1066 | - |
|
1067 | - // Check if the user has already rated this post/comment |
|
1068 | - $sql = "SELECT rating_id FROM $tbl_blogs_rating |
|
1029 | + echo '<span class="blogpost_info">'.get_lang('Author').': ' .Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)).' - '.get_lang('Comments').': '.$blog_post_comments['number_of_comments'].' - '.get_lang('Rating').': '.Blog::display_rating('post',$blog_id,$post_id).$rating_select.'</span>'; |
|
1030 | + echo '<span class="blogpost_actions">' . $blog_post_actions . '</span>'; |
|
1031 | + echo '</div>'; |
|
1032 | + |
|
1033 | + // Display comments if there are any |
|
1034 | + if($blog_post_comments['number_of_comments'] > 0) { |
|
1035 | + echo '<div class="comments">'; |
|
1036 | + echo '<span class="blogpost_title">' . get_lang('Comments') . '</span><br />'; |
|
1037 | + Blog::get_threaded_comments(0, 0, $blog_id, $post_id, $task_id); |
|
1038 | + echo '</div>'; |
|
1039 | + } |
|
1040 | + |
|
1041 | + // Display comment form |
|
1042 | + if (api_is_allowed('BLOG_' . $blog_id, 'article_comments_add')) { |
|
1043 | + Blog::display_new_comment_form($blog_id, $post_id, $blog_post['title']); |
|
1044 | + } |
|
1045 | + } |
|
1046 | + |
|
1047 | + /** |
|
1048 | + * Adds rating to a certain post or comment |
|
1049 | + * @author Toon Keppens |
|
1050 | + * |
|
1051 | + * @param String $type |
|
1052 | + * @param Integer $blog_id |
|
1053 | + * @param Integer $item_id |
|
1054 | + * @param Integer $rating |
|
1055 | + * |
|
1056 | + * @return Boolean success |
|
1057 | + */ |
|
1058 | + public static function add_rating($type, $blog_id, $item_id, $rating) |
|
1059 | + { |
|
1060 | + $_user = api_get_user_info(); |
|
1061 | + |
|
1062 | + // Init |
|
1063 | + $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
1064 | + $course_id = api_get_course_int_id(); |
|
1065 | + |
|
1066 | + // Check if the user has already rated this post/comment |
|
1067 | + $sql = "SELECT rating_id FROM $tbl_blogs_rating |
|
1069 | 1068 | WHERE |
1070 | 1069 | c_id = $course_id AND |
1071 | 1070 | blog_id = '".(int)$blog_id."' AND |
1072 | 1071 | item_id = '".(int)$item_id."' AND |
1073 | 1072 | rating_type = '".Database::escape_string($type)."' AND |
1074 | 1073 | user_id = '".(int)$_user['user_id']."'"; |
1075 | - $result = Database::query($sql); |
|
1074 | + $result = Database::query($sql); |
|
1076 | 1075 | |
1077 | 1076 | // Add rating |
1078 | - if (Database::num_rows($result) == 0) { |
|
1079 | - $sql = "INSERT INTO $tbl_blogs_rating (c_id, blog_id, rating_type, item_id, user_id, rating ) |
|
1077 | + if (Database::num_rows($result) == 0) { |
|
1078 | + $sql = "INSERT INTO $tbl_blogs_rating (c_id, blog_id, rating_type, item_id, user_id, rating ) |
|
1080 | 1079 | VALUES ($course_id, '".(int)$blog_id."', '".Database::escape_string($type)."', '".(int)$item_id."', '".(int)$_user['user_id']."', '".Database::escape_string($rating)."')"; |
1081 | - Database::query($sql); |
|
1080 | + Database::query($sql); |
|
1082 | 1081 | |
1083 | 1082 | $id = Database::insert_id(); |
1084 | 1083 | if ($id) { |
@@ -1086,103 +1085,103 @@ discard block |
||
1086 | 1085 | Database::query($sql); |
1087 | 1086 | } |
1088 | 1087 | |
1089 | - return true; |
|
1088 | + return true; |
|
1090 | 1089 | } else { |
1091 | - return false; |
|
1092 | - } |
|
1093 | - } |
|
1094 | - |
|
1095 | - /** |
|
1096 | - * Shows the rating of user |
|
1097 | - * @param String $type |
|
1098 | - * @param Integer $blog_id |
|
1099 | - * @param Integer $item_id |
|
1100 | - * @return array |
|
1101 | - */ |
|
1102 | - public static function display_rating($type, $blog_id, $item_id) |
|
1103 | - { |
|
1104 | - $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
1105 | - $course_id = api_get_course_int_id(); |
|
1106 | - |
|
1107 | - // Calculate rating |
|
1108 | - $sql = "SELECT AVG(rating) as rating FROM $tbl_blogs_rating |
|
1090 | + return false; |
|
1091 | + } |
|
1092 | + } |
|
1093 | + |
|
1094 | + /** |
|
1095 | + * Shows the rating of user |
|
1096 | + * @param String $type |
|
1097 | + * @param Integer $blog_id |
|
1098 | + * @param Integer $item_id |
|
1099 | + * @return array |
|
1100 | + */ |
|
1101 | + public static function display_rating($type, $blog_id, $item_id) |
|
1102 | + { |
|
1103 | + $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
1104 | + $course_id = api_get_course_int_id(); |
|
1105 | + |
|
1106 | + // Calculate rating |
|
1107 | + $sql = "SELECT AVG(rating) as rating FROM $tbl_blogs_rating |
|
1109 | 1108 | WHERE |
1110 | 1109 | c_id = $course_id AND |
1111 | 1110 | blog_id = '".(int)$blog_id."' AND |
1112 | 1111 | item_id = '".(int)$item_id."' AND |
1113 | 1112 | rating_type = '".Database::escape_string($type)."' "; |
1114 | - $result = Database::query($sql); |
|
1115 | - $result = Database::fetch_array($result); |
|
1116 | - return round($result['rating'], 2); |
|
1117 | - } |
|
1118 | - |
|
1119 | - /** |
|
1120 | - * Shows the rating form if not already rated by that user |
|
1121 | - * @author Toon Keppens |
|
1122 | - * |
|
1123 | - * @param String $type |
|
1124 | - * @param Integer $blog_id |
|
1125 | - * @param integer $post_id |
|
1126 | - */ |
|
1127 | - public static function display_rating_form ($type, $blog_id, $post_id, $comment_id = NULL) |
|
1128 | - { |
|
1129 | - $_user = api_get_user_info(); |
|
1130 | - $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
1113 | + $result = Database::query($sql); |
|
1114 | + $result = Database::fetch_array($result); |
|
1115 | + return round($result['rating'], 2); |
|
1116 | + } |
|
1117 | + |
|
1118 | + /** |
|
1119 | + * Shows the rating form if not already rated by that user |
|
1120 | + * @author Toon Keppens |
|
1121 | + * |
|
1122 | + * @param String $type |
|
1123 | + * @param Integer $blog_id |
|
1124 | + * @param integer $post_id |
|
1125 | + */ |
|
1126 | + public static function display_rating_form ($type, $blog_id, $post_id, $comment_id = NULL) |
|
1127 | + { |
|
1128 | + $_user = api_get_user_info(); |
|
1129 | + $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
1131 | 1130 | $course_id = api_get_course_int_id(); |
1132 | 1131 | |
1133 | 1132 | if ($type == 'post') { |
1134 | - // Check if the user has already rated this post |
|
1135 | - $sql = "SELECT rating_id FROM $tbl_blogs_rating |
|
1133 | + // Check if the user has already rated this post |
|
1134 | + $sql = "SELECT rating_id FROM $tbl_blogs_rating |
|
1136 | 1135 | WHERE c_id = $course_id AND |
1137 | 1136 | blog_id = '".(int)$blog_id."' |
1138 | 1137 | AND item_id = '".(int)$post_id."' |
1139 | 1138 | AND rating_type = '".Database::escape_string($type)."' |
1140 | 1139 | AND user_id = '".(int)$_user['user_id']."'"; |
1141 | - $result = Database::query($sql); |
|
1140 | + $result = Database::query($sql); |
|
1142 | 1141 | // Add rating |
1143 | 1142 | if (Database::num_rows($result) == 0) { |
1144 | - return ' - ' . get_lang('RateThis') . ': <form method="get" action="blog.php" style="display: inline" id="frm_rating_' . $type . '_' . $post_id . '" name="frm_rating_' . $type . '_' . $post_id . '"><select name="rating" onchange="document.forms[\'frm_rating_' . $type . '_' . $post_id . '\'].submit()"><option value="">-</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option></select><input type="hidden" name="action" value="view_post" /><input type="hidden" name="type" value="' . $type . '" /><input type="hidden" name="do" value="rate" /><input type="hidden" name="blog_id" value="' . $blog_id . '" /><input type="hidden" name="post_id" value="' . $post_id . '" /></form>'; |
|
1143 | + return ' - ' . get_lang('RateThis') . ': <form method="get" action="blog.php" style="display: inline" id="frm_rating_' . $type . '_' . $post_id . '" name="frm_rating_' . $type . '_' . $post_id . '"><select name="rating" onchange="document.forms[\'frm_rating_' . $type . '_' . $post_id . '\'].submit()"><option value="">-</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option></select><input type="hidden" name="action" value="view_post" /><input type="hidden" name="type" value="' . $type . '" /><input type="hidden" name="do" value="rate" /><input type="hidden" name="blog_id" value="' . $blog_id . '" /><input type="hidden" name="post_id" value="' . $post_id . '" /></form>'; |
|
1145 | 1144 | } else { |
1146 | - return ''; |
|
1147 | - } |
|
1148 | - } |
|
1145 | + return ''; |
|
1146 | + } |
|
1147 | + } |
|
1149 | 1148 | |
1150 | 1149 | if ($type = 'comment') { |
1151 | - // Check if the user has already rated this comment |
|
1152 | - $sql = "SELECT rating_id FROM $tbl_blogs_rating |
|
1150 | + // Check if the user has already rated this comment |
|
1151 | + $sql = "SELECT rating_id FROM $tbl_blogs_rating |
|
1153 | 1152 | WHERE c_id = $course_id AND blog_id = '".(int)$blog_id ."' |
1154 | 1153 | AND item_id = '".(int)$comment_id."' |
1155 | 1154 | AND rating_type = '".Database::escape_string($type)."' |
1156 | 1155 | AND user_id = '".(int)$_user['user_id']."'"; |
1157 | - $result = Database::query($sql); |
|
1156 | + $result = Database::query($sql); |
|
1158 | 1157 | |
1159 | 1158 | if (Database::num_rows($result) == 0) { |
1160 | - return ' - ' . get_lang('RateThis') . ': <form method="get" action="blog.php" style="display: inline" id="frm_rating_' . $type . '_' . $comment_id . '" name="frm_rating_' . $type . '_' . $comment_id . '"><select name="rating" onchange="document.forms[\'frm_rating_' . $type . '_' . $comment_id . '\'].submit()"><option value="">-</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option></select><input type="hidden" name="action" value="view_post" /><input type="hidden" name="type" value="' . $type . '" /><input type="hidden" name="do" value="rate" /><input type="hidden" name="blog_id" value="' . $blog_id . '" /><input type="hidden" name="post_id" value="' . $post_id . '" /><input type="hidden" name="comment_id" value="' . $comment_id . '" /></form>'; |
|
1159 | + return ' - ' . get_lang('RateThis') . ': <form method="get" action="blog.php" style="display: inline" id="frm_rating_' . $type . '_' . $comment_id . '" name="frm_rating_' . $type . '_' . $comment_id . '"><select name="rating" onchange="document.forms[\'frm_rating_' . $type . '_' . $comment_id . '\'].submit()"><option value="">-</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option></select><input type="hidden" name="action" value="view_post" /><input type="hidden" name="type" value="' . $type . '" /><input type="hidden" name="do" value="rate" /><input type="hidden" name="blog_id" value="' . $blog_id . '" /><input type="hidden" name="post_id" value="' . $post_id . '" /><input type="hidden" name="comment_id" value="' . $comment_id . '" /></form>'; |
|
1161 | 1160 | } else { |
1162 | - return ''; |
|
1163 | - } |
|
1164 | - } |
|
1165 | - } |
|
1166 | - |
|
1167 | - /** |
|
1168 | - * This functions gets all replys to a post, threaded. |
|
1169 | - * |
|
1170 | - * @param Integer $current |
|
1171 | - * @param Integer $current_level |
|
1172 | - * @param Integer $blog_id |
|
1173 | - * @param Integer $post_id |
|
1174 | - */ |
|
1175 | - public static function get_threaded_comments($current = 0, $current_level = 0, $blog_id, $post_id, $task_id = 0) |
|
1176 | - { |
|
1177 | - $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
1178 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
1179 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1180 | - global $charset; |
|
1181 | - |
|
1182 | - $course_id = api_get_course_int_id(); |
|
1183 | - |
|
1184 | - // Select top level comments |
|
1185 | - $next_level = $current_level + 1; |
|
1161 | + return ''; |
|
1162 | + } |
|
1163 | + } |
|
1164 | + } |
|
1165 | + |
|
1166 | + /** |
|
1167 | + * This functions gets all replys to a post, threaded. |
|
1168 | + * |
|
1169 | + * @param Integer $current |
|
1170 | + * @param Integer $current_level |
|
1171 | + * @param Integer $blog_id |
|
1172 | + * @param Integer $post_id |
|
1173 | + */ |
|
1174 | + public static function get_threaded_comments($current = 0, $current_level = 0, $blog_id, $post_id, $task_id = 0) |
|
1175 | + { |
|
1176 | + $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
1177 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
1178 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1179 | + global $charset; |
|
1180 | + |
|
1181 | + $course_id = api_get_course_int_id(); |
|
1182 | + |
|
1183 | + // Select top level comments |
|
1184 | + $next_level = $current_level + 1; |
|
1186 | 1185 | $sql = "SELECT comments.*, user.lastname, user.firstname, user.username, task.color |
1187 | 1186 | FROM $tbl_blogs_comments comments |
1188 | 1187 | INNER JOIN $tbl_users user |
@@ -1194,11 +1193,11 @@ discard block |
||
1194 | 1193 | parent_comment_id = $current AND |
1195 | 1194 | comments.blog_id = '".(int)$blog_id."' AND |
1196 | 1195 | comments.post_id = '".(int)$post_id."'"; |
1197 | - $result = Database::query($sql); |
|
1196 | + $result = Database::query($sql); |
|
1198 | 1197 | |
1199 | - while($comment = Database::fetch_array($result)) { |
|
1200 | - // Select the children recursivly |
|
1201 | - $tmp = "SELECT comments.*, user.lastname, user.firstname, user.username |
|
1198 | + while($comment = Database::fetch_array($result)) { |
|
1199 | + // Select the children recursivly |
|
1200 | + $tmp = "SELECT comments.*, user.lastname, user.firstname, user.username |
|
1202 | 1201 | FROM $tbl_blogs_comments comments |
1203 | 1202 | INNER JOIN $tbl_users user |
1204 | 1203 | ON comments.author_id = user.user_id |
@@ -1207,15 +1206,15 @@ discard block |
||
1207 | 1206 | comment_id = $current |
1208 | 1207 | AND blog_id = '".(int)$blog_id."' |
1209 | 1208 | AND post_id = '".(int)$post_id."'"; |
1210 | - $tmp = Database::query($tmp); |
|
1211 | - $tmp = Database::fetch_array($tmp); |
|
1212 | - $parent_cat = $tmp['parent_comment_id']; |
|
1213 | - $border_color = ''; |
|
1214 | - |
|
1215 | - // Prepare data |
|
1216 | - $comment_text = make_clickable(stripslashes($comment['comment'])); |
|
1217 | - $blog_comment_date = api_convert_and_format_date($comment['date_creation'], null, date_default_timezone_get()); |
|
1218 | - $blog_comment_actions = ""; |
|
1209 | + $tmp = Database::query($tmp); |
|
1210 | + $tmp = Database::fetch_array($tmp); |
|
1211 | + $parent_cat = $tmp['parent_comment_id']; |
|
1212 | + $border_color = ''; |
|
1213 | + |
|
1214 | + // Prepare data |
|
1215 | + $comment_text = make_clickable(stripslashes($comment['comment'])); |
|
1216 | + $blog_comment_date = api_convert_and_format_date($comment['date_creation'], null, date_default_timezone_get()); |
|
1217 | + $blog_comment_actions = ""; |
|
1219 | 1218 | if (api_is_allowed('BLOG_'.$blog_id, 'article_comments_delete', $task_id)) { |
1220 | 1219 | $blog_comment_actions .= '<a href="blog.php?action=view_post&blog_id='.$blog_id.'&post_id='.$post_id.'&do=delete_comment&comment_id='.$comment['comment_id'].'&task_id='.$task_id.'" title="'.get_lang( |
1221 | 1220 | 'DeleteThisComment' |
@@ -1230,167 +1229,167 @@ discard block |
||
1230 | 1229 | $rating_select = Blog::display_rating_form('comment', $blog_id, $post_id, $comment['comment_id']); |
1231 | 1230 | } |
1232 | 1231 | |
1233 | - if (!is_null($comment['task_id'])) { |
|
1234 | - $border_color = ' border-left: 3px solid #' . $comment['color']; |
|
1235 | - } |
|
1236 | - |
|
1237 | - $comment_text = stripslashes($comment_text); |
|
1238 | - |
|
1239 | - // Output... |
|
1240 | - $margin = $current_level * 30; |
|
1241 | - echo '<div class="blogpost_comment" style="margin-left: ' . $margin . 'px;' . $border_color . '">'; |
|
1242 | - echo '<span class="blogpost_comment_title"><a href="#add_comment" onclick="document.getElementById(\'comment_parent_id\').value=\'' . $comment['comment_id'] . '\'; document.getElementById(\'comment_title\').value=\'Re: '.addslashes($comment['title']) . '\'" title="' . get_lang('ReplyToThisComment') . '" >'.stripslashes($comment['title']) . '</a></span>'; |
|
1243 | - echo '<span class="blogpost_comment_date">' . $blog_comment_date . '</span>'; |
|
1244 | - echo '<span class="blogpost_text">' . $comment_text . '</span>'; |
|
1245 | - |
|
1246 | - $file_name_array = get_blog_attachment($blog_id,$post_id, $comment['comment_id']); |
|
1247 | - if (!empty($file_name_array)) { |
|
1248 | - echo '<br /><br />'; |
|
1249 | - echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
1250 | - echo '<a href="download.php?file='; |
|
1251 | - echo $file_name_array['path']; |
|
1252 | - echo ' "> '.$file_name_array['filename'].' </a>'; |
|
1253 | - echo '<span class="attachment_comment">'; |
|
1254 | - echo $file_name_array['comment']; |
|
1255 | - echo '</span><br />'; |
|
1256 | - } |
|
1257 | - $username = api_htmlentities(sprintf(get_lang('LoginX'), $comment['username']), ENT_QUOTES); |
|
1258 | - echo '<span class="blogpost_comment_info">'.get_lang('Author').': '.Display::tag('span', api_get_person_name($comment['firstname'], $comment['lastname']), array('title'=>$username)).' - '.get_lang('Rating').': '.Blog::display_rating('comment', $blog_id, $comment['comment_id']).$rating_select.'</span>'; |
|
1259 | - echo '<span class="blogpost_actions">' . $blog_comment_actions . '</span>'; |
|
1260 | - echo '</div>'; |
|
1261 | - |
|
1262 | - // Go further down the tree. |
|
1263 | - Blog::get_threaded_comments($comment['comment_id'], $next_level, $blog_id, $post_id); |
|
1264 | - } |
|
1265 | - } |
|
1266 | - |
|
1267 | - /** |
|
1268 | - * Displays the form to create a new post |
|
1269 | - * @author Toon Keppens |
|
1270 | - * |
|
1271 | - * @param Integer $blog_id |
|
1272 | - */ |
|
1273 | - public static function display_form_new_post($blog_id) |
|
1274 | - { |
|
1275 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) { |
|
1276 | - $form = new FormValidator( |
|
1277 | - 'add_post', |
|
1278 | - 'post', |
|
1279 | - api_get_path(WEB_CODE_PATH)."blog/blog.php?action=new_post&blog_id=" . $blog_id . "&" . api_get_cidreq(), |
|
1280 | - null, |
|
1281 | - array('enctype' => 'multipart/form-data') |
|
1282 | - ); |
|
1283 | - $form->addHidden('post_title_edited', 'false'); |
|
1284 | - $form->addHeader(get_lang('NewPost')); |
|
1285 | - $form->addText('title', get_lang('Title')); |
|
1286 | - $config = array(); |
|
1287 | - if (!api_is_allowed_to_edit()) { |
|
1288 | - $config['ToolbarSet'] = 'ProjectStudent'; |
|
1289 | - } else { |
|
1290 | - $config['ToolbarSet'] = 'Project'; |
|
1291 | - } |
|
1292 | - $form->addHtmlEditor('full_text', get_lang('Content'), false, false, $config); |
|
1293 | - $form->addFile('user_upload', get_lang('AddAnAttachment')); |
|
1294 | - $form->addTextarea('post_file_comment', get_lang('FileComment')); |
|
1295 | - $form->addHidden('new_post_submit', 'true'); |
|
1296 | - $form->addButton('save', get_lang('Save')); |
|
1297 | - |
|
1298 | - $form->display(); |
|
1299 | - } else { |
|
1300 | - api_not_allowed(); |
|
1301 | - } |
|
1302 | - } |
|
1303 | - |
|
1304 | - /** |
|
1305 | - * Displays the form to edit a post |
|
1306 | - * @author Toon Keppens |
|
1307 | - * |
|
1308 | - * @param Integer $blog_id |
|
1309 | - */ |
|
1310 | - public static function display_form_edit_post($blog_id, $post_id) |
|
1311 | - { |
|
1312 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
1313 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
1314 | - |
|
1315 | - $course_id = api_get_course_int_id(); |
|
1316 | - |
|
1317 | - // Get posts and author |
|
1318 | - $sql = "SELECT post.*, user.lastname, user.firstname |
|
1319 | - FROM $tbl_blogs_posts post |
|
1320 | - INNER JOIN $tbl_users user ON post.author_id = user.user_id |
|
1321 | - WHERE |
|
1322 | - post.c_id = $course_id AND |
|
1323 | - post.blog_id = '".(int)$blog_id ."' |
|
1324 | - AND post.post_id = '".(int)$post_id."' |
|
1325 | - ORDER BY post_id DESC"; |
|
1326 | - $result = Database::query($sql); |
|
1327 | - $blog_post = Database::fetch_array($result); |
|
1328 | - |
|
1329 | - // Form |
|
1330 | - $form = new FormValidator( |
|
1331 | - 'edit_post', |
|
1332 | - 'post', |
|
1333 | - api_get_path(WEB_CODE_PATH).'blog/blog.php?action=edit_post&post_id=' . intval($_GET['post_id']) . '&blog_id=' . intval($blog_id) . '&article_id='.intval($_GET['article_id']).'&task_id='.intval($_GET['task_id']) |
|
1334 | - ); |
|
1335 | - |
|
1336 | - $form->addHeader(get_lang('EditPost')); |
|
1337 | - $form->addText('title', get_lang('Title')); |
|
1338 | - |
|
1339 | - if (!api_is_allowed_to_edit()) { |
|
1340 | - $config['ToolbarSet'] = 'ProjectStudent'; |
|
1341 | - } else { |
|
1342 | - $config['ToolbarSet'] = 'Project'; |
|
1343 | - } |
|
1344 | - $form->addHtmlEditor('full_text', get_lang('Content'), false, false, $config); |
|
1345 | - |
|
1346 | - $form->addHidden('action', ''); |
|
1347 | - $form->addHidden('edit_post_submit', 'true'); |
|
1348 | - $form->addHidden('post_id', intval($_GET['post_id'])); |
|
1349 | - $form->addButton('save', get_lang('Save')); |
|
1350 | - $form->setDefaults($blog_post); |
|
1351 | - $form->display(); |
|
1352 | - } |
|
1353 | - |
|
1354 | - /** |
|
1355 | - * Displays a list of tasks in this blog |
|
1356 | - * @author Toon Keppens |
|
1357 | - * |
|
1358 | - * @param Integer $blog_id |
|
1359 | - */ |
|
1360 | - public static function display_task_list($blog_id) |
|
1232 | + if (!is_null($comment['task_id'])) { |
|
1233 | + $border_color = ' border-left: 3px solid #' . $comment['color']; |
|
1234 | + } |
|
1235 | + |
|
1236 | + $comment_text = stripslashes($comment_text); |
|
1237 | + |
|
1238 | + // Output... |
|
1239 | + $margin = $current_level * 30; |
|
1240 | + echo '<div class="blogpost_comment" style="margin-left: ' . $margin . 'px;' . $border_color . '">'; |
|
1241 | + echo '<span class="blogpost_comment_title"><a href="#add_comment" onclick="document.getElementById(\'comment_parent_id\').value=\'' . $comment['comment_id'] . '\'; document.getElementById(\'comment_title\').value=\'Re: '.addslashes($comment['title']) . '\'" title="' . get_lang('ReplyToThisComment') . '" >'.stripslashes($comment['title']) . '</a></span>'; |
|
1242 | + echo '<span class="blogpost_comment_date">' . $blog_comment_date . '</span>'; |
|
1243 | + echo '<span class="blogpost_text">' . $comment_text . '</span>'; |
|
1244 | + |
|
1245 | + $file_name_array = get_blog_attachment($blog_id,$post_id, $comment['comment_id']); |
|
1246 | + if (!empty($file_name_array)) { |
|
1247 | + echo '<br /><br />'; |
|
1248 | + echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
1249 | + echo '<a href="download.php?file='; |
|
1250 | + echo $file_name_array['path']; |
|
1251 | + echo ' "> '.$file_name_array['filename'].' </a>'; |
|
1252 | + echo '<span class="attachment_comment">'; |
|
1253 | + echo $file_name_array['comment']; |
|
1254 | + echo '</span><br />'; |
|
1255 | + } |
|
1256 | + $username = api_htmlentities(sprintf(get_lang('LoginX'), $comment['username']), ENT_QUOTES); |
|
1257 | + echo '<span class="blogpost_comment_info">'.get_lang('Author').': '.Display::tag('span', api_get_person_name($comment['firstname'], $comment['lastname']), array('title'=>$username)).' - '.get_lang('Rating').': '.Blog::display_rating('comment', $blog_id, $comment['comment_id']).$rating_select.'</span>'; |
|
1258 | + echo '<span class="blogpost_actions">' . $blog_comment_actions . '</span>'; |
|
1259 | + echo '</div>'; |
|
1260 | + |
|
1261 | + // Go further down the tree. |
|
1262 | + Blog::get_threaded_comments($comment['comment_id'], $next_level, $blog_id, $post_id); |
|
1263 | + } |
|
1264 | + } |
|
1265 | + |
|
1266 | + /** |
|
1267 | + * Displays the form to create a new post |
|
1268 | + * @author Toon Keppens |
|
1269 | + * |
|
1270 | + * @param Integer $blog_id |
|
1271 | + */ |
|
1272 | + public static function display_form_new_post($blog_id) |
|
1273 | + { |
|
1274 | + if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) { |
|
1275 | + $form = new FormValidator( |
|
1276 | + 'add_post', |
|
1277 | + 'post', |
|
1278 | + api_get_path(WEB_CODE_PATH)."blog/blog.php?action=new_post&blog_id=" . $blog_id . "&" . api_get_cidreq(), |
|
1279 | + null, |
|
1280 | + array('enctype' => 'multipart/form-data') |
|
1281 | + ); |
|
1282 | + $form->addHidden('post_title_edited', 'false'); |
|
1283 | + $form->addHeader(get_lang('NewPost')); |
|
1284 | + $form->addText('title', get_lang('Title')); |
|
1285 | + $config = array(); |
|
1286 | + if (!api_is_allowed_to_edit()) { |
|
1287 | + $config['ToolbarSet'] = 'ProjectStudent'; |
|
1288 | + } else { |
|
1289 | + $config['ToolbarSet'] = 'Project'; |
|
1290 | + } |
|
1291 | + $form->addHtmlEditor('full_text', get_lang('Content'), false, false, $config); |
|
1292 | + $form->addFile('user_upload', get_lang('AddAnAttachment')); |
|
1293 | + $form->addTextarea('post_file_comment', get_lang('FileComment')); |
|
1294 | + $form->addHidden('new_post_submit', 'true'); |
|
1295 | + $form->addButton('save', get_lang('Save')); |
|
1296 | + |
|
1297 | + $form->display(); |
|
1298 | + } else { |
|
1299 | + api_not_allowed(); |
|
1300 | + } |
|
1301 | + } |
|
1302 | + |
|
1303 | + /** |
|
1304 | + * Displays the form to edit a post |
|
1305 | + * @author Toon Keppens |
|
1306 | + * |
|
1307 | + * @param Integer $blog_id |
|
1308 | + */ |
|
1309 | + public static function display_form_edit_post($blog_id, $post_id) |
|
1310 | + { |
|
1311 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
1312 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
1313 | + |
|
1314 | + $course_id = api_get_course_int_id(); |
|
1315 | + |
|
1316 | + // Get posts and author |
|
1317 | + $sql = "SELECT post.*, user.lastname, user.firstname |
|
1318 | + FROM $tbl_blogs_posts post |
|
1319 | + INNER JOIN $tbl_users user ON post.author_id = user.user_id |
|
1320 | + WHERE |
|
1321 | + post.c_id = $course_id AND |
|
1322 | + post.blog_id = '".(int)$blog_id ."' |
|
1323 | + AND post.post_id = '".(int)$post_id."' |
|
1324 | + ORDER BY post_id DESC"; |
|
1325 | + $result = Database::query($sql); |
|
1326 | + $blog_post = Database::fetch_array($result); |
|
1327 | + |
|
1328 | + // Form |
|
1329 | + $form = new FormValidator( |
|
1330 | + 'edit_post', |
|
1331 | + 'post', |
|
1332 | + api_get_path(WEB_CODE_PATH).'blog/blog.php?action=edit_post&post_id=' . intval($_GET['post_id']) . '&blog_id=' . intval($blog_id) . '&article_id='.intval($_GET['article_id']).'&task_id='.intval($_GET['task_id']) |
|
1333 | + ); |
|
1334 | + |
|
1335 | + $form->addHeader(get_lang('EditPost')); |
|
1336 | + $form->addText('title', get_lang('Title')); |
|
1337 | + |
|
1338 | + if (!api_is_allowed_to_edit()) { |
|
1339 | + $config['ToolbarSet'] = 'ProjectStudent'; |
|
1340 | + } else { |
|
1341 | + $config['ToolbarSet'] = 'Project'; |
|
1342 | + } |
|
1343 | + $form->addHtmlEditor('full_text', get_lang('Content'), false, false, $config); |
|
1344 | + |
|
1345 | + $form->addHidden('action', ''); |
|
1346 | + $form->addHidden('edit_post_submit', 'true'); |
|
1347 | + $form->addHidden('post_id', intval($_GET['post_id'])); |
|
1348 | + $form->addButton('save', get_lang('Save')); |
|
1349 | + $form->setDefaults($blog_post); |
|
1350 | + $form->display(); |
|
1351 | + } |
|
1352 | + |
|
1353 | + /** |
|
1354 | + * Displays a list of tasks in this blog |
|
1355 | + * @author Toon Keppens |
|
1356 | + * |
|
1357 | + * @param Integer $blog_id |
|
1358 | + */ |
|
1359 | + public static function display_task_list($blog_id) |
|
1361 | 1360 | { |
1362 | - global $charset; |
|
1361 | + global $charset; |
|
1363 | 1362 | $course_id = api_get_course_int_id(); |
1364 | 1363 | |
1365 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) { |
|
1366 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1367 | - $counter = 0; |
|
1368 | - global $color2; |
|
1364 | + if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) { |
|
1365 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1366 | + $counter = 0; |
|
1367 | + global $color2; |
|
1369 | 1368 | |
1370 | - echo '<div class="actions">'; |
|
1371 | - echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=add">'; |
|
1369 | + echo '<div class="actions">'; |
|
1370 | + echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=add">'; |
|
1372 | 1371 | echo Display::return_icon('blog_newtasks.gif', get_lang('AddTasks')); |
1373 | 1372 | echo get_lang('AddTasks') . '</a> '; |
1374 | - echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=assign">'; |
|
1373 | + echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=assign">'; |
|
1375 | 1374 | echo Display::return_icon('blog_task.gif', get_lang('AssignTasks')); |
1376 | 1375 | echo get_lang('AssignTasks') . '</a>'; |
1377 | - ?> |
|
1376 | + ?> |
|
1378 | 1377 | <a href="<?php echo api_get_self(); ?>?action=manage_rights&blog_id=<?php echo $blog_id ?>" title="<?php echo get_lang('ManageRights') ?>"> |
1379 | 1378 | <?php echo Display::return_icon('blog_admin_users.png', get_lang('RightsManager'),'',ICON_SIZE_SMALL). get_lang('RightsManager') ?></a> |
1380 | 1379 | <?php |
1381 | - echo '</div>'; |
|
1380 | + echo '</div>'; |
|
1382 | 1381 | |
1383 | - echo '<span class="blogpost_title">' . get_lang('TaskList') . '</span><br />'; |
|
1384 | - echo "<table class=\"data_table\">"; |
|
1385 | - echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">", |
|
1386 | - "<th width='240'><b>",get_lang('Title'),"</b></th>", |
|
1387 | - "<th><b>",get_lang('Description'),"</b></th>", |
|
1388 | - "<th><b>",get_lang('Color'),"</b></th>", |
|
1389 | - "<th width='50'><b>",get_lang('Modify'),"</b></th>", |
|
1390 | - "</tr>"; |
|
1382 | + echo '<span class="blogpost_title">' . get_lang('TaskList') . '</span><br />'; |
|
1383 | + echo "<table class=\"data_table\">"; |
|
1384 | + echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">", |
|
1385 | + "<th width='240'><b>",get_lang('Title'),"</b></th>", |
|
1386 | + "<th><b>",get_lang('Description'),"</b></th>", |
|
1387 | + "<th><b>",get_lang('Color'),"</b></th>", |
|
1388 | + "<th width='50'><b>",get_lang('Modify'),"</b></th>", |
|
1389 | + "</tr>"; |
|
1391 | 1390 | |
1392 | 1391 | |
1393 | - $sql = " SELECT |
|
1392 | + $sql = " SELECT |
|
1394 | 1393 | blog_id, |
1395 | 1394 | task_id, |
1396 | 1395 | blog_id, |
@@ -1401,64 +1400,64 @@ discard block |
||
1401 | 1400 | FROM " . $tbl_blogs_tasks . " |
1402 | 1401 | WHERE c_id = $course_id AND blog_id = " . (int)$blog_id . " |
1403 | 1402 | ORDER BY system_task, title"; |
1404 | - $result = Database::query($sql); |
|
1403 | + $result = Database::query($sql); |
|
1405 | 1404 | |
1406 | - while ($task = Database::fetch_array($result)) { |
|
1407 | - $counter++; |
|
1408 | - $css_class = (($counter % 2) == 0) ? "row_odd" : "row_even"; |
|
1409 | - $delete_icon = ($task['system_task'] == '1') ? "delete_na.png" : "delete.png"; |
|
1410 | - $delete_title = ($task['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask'); |
|
1411 | - $delete_link = ($task['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=delete&task_id=' . $task['task_id']; |
|
1412 | - $delete_confirm = ($task['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"'; |
|
1405 | + while ($task = Database::fetch_array($result)) { |
|
1406 | + $counter++; |
|
1407 | + $css_class = (($counter % 2) == 0) ? "row_odd" : "row_even"; |
|
1408 | + $delete_icon = ($task['system_task'] == '1') ? "delete_na.png" : "delete.png"; |
|
1409 | + $delete_title = ($task['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask'); |
|
1410 | + $delete_link = ($task['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=delete&task_id=' . $task['task_id']; |
|
1411 | + $delete_confirm = ($task['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"'; |
|
1413 | 1412 | |
1414 | - echo '<tr class="' . $css_class . '" valign="top">'; |
|
1413 | + echo '<tr class="' . $css_class . '" valign="top">'; |
|
1415 | 1414 | echo '<td width="240">'.Security::remove_XSS($task['title']).'</td>'; |
1416 | 1415 | echo '<td>'.Security::remove_XSS($task['description']).'</td>'; |
1417 | 1416 | echo '<td><span style="background-color: #'.$task['color'].'"> </span></td>'; |
1418 | 1417 | echo '<td width="50">'; |
1419 | 1418 | echo '<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$task['blog_id'].'&do=edit&task_id='.$task['task_id'].'">'; |
1420 | 1419 | echo Display::return_icon('edit.png', get_lang('EditTask')); |
1421 | - echo "</a>"; |
|
1422 | - echo '<a href="'.$delete_link.'"'; |
|
1423 | - echo $delete_confirm; |
|
1424 | - echo '>'; |
|
1420 | + echo "</a>"; |
|
1421 | + echo '<a href="'.$delete_link.'"'; |
|
1422 | + echo $delete_confirm; |
|
1423 | + echo '>'; |
|
1425 | 1424 | echo Display::return_icon($delete_icon, $delete_title); |
1426 | - echo "</a>"; |
|
1427 | - echo '</td>'; |
|
1428 | - echo '</tr>'; |
|
1429 | - } |
|
1430 | - echo "</table>"; |
|
1431 | - } |
|
1432 | - } |
|
1433 | - |
|
1434 | - /** |
|
1435 | - * Displays a list of tasks assigned to a user in this blog |
|
1436 | - * @author Toon Keppens |
|
1437 | - * |
|
1438 | - * @param Integer $blog_id |
|
1439 | - */ |
|
1440 | - public static function display_assigned_task_list ($blog_id) |
|
1425 | + echo "</a>"; |
|
1426 | + echo '</td>'; |
|
1427 | + echo '</tr>'; |
|
1428 | + } |
|
1429 | + echo "</table>"; |
|
1430 | + } |
|
1431 | + } |
|
1432 | + |
|
1433 | + /** |
|
1434 | + * Displays a list of tasks assigned to a user in this blog |
|
1435 | + * @author Toon Keppens |
|
1436 | + * |
|
1437 | + * @param Integer $blog_id |
|
1438 | + */ |
|
1439 | + public static function display_assigned_task_list ($blog_id) |
|
1441 | 1440 | { |
1442 | - // Init |
|
1443 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
1444 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1445 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
1446 | - $counter = 0; |
|
1447 | - global $charset,$color2; |
|
1448 | - |
|
1449 | - echo '<span class="blogpost_title">' . get_lang('AssignedTasks') . '</span><br />'; |
|
1450 | - echo "<table class=\"data_table\">"; |
|
1451 | - echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">", |
|
1452 | - "<th width='240'><b>",get_lang('Member'),"</b></th>", |
|
1453 | - "<th><b>",get_lang('Task'),"</b></th>", |
|
1454 | - "<th><b>",get_lang('Description'),"</b></th>", |
|
1455 | - "<th><b>",get_lang('TargetDate'),"</b></th>", |
|
1456 | - "<th width='50'><b>",get_lang('Modify'),"</b></th>", |
|
1457 | - "</tr>"; |
|
1458 | - |
|
1459 | - $course_id = api_get_course_int_id(); |
|
1460 | - |
|
1461 | - $sql = "SELECT task_rel_user.*, task.title, user.firstname, user.lastname, user.username, task.description, task.system_task, task.blog_id, task.task_id |
|
1441 | + // Init |
|
1442 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
1443 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1444 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
1445 | + $counter = 0; |
|
1446 | + global $charset,$color2; |
|
1447 | + |
|
1448 | + echo '<span class="blogpost_title">' . get_lang('AssignedTasks') . '</span><br />'; |
|
1449 | + echo "<table class=\"data_table\">"; |
|
1450 | + echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">", |
|
1451 | + "<th width='240'><b>",get_lang('Member'),"</b></th>", |
|
1452 | + "<th><b>",get_lang('Task'),"</b></th>", |
|
1453 | + "<th><b>",get_lang('Description'),"</b></th>", |
|
1454 | + "<th><b>",get_lang('TargetDate'),"</b></th>", |
|
1455 | + "<th width='50'><b>",get_lang('Modify'),"</b></th>", |
|
1456 | + "</tr>"; |
|
1457 | + |
|
1458 | + $course_id = api_get_course_int_id(); |
|
1459 | + |
|
1460 | + $sql = "SELECT task_rel_user.*, task.title, user.firstname, user.lastname, user.username, task.description, task.system_task, task.blog_id, task.task_id |
|
1462 | 1461 | FROM $tbl_blogs_tasks_rel_user task_rel_user |
1463 | 1462 | INNER JOIN $tbl_blogs_tasks task ON task_rel_user.task_id = task.task_id |
1464 | 1463 | INNER JOIN $tbl_users user ON task_rel_user.user_id = user.user_id |
@@ -1467,15 +1466,15 @@ discard block |
||
1467 | 1466 | task.c_id = $course_id AND |
1468 | 1467 | task_rel_user.blog_id = '".(int)$blog_id."' |
1469 | 1468 | ORDER BY target_date ASC"; |
1470 | - $result = Database::query($sql); |
|
1469 | + $result = Database::query($sql); |
|
1471 | 1470 | |
1472 | - while ($assignment = Database::fetch_array($result)) { |
|
1473 | - $counter++; |
|
1474 | - $css_class = (($counter % 2)==0) ? "row_odd" : "row_even"; |
|
1475 | - $delete_icon = ($assignment['system_task'] == '1') ? "delete_na.png" : "delete.png"; |
|
1476 | - $delete_title = ($assignment['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask'); |
|
1477 | - $delete_link = ($assignment['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete&task_id=' . $assignment['task_id']; |
|
1478 | - $delete_confirm = ($assignment['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"'; |
|
1471 | + while ($assignment = Database::fetch_array($result)) { |
|
1472 | + $counter++; |
|
1473 | + $css_class = (($counter % 2)==0) ? "row_odd" : "row_even"; |
|
1474 | + $delete_icon = ($assignment['system_task'] == '1') ? "delete_na.png" : "delete.png"; |
|
1475 | + $delete_title = ($assignment['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask'); |
|
1476 | + $delete_link = ($assignment['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete&task_id=' . $assignment['task_id']; |
|
1477 | + $delete_confirm = ($assignment['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"'; |
|
1479 | 1478 | |
1480 | 1479 | $username = api_htmlentities(sprintf(get_lang('LoginX'), $assignment['username']), ENT_QUOTES); |
1481 | 1480 | |
@@ -1490,26 +1489,26 @@ discard block |
||
1490 | 1489 | echo '<td>'.$assignment['target_date'].'</td>'; |
1491 | 1490 | echo '<td width="50">'; |
1492 | 1491 | echo '<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$assignment['blog_id'].'&do=edit_assignment&task_id='.$assignment['task_id'].'&user_id='.$assignment['user_id'].'">'; |
1493 | - echo Display::return_icon('edit.png', get_lang('EditTask')); |
|
1494 | - echo "</a>"; |
|
1495 | - echo '<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$assignment['blog_id'].'&do=delete_assignment&task_id='.$assignment['task_id'].'&user_id='.$assignment['user_id'].'" '; |
|
1496 | - echo 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)).'\')) return false;"'; |
|
1492 | + echo Display::return_icon('edit.png', get_lang('EditTask')); |
|
1493 | + echo "</a>"; |
|
1494 | + echo '<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$assignment['blog_id'].'&do=delete_assignment&task_id='.$assignment['task_id'].'&user_id='.$assignment['user_id'].'" '; |
|
1495 | + echo 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)).'\')) return false;"'; |
|
1497 | 1496 | echo Display::return_icon($delete_icon, $delete_title); |
1498 | - echo "</a>"; |
|
1499 | - echo '</td>'; |
|
1500 | - echo '</tr>'; |
|
1501 | - } |
|
1502 | - echo "</table>"; |
|
1503 | - } |
|
1504 | - |
|
1505 | - /** |
|
1506 | - * Displays new task form |
|
1507 | - * @author Toon Keppens |
|
1508 | - * |
|
1509 | - */ |
|
1510 | - public static function display_new_task_form ($blog_id) |
|
1511 | - { |
|
1512 | - // Init |
|
1497 | + echo "</a>"; |
|
1498 | + echo '</td>'; |
|
1499 | + echo '</tr>'; |
|
1500 | + } |
|
1501 | + echo "</table>"; |
|
1502 | + } |
|
1503 | + |
|
1504 | + /** |
|
1505 | + * Displays new task form |
|
1506 | + * @author Toon Keppens |
|
1507 | + * |
|
1508 | + */ |
|
1509 | + public static function display_new_task_form ($blog_id) |
|
1510 | + { |
|
1511 | + // Init |
|
1513 | 1512 | $colors = array( |
1514 | 1513 | 'FFFFFF', |
1515 | 1514 | 'FFFF99', |
@@ -1528,14 +1527,14 @@ discard block |
||
1528 | 1527 | '000000' |
1529 | 1528 | ); |
1530 | 1529 | |
1531 | - // form |
|
1532 | - echo '<form name="add_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '">'; |
|
1530 | + // form |
|
1531 | + echo '<form name="add_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '">'; |
|
1533 | 1532 | |
1534 | - // form title |
|
1535 | - echo '<legend>'.get_lang('AddTask').'</legend>'; |
|
1533 | + // form title |
|
1534 | + echo '<legend>'.get_lang('AddTask').'</legend>'; |
|
1536 | 1535 | |
1537 | - // task title |
|
1538 | - echo ' <div class="control-group"> |
|
1536 | + // task title |
|
1537 | + echo ' <div class="control-group"> |
|
1539 | 1538 | <label class="control-label"> |
1540 | 1539 | <span class="form_required">*</span>' . get_lang('Title') . ' |
1541 | 1540 | </label> |
@@ -1544,8 +1543,8 @@ discard block |
||
1544 | 1543 | </div> |
1545 | 1544 | </div>'; |
1546 | 1545 | |
1547 | - // task comment |
|
1548 | - echo ' <div class="control-group"> |
|
1546 | + // task comment |
|
1547 | + echo ' <div class="control-group"> |
|
1549 | 1548 | <label class="control-label"> |
1550 | 1549 | ' . get_lang('Description') . ' |
1551 | 1550 | </label> |
@@ -1554,8 +1553,8 @@ discard block |
||
1554 | 1553 | </div> |
1555 | 1554 | </div>'; |
1556 | 1555 | |
1557 | - // task management |
|
1558 | - echo ' <div class="control-group"> |
|
1556 | + // task management |
|
1557 | + echo ' <div class="control-group"> |
|
1559 | 1558 | <label class="control-label"> |
1560 | 1559 | ' . get_lang('TaskManager') . ' |
1561 | 1560 | </label> |
@@ -1576,12 +1575,12 @@ discard block |
||
1576 | 1575 | echo '<td style="border:1px dotted #808080; text-align:center;"><input id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>'; |
1577 | 1576 | echo '</tr>'; |
1578 | 1577 | echo '</table>'; |
1579 | - echo ' </div> |
|
1578 | + echo ' </div> |
|
1580 | 1579 | </div>'; |
1581 | 1580 | |
1582 | 1581 | |
1583 | - // task color |
|
1584 | - echo ' <div class="control-group"> |
|
1582 | + // task color |
|
1583 | + echo ' <div class="control-group"> |
|
1585 | 1584 | <label class="control-label"> |
1586 | 1585 | ' . get_lang('Color') . ' |
1587 | 1586 | </label> |
@@ -1592,40 +1591,40 @@ discard block |
||
1592 | 1591 | echo '<option value="' . $color . '" ' . $style . '> </option>'; |
1593 | 1592 | } |
1594 | 1593 | echo '</select>'; |
1595 | - echo ' </div> |
|
1594 | + echo ' </div> |
|
1596 | 1595 | </div>'; |
1597 | 1596 | |
1598 | - // submit |
|
1599 | - echo ' <div class="control-group"> |
|
1597 | + // submit |
|
1598 | + echo ' <div class="control-group"> |
|
1600 | 1599 | <div class="controls"> |
1601 | 1600 | <input type="hidden" name="action" value="" /> |
1602 | 1601 | <input type="hidden" name="new_task_submit" value="true" /> |
1603 | 1602 | <button class="save" type="submit" name="Submit">' . get_lang('Save') . '</button> |
1604 | 1603 | </div> |
1605 | 1604 | </div>'; |
1606 | - echo '</form>'; |
|
1605 | + echo '</form>'; |
|
1607 | 1606 | |
1608 | - echo '<div style="clear:both; margin-bottom: 10px;"></div>'; |
|
1609 | - } |
|
1607 | + echo '<div style="clear:both; margin-bottom: 10px;"></div>'; |
|
1608 | + } |
|
1610 | 1609 | |
1611 | 1610 | |
1612 | - /** |
|
1613 | - * Displays edit task form |
|
1614 | - * @author Toon Keppens |
|
1615 | - * |
|
1616 | - */ |
|
1617 | - public static function display_edit_task_form ($blog_id, $task_id) { |
|
1618 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1611 | + /** |
|
1612 | + * Displays edit task form |
|
1613 | + * @author Toon Keppens |
|
1614 | + * |
|
1615 | + */ |
|
1616 | + public static function display_edit_task_form ($blog_id, $task_id) { |
|
1617 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1619 | 1618 | $course_id = api_get_course_int_id(); |
1620 | 1619 | |
1621 | - $colors = array('FFFFFF','FFFF99','FFCC99','FF9933','FF6699','CCFF99','CC9966','66FF00', '9966FF', 'CF3F3F', '990033','669933','0033FF','003366','000000'); |
|
1620 | + $colors = array('FFFFFF','FFFF99','FFCC99','FF9933','FF6699','CCFF99','CC9966','66FF00', '9966FF', 'CF3F3F', '990033','669933','0033FF','003366','000000'); |
|
1622 | 1621 | |
1623 | - $sql = "SELECT blog_id, task_id, title, description, color FROM $tbl_blogs_tasks WHERE c_id = $course_id AND task_id = '".(int)$task_id."'"; |
|
1624 | - $result = Database::query($sql); |
|
1625 | - $task = Database::fetch_array($result); |
|
1622 | + $sql = "SELECT blog_id, task_id, title, description, color FROM $tbl_blogs_tasks WHERE c_id = $course_id AND task_id = '".(int)$task_id."'"; |
|
1623 | + $result = Database::query($sql); |
|
1624 | + $task = Database::fetch_array($result); |
|
1626 | 1625 | |
1627 | - // Display |
|
1628 | - echo '<form name="edit_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '"> |
|
1626 | + // Display |
|
1627 | + echo '<form name="edit_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '"> |
|
1629 | 1628 | <legend>' . get_lang('EditTask') . '</legend> |
1630 | 1629 | <table width="100%" border="0" cellspacing="2"> |
1631 | 1630 | <tr> |
@@ -1637,42 +1636,42 @@ discard block |
||
1637 | 1636 | <td><textarea name="task_description" cols="45">'.Security::remove_XSS($task['description']).'</textarea></td> |
1638 | 1637 | </tr>'; |
1639 | 1638 | |
1640 | - /* edit by Kevin Van Den Haute ([email protected]) */ |
|
1641 | - $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
1639 | + /* edit by Kevin Van Den Haute ([email protected]) */ |
|
1640 | + $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
1642 | 1641 | |
1643 | - $sql = " SELECT id, action FROM " . $tbl_tasks_permissions . " |
|
1642 | + $sql = " SELECT id, action FROM " . $tbl_tasks_permissions . " |
|
1644 | 1643 | WHERE c_id = $course_id AND task_id = '" . (int)$task_id."'"; |
1645 | - $result = Database::query($sql); |
|
1646 | - |
|
1647 | - $arrPermissions = array(); |
|
1648 | - |
|
1649 | - while ($row = Database::fetch_array($result)) |
|
1650 | - $arrPermissions[] = $row['action']; |
|
1651 | - |
|
1652 | - echo '<tr>'; |
|
1653 | - echo '<td style="text-align:right; vertical-align:top;">' . get_lang('TaskManager') . ': </td>'; |
|
1654 | - echo '<td>'; |
|
1655 | - echo '<table class="data_table" cellspacing="0" style="border-collapse:collapse; width:446px;">'; |
|
1656 | - echo '<tr>'; |
|
1657 | - echo '<th colspan="2" style="width:223px;">' . get_lang('ArticleManager') . '</th>'; |
|
1658 | - echo '<th width:223px;>' . get_lang('CommentManager') . '</th>'; |
|
1659 | - echo '</tr>'; |
|
1660 | - echo '<tr>'; |
|
1661 | - echo '<th style="width:111px;"><label for="articleDelete">' . get_lang('Delete') . '</label></th>'; |
|
1662 | - echo '<th style="width:112px;"><label for="articleEdit">' . get_lang('Edit') . '</label></th>'; |
|
1663 | - echo '<th style="width:223px;"><label for="commentsDelete">' . get_lang('Delete') . '</label></th>'; |
|
1664 | - echo '</tr>'; |
|
1665 | - echo '<tr>'; |
|
1666 | - echo '<td style="text-align:center;"><input ' . ((in_array('article_delete', $arrPermissions)) ? 'checked ' : '') . 'id="articleDelete" name="chkArticleDelete" type="checkbox" /></td>'; |
|
1667 | - echo '<td style="text-align:center;"><input ' . ((in_array('article_edit', $arrPermissions)) ? 'checked ' : '') . 'id="articleEdit" name="chkArticleEdit" type="checkbox" /></td>'; |
|
1668 | - echo '<td style="text-align:center;"><input ' . ((in_array('article_comments_delete', $arrPermissions)) ? 'checked ' : '') . 'id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>'; |
|
1669 | - echo '</tr>'; |
|
1670 | - echo '</table>'; |
|
1671 | - echo '</td>'; |
|
1672 | - echo '</tr>'; |
|
1673 | - /* end of edit */ |
|
1674 | - |
|
1675 | - echo '<tr> |
|
1644 | + $result = Database::query($sql); |
|
1645 | + |
|
1646 | + $arrPermissions = array(); |
|
1647 | + |
|
1648 | + while ($row = Database::fetch_array($result)) |
|
1649 | + $arrPermissions[] = $row['action']; |
|
1650 | + |
|
1651 | + echo '<tr>'; |
|
1652 | + echo '<td style="text-align:right; vertical-align:top;">' . get_lang('TaskManager') . ': </td>'; |
|
1653 | + echo '<td>'; |
|
1654 | + echo '<table class="data_table" cellspacing="0" style="border-collapse:collapse; width:446px;">'; |
|
1655 | + echo '<tr>'; |
|
1656 | + echo '<th colspan="2" style="width:223px;">' . get_lang('ArticleManager') . '</th>'; |
|
1657 | + echo '<th width:223px;>' . get_lang('CommentManager') . '</th>'; |
|
1658 | + echo '</tr>'; |
|
1659 | + echo '<tr>'; |
|
1660 | + echo '<th style="width:111px;"><label for="articleDelete">' . get_lang('Delete') . '</label></th>'; |
|
1661 | + echo '<th style="width:112px;"><label for="articleEdit">' . get_lang('Edit') . '</label></th>'; |
|
1662 | + echo '<th style="width:223px;"><label for="commentsDelete">' . get_lang('Delete') . '</label></th>'; |
|
1663 | + echo '</tr>'; |
|
1664 | + echo '<tr>'; |
|
1665 | + echo '<td style="text-align:center;"><input ' . ((in_array('article_delete', $arrPermissions)) ? 'checked ' : '') . 'id="articleDelete" name="chkArticleDelete" type="checkbox" /></td>'; |
|
1666 | + echo '<td style="text-align:center;"><input ' . ((in_array('article_edit', $arrPermissions)) ? 'checked ' : '') . 'id="articleEdit" name="chkArticleEdit" type="checkbox" /></td>'; |
|
1667 | + echo '<td style="text-align:center;"><input ' . ((in_array('article_comments_delete', $arrPermissions)) ? 'checked ' : '') . 'id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>'; |
|
1668 | + echo '</tr>'; |
|
1669 | + echo '</table>'; |
|
1670 | + echo '</td>'; |
|
1671 | + echo '</tr>'; |
|
1672 | + /* end of edit */ |
|
1673 | + |
|
1674 | + echo '<tr> |
|
1676 | 1675 | <td align="right">' . get_lang('Color') . ': </td> |
1677 | 1676 | <td> |
1678 | 1677 | <select name="task_color" id="color" style="width: 150px; background-color: #' . $task['color'] . '" onchange="document.getElementById(\'color\').style.backgroundColor=\'#\'+document.getElementById(\'color\').value" onkeypress="document.getElementById(\'color\').style.backgroundColor=\'#\'+document.getElementById(\'color\').value">'; |
@@ -1681,7 +1680,7 @@ discard block |
||
1681 | 1680 | $style = 'style="background-color: #' . $color . '"'; |
1682 | 1681 | echo '<option value="' . $color . '" ' . $style . ' ' . $selected . ' > </option>'; |
1683 | 1682 | } |
1684 | - echo ' </select> |
|
1683 | + echo ' </select> |
|
1685 | 1684 | </td> |
1686 | 1685 | </tr> |
1687 | 1686 | <tr> |
@@ -1694,34 +1693,34 @@ discard block |
||
1694 | 1693 | </tr> |
1695 | 1694 | </table> |
1696 | 1695 | </form>'; |
1697 | - } |
|
1698 | - |
|
1699 | - /** |
|
1700 | - * @param $blog_id |
|
1701 | - * @return FormValidator |
|
1702 | - */ |
|
1703 | - public static function getTaskForm($blog_id) |
|
1704 | - { |
|
1705 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
1706 | - $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
1707 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1708 | - $course_id = api_get_course_int_id(); |
|
1709 | - |
|
1710 | - // Get users in this blog / make select list of it |
|
1711 | - $sql = "SELECT user.user_id, user.firstname, user.lastname, user.username |
|
1696 | + } |
|
1697 | + |
|
1698 | + /** |
|
1699 | + * @param $blog_id |
|
1700 | + * @return FormValidator |
|
1701 | + */ |
|
1702 | + public static function getTaskForm($blog_id) |
|
1703 | + { |
|
1704 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
1705 | + $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
1706 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1707 | + $course_id = api_get_course_int_id(); |
|
1708 | + |
|
1709 | + // Get users in this blog / make select list of it |
|
1710 | + $sql = "SELECT user.user_id, user.firstname, user.lastname, user.username |
|
1712 | 1711 | FROM $tbl_users user |
1713 | 1712 | INNER JOIN $tbl_blogs_rel_user blogs_rel_user |
1714 | 1713 | ON user.user_id = blogs_rel_user.user_id |
1715 | 1714 | WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".(int)$blog_id."'"; |
1716 | - $result = Database::query($sql); |
|
1715 | + $result = Database::query($sql); |
|
1717 | 1716 | |
1718 | - $options = array(); |
|
1719 | - while ($user = Database::fetch_array($result)) { |
|
1720 | - $options[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']); |
|
1721 | - } |
|
1717 | + $options = array(); |
|
1718 | + while ($user = Database::fetch_array($result)) { |
|
1719 | + $options[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']); |
|
1720 | + } |
|
1722 | 1721 | |
1723 | - // Get tasks in this blog / make select list of it |
|
1724 | - $sql = " |
|
1722 | + // Get tasks in this blog / make select list of it |
|
1723 | + $sql = " |
|
1725 | 1724 | SELECT |
1726 | 1725 | blog_id, |
1727 | 1726 | task_id, |
@@ -1733,97 +1732,97 @@ discard block |
||
1733 | 1732 | FROM $tbl_blogs_tasks |
1734 | 1733 | WHERE c_id = $course_id AND blog_id = " . (int)$blog_id . " |
1735 | 1734 | ORDER BY system_task, title"; |
1736 | - $result = Database::query($sql); |
|
1737 | - |
|
1738 | - $taskOptions = array(); |
|
1739 | - while ($task = Database::fetch_array($result)) { |
|
1740 | - $taskOptions[$task['task_id']] = stripslashes($task['title']); |
|
1741 | - } |
|
1742 | - |
|
1743 | - $form = new FormValidator( |
|
1744 | - 'assign_task', |
|
1745 | - 'post', |
|
1746 | - api_get_path( |
|
1747 | - WEB_CODE_PATH |
|
1748 | - ).'blog/blog.php?action=manage_tasks&blog_id='.$blog_id |
|
1749 | - ); |
|
1750 | - |
|
1751 | - $form->addHeader(get_lang('AssignTask')); |
|
1752 | - $form->addSelect('task_user_id', get_lang('SelectUser'), $options); |
|
1753 | - $form->addSelect('task_task_id', get_lang('SelectTask'), $taskOptions); |
|
1754 | - $form->addDatePicker('task_day', get_lang('SelectTargetDate')); |
|
1755 | - |
|
1756 | - $form->addHidden('action', ''); |
|
1757 | - $form->addButtonSave(get_lang('Ok')); |
|
1758 | - |
|
1759 | - return $form; |
|
1760 | - } |
|
1761 | - |
|
1762 | - /** |
|
1763 | - * Displays assign task form |
|
1764 | - * @author Toon Keppens |
|
1765 | - * |
|
1766 | - */ |
|
1767 | - public static function display_assign_task_form($blog_id) |
|
1768 | - { |
|
1769 | - $form = self::getTaskForm($blog_id); |
|
1770 | - $form->addHidden('assign_task_submit', 'true'); |
|
1771 | - $form->display(); |
|
1772 | - echo '<div style="clear: both; margin-bottom:10px;"></div>'; |
|
1773 | - } |
|
1774 | - |
|
1775 | - /** |
|
1776 | - * Displays assign task form |
|
1777 | - * @author Toon Keppens |
|
1778 | - * |
|
1779 | - */ |
|
1780 | - public static function display_edit_assigned_task_form($blog_id, $task_id, $user_id) |
|
1781 | - { |
|
1782 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
1783 | - |
|
1784 | - $course_id = api_get_course_int_id(); |
|
1785 | - |
|
1786 | - // Get assignd date; |
|
1787 | - $sql = " |
|
1735 | + $result = Database::query($sql); |
|
1736 | + |
|
1737 | + $taskOptions = array(); |
|
1738 | + while ($task = Database::fetch_array($result)) { |
|
1739 | + $taskOptions[$task['task_id']] = stripslashes($task['title']); |
|
1740 | + } |
|
1741 | + |
|
1742 | + $form = new FormValidator( |
|
1743 | + 'assign_task', |
|
1744 | + 'post', |
|
1745 | + api_get_path( |
|
1746 | + WEB_CODE_PATH |
|
1747 | + ).'blog/blog.php?action=manage_tasks&blog_id='.$blog_id |
|
1748 | + ); |
|
1749 | + |
|
1750 | + $form->addHeader(get_lang('AssignTask')); |
|
1751 | + $form->addSelect('task_user_id', get_lang('SelectUser'), $options); |
|
1752 | + $form->addSelect('task_task_id', get_lang('SelectTask'), $taskOptions); |
|
1753 | + $form->addDatePicker('task_day', get_lang('SelectTargetDate')); |
|
1754 | + |
|
1755 | + $form->addHidden('action', ''); |
|
1756 | + $form->addButtonSave(get_lang('Ok')); |
|
1757 | + |
|
1758 | + return $form; |
|
1759 | + } |
|
1760 | + |
|
1761 | + /** |
|
1762 | + * Displays assign task form |
|
1763 | + * @author Toon Keppens |
|
1764 | + * |
|
1765 | + */ |
|
1766 | + public static function display_assign_task_form($blog_id) |
|
1767 | + { |
|
1768 | + $form = self::getTaskForm($blog_id); |
|
1769 | + $form->addHidden('assign_task_submit', 'true'); |
|
1770 | + $form->display(); |
|
1771 | + echo '<div style="clear: both; margin-bottom:10px;"></div>'; |
|
1772 | + } |
|
1773 | + |
|
1774 | + /** |
|
1775 | + * Displays assign task form |
|
1776 | + * @author Toon Keppens |
|
1777 | + * |
|
1778 | + */ |
|
1779 | + public static function display_edit_assigned_task_form($blog_id, $task_id, $user_id) |
|
1780 | + { |
|
1781 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
1782 | + |
|
1783 | + $course_id = api_get_course_int_id(); |
|
1784 | + |
|
1785 | + // Get assignd date; |
|
1786 | + $sql = " |
|
1788 | 1787 | SELECT target_date |
1789 | 1788 | FROM $tbl_blogs_tasks_rel_user |
1790 | 1789 | WHERE c_id = $course_id AND |
1791 | 1790 | blog_id = '".(int)$blog_id."' AND |
1792 | 1791 | user_id = '".(int)$user_id."' AND |
1793 | 1792 | task_id = '".(int)$task_id."'"; |
1794 | - $result = Database::query($sql); |
|
1795 | - $row = Database::fetch_assoc($result); |
|
1796 | - |
|
1797 | - $date = $row['target_date']; |
|
1798 | - |
|
1799 | - $defaults = [ |
|
1800 | - 'task_user_id' => $user_id, |
|
1801 | - 'task_task_id' => $task_id, |
|
1802 | - 'task_day' => $date |
|
1803 | - ]; |
|
1804 | - $form = self::getTaskForm($blog_id); |
|
1805 | - $form->addHidden('old_task_id', $task_id); |
|
1806 | - $form->addHidden('old_user_id', $user_id); |
|
1807 | - $form->addHidden('old_target_date', $date); |
|
1808 | - $form->addHidden('assign_task_edit_submit', 'true'); |
|
1809 | - $form->setDefaults($defaults); |
|
1810 | - $form->display(); |
|
1811 | - } |
|
1812 | - |
|
1813 | - /** |
|
1814 | - * Assigns a task to a user in a blog |
|
1815 | - * |
|
1816 | - * @param Integer $blog_id |
|
1817 | - * @param Integer $user_id |
|
1818 | - * @param Integer $task_id |
|
1819 | - * @param Date $target_date |
|
1820 | - */ |
|
1821 | - public static function assign_task($blog_id, $user_id, $task_id, $target_date) |
|
1822 | - { |
|
1823 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
1824 | - $course_id = api_get_course_int_id(); |
|
1825 | - |
|
1826 | - $sql = " |
|
1793 | + $result = Database::query($sql); |
|
1794 | + $row = Database::fetch_assoc($result); |
|
1795 | + |
|
1796 | + $date = $row['target_date']; |
|
1797 | + |
|
1798 | + $defaults = [ |
|
1799 | + 'task_user_id' => $user_id, |
|
1800 | + 'task_task_id' => $task_id, |
|
1801 | + 'task_day' => $date |
|
1802 | + ]; |
|
1803 | + $form = self::getTaskForm($blog_id); |
|
1804 | + $form->addHidden('old_task_id', $task_id); |
|
1805 | + $form->addHidden('old_user_id', $user_id); |
|
1806 | + $form->addHidden('old_target_date', $date); |
|
1807 | + $form->addHidden('assign_task_edit_submit', 'true'); |
|
1808 | + $form->setDefaults($defaults); |
|
1809 | + $form->display(); |
|
1810 | + } |
|
1811 | + |
|
1812 | + /** |
|
1813 | + * Assigns a task to a user in a blog |
|
1814 | + * |
|
1815 | + * @param Integer $blog_id |
|
1816 | + * @param Integer $user_id |
|
1817 | + * @param Integer $task_id |
|
1818 | + * @param Date $target_date |
|
1819 | + */ |
|
1820 | + public static function assign_task($blog_id, $user_id, $task_id, $target_date) |
|
1821 | + { |
|
1822 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
1823 | + $course_id = api_get_course_int_id(); |
|
1824 | + |
|
1825 | + $sql = " |
|
1827 | 1826 | SELECT COUNT(*) as 'number' |
1828 | 1827 | FROM " . $tbl_blogs_tasks_rel_user . " |
1829 | 1828 | WHERE c_id = $course_id AND |
@@ -1832,11 +1831,11 @@ discard block |
||
1832 | 1831 | AND task_id = " . (int)$task_id . " |
1833 | 1832 | "; |
1834 | 1833 | |
1835 | - $result = Database::query($sql); |
|
1836 | - $row = Database::fetch_assoc($result); |
|
1834 | + $result = Database::query($sql); |
|
1835 | + $row = Database::fetch_assoc($result); |
|
1837 | 1836 | |
1838 | - if ($row['number'] == 0) { |
|
1839 | - $sql = " |
|
1837 | + if ($row['number'] == 0) { |
|
1838 | + $sql = " |
|
1840 | 1839 | INSERT INTO " . $tbl_blogs_tasks_rel_user . " ( |
1841 | 1840 | c_id, |
1842 | 1841 | blog_id, |
@@ -1851,9 +1850,9 @@ discard block |
||
1851 | 1850 | '" . Database::escape_string($target_date) . "' |
1852 | 1851 | )"; |
1853 | 1852 | |
1854 | - Database::query($sql); |
|
1855 | - } |
|
1856 | - } |
|
1853 | + Database::query($sql); |
|
1854 | + } |
|
1855 | + } |
|
1857 | 1856 | |
1858 | 1857 | /** |
1859 | 1858 | * @param $blog_id |
@@ -1873,11 +1872,11 @@ discard block |
||
1873 | 1872 | $old_task_id, |
1874 | 1873 | $old_target_date |
1875 | 1874 | ) { |
1876 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
1875 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
1877 | 1876 | |
1878 | - $course_id = api_get_course_int_id(); |
|
1877 | + $course_id = api_get_course_int_id(); |
|
1879 | 1878 | |
1880 | - $sql = "SELECT COUNT(*) as 'number' |
|
1879 | + $sql = "SELECT COUNT(*) as 'number' |
|
1881 | 1880 | FROM " . $tbl_blogs_tasks_rel_user . " |
1882 | 1881 | WHERE |
1883 | 1882 | c_id = $course_id AND |
@@ -1886,11 +1885,11 @@ discard block |
||
1886 | 1885 | task_id = " . (int)$task_id . " |
1887 | 1886 | "; |
1888 | 1887 | |
1889 | - $result = Database::query($sql); |
|
1890 | - $row = Database::fetch_assoc($result); |
|
1888 | + $result = Database::query($sql); |
|
1889 | + $row = Database::fetch_assoc($result); |
|
1891 | 1890 | |
1892 | - if ($row['number'] == 0 || ($row['number'] != 0 && $task_id == $old_task_id && $user_id == $old_user_id)) { |
|
1893 | - $sql = " |
|
1891 | + if ($row['number'] == 0 || ($row['number'] != 0 && $task_id == $old_task_id && $user_id == $old_user_id)) { |
|
1892 | + $sql = " |
|
1894 | 1893 | UPDATE " . $tbl_blogs_tasks_rel_user . " |
1895 | 1894 | SET |
1896 | 1895 | user_id = " . (int)$user_id . ", |
@@ -1903,76 +1902,76 @@ discard block |
||
1903 | 1902 | task_id = " . (int)$old_task_id . " AND |
1904 | 1903 | target_date = '" . Database::escape_string($old_target_date) . "' |
1905 | 1904 | "; |
1906 | - Database::query($sql); |
|
1907 | - } |
|
1908 | - } |
|
1909 | - |
|
1910 | - /** |
|
1911 | - * Displays a list with posts a user can select to execute his task. |
|
1912 | - * |
|
1913 | - * @param Integer $blog_id |
|
1914 | - * @param unknown_type $task_id |
|
1915 | - */ |
|
1916 | - public static function display_select_task_post($blog_id, $task_id) |
|
1905 | + Database::query($sql); |
|
1906 | + } |
|
1907 | + } |
|
1908 | + |
|
1909 | + /** |
|
1910 | + * Displays a list with posts a user can select to execute his task. |
|
1911 | + * |
|
1912 | + * @param Integer $blog_id |
|
1913 | + * @param unknown_type $task_id |
|
1914 | + */ |
|
1915 | + public static function display_select_task_post($blog_id, $task_id) |
|
1917 | 1916 | { |
1918 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1919 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
1920 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
1921 | - $course_id = api_get_course_int_id(); |
|
1917 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1918 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
1919 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
1920 | + $course_id = api_get_course_int_id(); |
|
1922 | 1921 | |
1923 | 1922 | |
1924 | - $sql = "SELECT title, description FROM $tbl_blogs_tasks |
|
1923 | + $sql = "SELECT title, description FROM $tbl_blogs_tasks |
|
1925 | 1924 | WHERE task_id = '".(int)$task_id."' |
1926 | 1925 | AND c_id = $course_id"; |
1927 | - $result = Database::query($sql); |
|
1928 | - $row = Database::fetch_assoc($result); |
|
1929 | - // Get posts and authors |
|
1930 | - $sql = "SELECT post.*, user.lastname, user.firstname, user.username |
|
1926 | + $result = Database::query($sql); |
|
1927 | + $row = Database::fetch_assoc($result); |
|
1928 | + // Get posts and authors |
|
1929 | + $sql = "SELECT post.*, user.lastname, user.firstname, user.username |
|
1931 | 1930 | FROM $tbl_blogs_posts post |
1932 | 1931 | INNER JOIN $tbl_users user ON post.author_id = user.user_id |
1933 | 1932 | WHERE post.blog_id = '".(int)$blog_id."' AND post.c_id = $course_id |
1934 | 1933 | ORDER BY post_id DESC |
1935 | 1934 | LIMIT 0, 100"; |
1936 | - $result = Database::query($sql); |
|
1935 | + $result = Database::query($sql); |
|
1937 | 1936 | |
1938 | - // Display |
|
1939 | - echo '<span class="blogpost_title">' . get_lang('SelectTaskArticle') . ' "' . stripslashes($row['title']) . '"</span>'; |
|
1940 | - echo '<span style="font-style: italic;"">'.stripslashes($row['description']) . '</span><br><br>'; |
|
1937 | + // Display |
|
1938 | + echo '<span class="blogpost_title">' . get_lang('SelectTaskArticle') . ' "' . stripslashes($row['title']) . '"</span>'; |
|
1939 | + echo '<span style="font-style: italic;"">'.stripslashes($row['description']) . '</span><br><br>'; |
|
1941 | 1940 | |
1942 | - if (Database::num_rows($result) > 0) { |
|
1943 | - while($blog_post = Database::fetch_array($result)) { |
|
1944 | - $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES); |
|
1945 | - echo '<a href="blog.php?action=execute_task&blog_id=' . $blog_id . '&task_id=' . $task_id . '&post_id=' . $blog_post['post_id'] . '#add_comment">'.stripslashes($blog_post['title']) . '</a>, ' . get_lang('WrittenBy') . ' ' . stripslashes(Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username))) . '<br />'; |
|
1946 | - } |
|
1941 | + if (Database::num_rows($result) > 0) { |
|
1942 | + while($blog_post = Database::fetch_array($result)) { |
|
1943 | + $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES); |
|
1944 | + echo '<a href="blog.php?action=execute_task&blog_id=' . $blog_id . '&task_id=' . $task_id . '&post_id=' . $blog_post['post_id'] . '#add_comment">'.stripslashes($blog_post['title']) . '</a>, ' . get_lang('WrittenBy') . ' ' . stripslashes(Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username))) . '<br />'; |
|
1945 | + } |
|
1947 | 1946 | } else { |
1948 | 1947 | echo get_lang('NoArticles'); |
1949 | 1948 | } |
1950 | - } |
|
1951 | - |
|
1952 | - /** |
|
1953 | - * Subscribes a user to a given blog |
|
1954 | - * @author Toon Keppens |
|
1955 | - * |
|
1956 | - * @param Integer $blog_id |
|
1957 | - * @param Integer $user_id |
|
1958 | - */ |
|
1959 | - public static function set_user_subscribed($blog_id, $user_id) |
|
1949 | + } |
|
1950 | + |
|
1951 | + /** |
|
1952 | + * Subscribes a user to a given blog |
|
1953 | + * @author Toon Keppens |
|
1954 | + * |
|
1955 | + * @param Integer $blog_id |
|
1956 | + * @param Integer $user_id |
|
1957 | + */ |
|
1958 | + public static function set_user_subscribed($blog_id, $user_id) |
|
1960 | 1959 | { |
1961 | - // Init |
|
1962 | - $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
1963 | - $tbl_user_permissions = Database::get_course_table(TABLE_PERMISSION_USER); |
|
1960 | + // Init |
|
1961 | + $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
1962 | + $tbl_user_permissions = Database::get_course_table(TABLE_PERMISSION_USER); |
|
1964 | 1963 | |
1965 | - $course_id = api_get_course_int_id(); |
|
1964 | + $course_id = api_get_course_int_id(); |
|
1966 | 1965 | |
1967 | - // Subscribe the user |
|
1968 | - $sql = "INSERT INTO $tbl_blogs_rel_user (c_id, blog_id, user_id ) |
|
1966 | + // Subscribe the user |
|
1967 | + $sql = "INSERT INTO $tbl_blogs_rel_user (c_id, blog_id, user_id ) |
|
1969 | 1968 | VALUES ($course_id, '".(int)$blog_id."', '".(int)$user_id."');"; |
1970 | - Database::query($sql); |
|
1969 | + Database::query($sql); |
|
1971 | 1970 | |
1972 | - // Give this user basic rights |
|
1973 | - $sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action) |
|
1971 | + // Give this user basic rights |
|
1972 | + $sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action) |
|
1974 | 1973 | VALUES ($course_id, '".(int)$user_id."','BLOG_" . (int)$blog_id."','article_add')"; |
1975 | - Database::query($sql); |
|
1974 | + Database::query($sql); |
|
1976 | 1975 | |
1977 | 1976 | $id = Database::insert_id(); |
1978 | 1977 | if ($id) { |
@@ -1980,9 +1979,9 @@ discard block |
||
1980 | 1979 | Database::query($sql); |
1981 | 1980 | } |
1982 | 1981 | |
1983 | - $sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action) |
|
1982 | + $sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action) |
|
1984 | 1983 | VALUES ($course_id, '".(int)$user_id."','BLOG_" . (int)$blog_id."','article_comments_add')"; |
1985 | - Database::query($sql); |
|
1984 | + Database::query($sql); |
|
1986 | 1985 | |
1987 | 1986 | $id = Database::insert_id(); |
1988 | 1987 | if ($id) { |
@@ -1990,197 +1989,197 @@ discard block |
||
1990 | 1989 | Database::query($sql); |
1991 | 1990 | } |
1992 | 1991 | |
1993 | - } |
|
1992 | + } |
|
1994 | 1993 | |
1995 | - /** |
|
1996 | - * Unsubscribe a user from a given blog |
|
1997 | - * @author Toon Keppens |
|
1998 | - * |
|
1999 | - * @param Integer $blog_id |
|
2000 | - * @param Integer $user_id |
|
2001 | - */ |
|
2002 | - public static function set_user_unsubscribed($blog_id, $user_id) |
|
1994 | + /** |
|
1995 | + * Unsubscribe a user from a given blog |
|
1996 | + * @author Toon Keppens |
|
1997 | + * |
|
1998 | + * @param Integer $blog_id |
|
1999 | + * @param Integer $user_id |
|
2000 | + */ |
|
2001 | + public static function set_user_unsubscribed($blog_id, $user_id) |
|
2003 | 2002 | { |
2004 | - // Init |
|
2003 | + // Init |
|
2005 | 2004 | $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
2006 | 2005 | $tbl_user_permissions = Database::get_course_table(TABLE_PERMISSION_USER); |
2007 | 2006 | |
2008 | - // Unsubscribe the user |
|
2009 | - $sql = "DELETE FROM $tbl_blogs_rel_user |
|
2007 | + // Unsubscribe the user |
|
2008 | + $sql = "DELETE FROM $tbl_blogs_rel_user |
|
2010 | 2009 | WHERE blog_id = '".(int)$blog_id."' AND user_id = '".(int)$user_id."'"; |
2011 | - Database::query($sql); |
|
2010 | + Database::query($sql); |
|
2012 | 2011 | |
2013 | - // Remove this user's permissions. |
|
2014 | - $sql = "DELETE FROM $tbl_user_permissions |
|
2012 | + // Remove this user's permissions. |
|
2013 | + $sql = "DELETE FROM $tbl_user_permissions |
|
2015 | 2014 | WHERE user_id = '".(int)$user_id."'"; |
2016 | - Database::query($sql); |
|
2017 | - } |
|
2018 | - |
|
2019 | - /** |
|
2020 | - * Displays the form to register users in a blog (in a course) |
|
2021 | - * The listed users are users subcribed in the course. |
|
2022 | - * @author Toon Keppens |
|
2023 | - * |
|
2024 | - * @param Integer $blog_id |
|
2025 | - * |
|
2026 | - * @return Html Form with sortable table with users to subcribe in a blog, in a course. |
|
2027 | - */ |
|
2028 | - public static function display_form_user_subscribe($blog_id) |
|
2029 | - { |
|
2030 | - $_course = api_get_course_info(); |
|
2031 | - $is_western_name_order = api_is_western_name_order(); |
|
2032 | - $session_id = api_get_session_id(); |
|
2033 | - $course_id = $_course['real_id']; |
|
2034 | - |
|
2035 | - $currentCourse = $_course['code']; |
|
2036 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
2037 | - $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
2038 | - |
|
2039 | - echo '<legend>'.get_lang('SubscribeMembers').'</legend>'; |
|
2040 | - |
|
2041 | - $properties["width"] = "100%"; |
|
2042 | - |
|
2043 | - // Get blog members' id. |
|
2044 | - $sql = "SELECT user.user_id FROM $tbl_users user |
|
2015 | + Database::query($sql); |
|
2016 | + } |
|
2017 | + |
|
2018 | + /** |
|
2019 | + * Displays the form to register users in a blog (in a course) |
|
2020 | + * The listed users are users subcribed in the course. |
|
2021 | + * @author Toon Keppens |
|
2022 | + * |
|
2023 | + * @param Integer $blog_id |
|
2024 | + * |
|
2025 | + * @return Html Form with sortable table with users to subcribe in a blog, in a course. |
|
2026 | + */ |
|
2027 | + public static function display_form_user_subscribe($blog_id) |
|
2028 | + { |
|
2029 | + $_course = api_get_course_info(); |
|
2030 | + $is_western_name_order = api_is_western_name_order(); |
|
2031 | + $session_id = api_get_session_id(); |
|
2032 | + $course_id = $_course['real_id']; |
|
2033 | + |
|
2034 | + $currentCourse = $_course['code']; |
|
2035 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
2036 | + $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
2037 | + |
|
2038 | + echo '<legend>'.get_lang('SubscribeMembers').'</legend>'; |
|
2039 | + |
|
2040 | + $properties["width"] = "100%"; |
|
2041 | + |
|
2042 | + // Get blog members' id. |
|
2043 | + $sql = "SELECT user.user_id FROM $tbl_users user |
|
2045 | 2044 | INNER JOIN $tbl_blogs_rel_user blogs_rel_user |
2046 | 2045 | ON user.user_id = blogs_rel_user.user_id |
2047 | 2046 | WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".intval($blog_id)."'"; |
2048 | - $result = Database::query($sql); |
|
2049 | - |
|
2050 | - $blog_member_ids = array(); |
|
2051 | - while($user = Database::fetch_array($result)) { |
|
2052 | - $blog_member_ids[] = $user['user_id']; |
|
2053 | - } |
|
2054 | - |
|
2055 | - // Set table headers |
|
2056 | - $column_header[] = array ('', false, ''); |
|
2057 | - if ($is_western_name_order) { |
|
2058 | - $column_header[] = array(get_lang('FirstName'), true, ''); |
|
2059 | - $column_header[] = array(get_lang('LastName'), true, ''); |
|
2060 | - } else { |
|
2061 | - $column_header[] = array(get_lang('LastName'), true, ''); |
|
2062 | - $column_header[] = array(get_lang('FirstName'), true, ''); |
|
2063 | - } |
|
2064 | - $column_header[] = array(get_lang('Email'), false, ''); |
|
2065 | - $column_header[] = array(get_lang('Register'), false, ''); |
|
2047 | + $result = Database::query($sql); |
|
2048 | + |
|
2049 | + $blog_member_ids = array(); |
|
2050 | + while($user = Database::fetch_array($result)) { |
|
2051 | + $blog_member_ids[] = $user['user_id']; |
|
2052 | + } |
|
2053 | + |
|
2054 | + // Set table headers |
|
2055 | + $column_header[] = array ('', false, ''); |
|
2056 | + if ($is_western_name_order) { |
|
2057 | + $column_header[] = array(get_lang('FirstName'), true, ''); |
|
2058 | + $column_header[] = array(get_lang('LastName'), true, ''); |
|
2059 | + } else { |
|
2060 | + $column_header[] = array(get_lang('LastName'), true, ''); |
|
2061 | + $column_header[] = array(get_lang('FirstName'), true, ''); |
|
2062 | + } |
|
2063 | + $column_header[] = array(get_lang('Email'), false, ''); |
|
2064 | + $column_header[] = array(get_lang('Register'), false, ''); |
|
2066 | 2065 | |
2067 | 2066 | $student_list = CourseManager:: get_student_list_from_course_code( |
2068 | 2067 | $currentCourse, |
2069 | 2068 | false, |
2070 | 2069 | $session_id |
2071 | 2070 | ); |
2072 | - $user_data = array(); |
|
2073 | - |
|
2074 | - // Add users that are not in this blog to the list. |
|
2075 | - foreach ($student_list as $key=>$user) { |
|
2076 | - if(isset($user['id_user'])) { |
|
2077 | - $user['user_id'] = $user['id_user']; |
|
2078 | - } |
|
2079 | - if(!in_array($user['user_id'],$blog_member_ids)) { |
|
2080 | - $a_infosUser = api_get_user_info($user['user_id']); |
|
2081 | - $row = array (); |
|
2082 | - $row[] = '<input type="checkbox" name="user[]" value="' . $a_infosUser['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "subscribe") ? ' checked="checked" ' : '') . '/>'; |
|
2083 | - $username = api_htmlentities(sprintf(get_lang('LoginX'), $a_infosUser["username"]), ENT_QUOTES); |
|
2084 | - if ($is_western_name_order) { |
|
2085 | - $row[] = $a_infosUser["firstname"]; |
|
2086 | - $row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username)); |
|
2087 | - } else { |
|
2088 | - $row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username)); |
|
2089 | - $row[] = $a_infosUser["firstname"]; |
|
2090 | - } |
|
2091 | - $row[] = Display::icon_mailto_link($a_infosUser["email"]); |
|
2092 | - |
|
2093 | - //Link to register users |
|
2094 | - if ($a_infosUser["user_id"] != $_SESSION['_user']['user_id']){ |
|
2095 | - $row[] = "<a class=\"btn btn-primary \" href=\"" .api_get_self()."?action=manage_members&blog_id=$blog_id®ister=yes&user_id=" . $a_infosUser["user_id"]."\">" . get_lang('Register')."</a>"; |
|
2096 | - } else { |
|
2097 | - $row[] = ''; |
|
2098 | - } |
|
2099 | - $user_data[] = $row; |
|
2100 | - } |
|
2101 | - } |
|
2102 | - |
|
2103 | - // Display |
|
2104 | - $query_vars['action'] = 'manage_members'; |
|
2105 | - $query_vars['blog_id'] = $blog_id; |
|
2106 | - echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">'; |
|
2107 | - Display::display_sortable_table($column_header, $user_data,null,null,$query_vars); |
|
2108 | - $link = ''; |
|
2109 | - $link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']) . '&' : ''; |
|
2110 | - $link .= "blog_id=$blog_id&"; |
|
2111 | - |
|
2112 | - echo '<a href="blog.php?' . $link . 'selectall=subscribe">' . get_lang('SelectAll') . '</a> - '; |
|
2113 | - echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> '; |
|
2114 | - echo get_lang('WithSelected') . ' : '; |
|
2115 | - echo '<select name="action">'; |
|
2116 | - echo '<option value="select_subscribe">' . get_lang('Register') . '</option>'; |
|
2117 | - echo '</select>'; |
|
2118 | - echo '<input type="hidden" name="register" value="true" />'; |
|
2119 | - echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>'; |
|
2120 | - echo '</form>'; |
|
2121 | - } |
|
2122 | - |
|
2123 | - /** |
|
2124 | - * Displays the form to register users in a blog (in a course) |
|
2125 | - * The listed users are users subcribed in the course. |
|
2126 | - * @author Toon Keppens |
|
2127 | - * |
|
2128 | - * @param Integer $blog_id |
|
2129 | - * |
|
2130 | - * @return false|null Form with sortable table with users to unsubcribe from a blog. |
|
2131 | - */ |
|
2132 | - public static function display_form_user_unsubscribe ($blog_id) |
|
2133 | - { |
|
2134 | - $_user = api_get_user_info(); |
|
2135 | - $is_western_name_order = api_is_western_name_order(); |
|
2136 | - |
|
2137 | - // Init |
|
2138 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
2139 | - $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
2140 | - |
|
2141 | - echo '<legend>'.get_lang('UnsubscribeMembers').'</legend>'; |
|
2142 | - |
|
2143 | - $properties["width"] = "100%"; |
|
2144 | - //table column titles |
|
2145 | - $column_header[] = array ('', false, ''); |
|
2146 | - if ($is_western_name_order) { |
|
2147 | - $column_header[] = array (get_lang('FirstName'), true, ''); |
|
2148 | - $column_header[] = array (get_lang('LastName'), true, ''); |
|
2149 | - } else { |
|
2150 | - $column_header[] = array (get_lang('LastName'), true, ''); |
|
2151 | - $column_header[] = array (get_lang('FirstName'), true, ''); |
|
2152 | - } |
|
2153 | - $column_header[] = array (get_lang('Email'), false, ''); |
|
2154 | - $column_header[] = array (get_lang('TaskManager'), true, ''); |
|
2155 | - $column_header[] = array (get_lang('UnRegister'), false, ''); |
|
2156 | - |
|
2157 | - $course_id = api_get_course_int_id(); |
|
2158 | - |
|
2159 | - $sql = "SELECT user.user_id, user.lastname, user.firstname, user.email, user.username |
|
2071 | + $user_data = array(); |
|
2072 | + |
|
2073 | + // Add users that are not in this blog to the list. |
|
2074 | + foreach ($student_list as $key=>$user) { |
|
2075 | + if(isset($user['id_user'])) { |
|
2076 | + $user['user_id'] = $user['id_user']; |
|
2077 | + } |
|
2078 | + if(!in_array($user['user_id'],$blog_member_ids)) { |
|
2079 | + $a_infosUser = api_get_user_info($user['user_id']); |
|
2080 | + $row = array (); |
|
2081 | + $row[] = '<input type="checkbox" name="user[]" value="' . $a_infosUser['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "subscribe") ? ' checked="checked" ' : '') . '/>'; |
|
2082 | + $username = api_htmlentities(sprintf(get_lang('LoginX'), $a_infosUser["username"]), ENT_QUOTES); |
|
2083 | + if ($is_western_name_order) { |
|
2084 | + $row[] = $a_infosUser["firstname"]; |
|
2085 | + $row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username)); |
|
2086 | + } else { |
|
2087 | + $row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username)); |
|
2088 | + $row[] = $a_infosUser["firstname"]; |
|
2089 | + } |
|
2090 | + $row[] = Display::icon_mailto_link($a_infosUser["email"]); |
|
2091 | + |
|
2092 | + //Link to register users |
|
2093 | + if ($a_infosUser["user_id"] != $_SESSION['_user']['user_id']){ |
|
2094 | + $row[] = "<a class=\"btn btn-primary \" href=\"" .api_get_self()."?action=manage_members&blog_id=$blog_id®ister=yes&user_id=" . $a_infosUser["user_id"]."\">" . get_lang('Register')."</a>"; |
|
2095 | + } else { |
|
2096 | + $row[] = ''; |
|
2097 | + } |
|
2098 | + $user_data[] = $row; |
|
2099 | + } |
|
2100 | + } |
|
2101 | + |
|
2102 | + // Display |
|
2103 | + $query_vars['action'] = 'manage_members'; |
|
2104 | + $query_vars['blog_id'] = $blog_id; |
|
2105 | + echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">'; |
|
2106 | + Display::display_sortable_table($column_header, $user_data,null,null,$query_vars); |
|
2107 | + $link = ''; |
|
2108 | + $link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']) . '&' : ''; |
|
2109 | + $link .= "blog_id=$blog_id&"; |
|
2110 | + |
|
2111 | + echo '<a href="blog.php?' . $link . 'selectall=subscribe">' . get_lang('SelectAll') . '</a> - '; |
|
2112 | + echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> '; |
|
2113 | + echo get_lang('WithSelected') . ' : '; |
|
2114 | + echo '<select name="action">'; |
|
2115 | + echo '<option value="select_subscribe">' . get_lang('Register') . '</option>'; |
|
2116 | + echo '</select>'; |
|
2117 | + echo '<input type="hidden" name="register" value="true" />'; |
|
2118 | + echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>'; |
|
2119 | + echo '</form>'; |
|
2120 | + } |
|
2121 | + |
|
2122 | + /** |
|
2123 | + * Displays the form to register users in a blog (in a course) |
|
2124 | + * The listed users are users subcribed in the course. |
|
2125 | + * @author Toon Keppens |
|
2126 | + * |
|
2127 | + * @param Integer $blog_id |
|
2128 | + * |
|
2129 | + * @return false|null Form with sortable table with users to unsubcribe from a blog. |
|
2130 | + */ |
|
2131 | + public static function display_form_user_unsubscribe ($blog_id) |
|
2132 | + { |
|
2133 | + $_user = api_get_user_info(); |
|
2134 | + $is_western_name_order = api_is_western_name_order(); |
|
2135 | + |
|
2136 | + // Init |
|
2137 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
2138 | + $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
2139 | + |
|
2140 | + echo '<legend>'.get_lang('UnsubscribeMembers').'</legend>'; |
|
2141 | + |
|
2142 | + $properties["width"] = "100%"; |
|
2143 | + //table column titles |
|
2144 | + $column_header[] = array ('', false, ''); |
|
2145 | + if ($is_western_name_order) { |
|
2146 | + $column_header[] = array (get_lang('FirstName'), true, ''); |
|
2147 | + $column_header[] = array (get_lang('LastName'), true, ''); |
|
2148 | + } else { |
|
2149 | + $column_header[] = array (get_lang('LastName'), true, ''); |
|
2150 | + $column_header[] = array (get_lang('FirstName'), true, ''); |
|
2151 | + } |
|
2152 | + $column_header[] = array (get_lang('Email'), false, ''); |
|
2153 | + $column_header[] = array (get_lang('TaskManager'), true, ''); |
|
2154 | + $column_header[] = array (get_lang('UnRegister'), false, ''); |
|
2155 | + |
|
2156 | + $course_id = api_get_course_int_id(); |
|
2157 | + |
|
2158 | + $sql = "SELECT user.user_id, user.lastname, user.firstname, user.email, user.username |
|
2160 | 2159 | FROM $tbl_users user INNER JOIN $tbl_blogs_rel_user blogs_rel_user |
2161 | 2160 | ON user.user_id = blogs_rel_user.user_id |
2162 | 2161 | WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".(int)$blog_id."'"; |
2163 | 2162 | |
2164 | - if (!($sql_result = Database::query($sql))) { |
|
2165 | - return false; |
|
2166 | - } |
|
2167 | - |
|
2168 | - $user_data = array (); |
|
2169 | - |
|
2170 | - while ($myrow = Database::fetch_array($sql_result)) { |
|
2171 | - $row = array (); |
|
2172 | - $row[] = '<input type="checkbox" name="user[]" value="' . $myrow['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "unsubscribe") ? ' checked="checked" ' : '') . '/>'; |
|
2173 | - $username = api_htmlentities(sprintf(get_lang('LoginX'), $myrow["username"]), ENT_QUOTES); |
|
2174 | - if ($is_western_name_order) { |
|
2175 | - $row[] = $myrow["firstname"]; |
|
2176 | - $row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username)); |
|
2177 | - } else { |
|
2178 | - $row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username)); |
|
2179 | - $row[] = $myrow["firstname"]; |
|
2180 | - } |
|
2181 | - $row[] = Display::icon_mailto_link($myrow["email"]); |
|
2182 | - |
|
2183 | - $sql = "SELECT bt.title task |
|
2163 | + if (!($sql_result = Database::query($sql))) { |
|
2164 | + return false; |
|
2165 | + } |
|
2166 | + |
|
2167 | + $user_data = array (); |
|
2168 | + |
|
2169 | + while ($myrow = Database::fetch_array($sql_result)) { |
|
2170 | + $row = array (); |
|
2171 | + $row[] = '<input type="checkbox" name="user[]" value="' . $myrow['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "unsubscribe") ? ' checked="checked" ' : '') . '/>'; |
|
2172 | + $username = api_htmlentities(sprintf(get_lang('LoginX'), $myrow["username"]), ENT_QUOTES); |
|
2173 | + if ($is_western_name_order) { |
|
2174 | + $row[] = $myrow["firstname"]; |
|
2175 | + $row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username)); |
|
2176 | + } else { |
|
2177 | + $row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username)); |
|
2178 | + $row[] = $myrow["firstname"]; |
|
2179 | + } |
|
2180 | + $row[] = Display::icon_mailto_link($myrow["email"]); |
|
2181 | + |
|
2182 | + $sql = "SELECT bt.title task |
|
2184 | 2183 | FROM " . Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER) . " btu |
2185 | 2184 | INNER JOIN " . Database::get_course_table(TABLE_BLOGS_TASKS) . " bt |
2186 | 2185 | ON btu.task_id = bt.task_id |
@@ -2188,157 +2187,157 @@ discard block |
||
2188 | 2187 | bt.c_id = $course_id AND |
2189 | 2188 | btu.blog_id = $blog_id AND |
2190 | 2189 | btu.user_id = " . $myrow['user_id']; |
2191 | - $sql_res = Database::query($sql); |
|
2192 | - |
|
2193 | - $task = ''; |
|
2194 | - |
|
2195 | - while($r = Database::fetch_array($sql_res)) { |
|
2196 | - $task .= stripslashes($r['task']) . ', '; |
|
2197 | - } |
|
2198 | - //echo $task; |
|
2199 | - $task = (api_strlen(trim($task)) != 0) ? api_substr($task, 0, api_strlen($task) - 2) : get_lang('Reader'); |
|
2200 | - $row[] = $task; |
|
2201 | - //Link to register users |
|
2202 | - |
|
2203 | - if ($myrow["user_id"] != $_user['user_id']) { |
|
2204 | - $row[] = "<a class=\"btn btn-primary\" href=\"" .api_get_self()."?action=manage_members&blog_id=$blog_id&unregister=yes&user_id=" . $myrow['user_id']."\">" . get_lang('UnRegister')."</a>"; |
|
2205 | - } else { |
|
2206 | - $row[] = ''; |
|
2207 | - } |
|
2208 | - |
|
2209 | - $user_data[] = $row; |
|
2210 | - } |
|
2211 | - |
|
2212 | - $query_vars['action'] = 'manage_members'; |
|
2213 | - $query_vars['blog_id'] = $blog_id; |
|
2214 | - echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">'; |
|
2215 | - Display::display_sortable_table($column_header, $user_data,null,null,$query_vars); |
|
2216 | - $link = ''; |
|
2217 | - $link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']). '&' : ''; |
|
2218 | - $link .= "blog_id=$blog_id&"; |
|
2219 | - |
|
2220 | - echo '<a href="blog.php?' . $link . 'selectall=unsubscribe">' . get_lang('SelectAll') . '</a> - '; |
|
2221 | - echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> '; |
|
2222 | - echo get_lang('WithSelected') . ' : '; |
|
2223 | - echo '<select name="action">'; |
|
2224 | - echo '<option value="select_unsubscribe">' . get_lang('UnRegister') . '</option>'; |
|
2225 | - echo '</select>'; |
|
2226 | - echo '<input type="hidden" name="unregister" value="true" />'; |
|
2227 | - echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>'; |
|
2228 | - echo '</form>'; |
|
2229 | - } |
|
2230 | - |
|
2231 | - /** |
|
2232 | - * Displays a matrix with selectboxes. On the left: users, on top: possible rights. |
|
2233 | - * The blog admin can thus select what a certain user can do in the current blog |
|
2234 | - * |
|
2235 | - * @param Integer $blog_id |
|
2236 | - */ |
|
2237 | - public static function display_form_user_rights ($blog_id) |
|
2190 | + $sql_res = Database::query($sql); |
|
2191 | + |
|
2192 | + $task = ''; |
|
2193 | + |
|
2194 | + while($r = Database::fetch_array($sql_res)) { |
|
2195 | + $task .= stripslashes($r['task']) . ', '; |
|
2196 | + } |
|
2197 | + //echo $task; |
|
2198 | + $task = (api_strlen(trim($task)) != 0) ? api_substr($task, 0, api_strlen($task) - 2) : get_lang('Reader'); |
|
2199 | + $row[] = $task; |
|
2200 | + //Link to register users |
|
2201 | + |
|
2202 | + if ($myrow["user_id"] != $_user['user_id']) { |
|
2203 | + $row[] = "<a class=\"btn btn-primary\" href=\"" .api_get_self()."?action=manage_members&blog_id=$blog_id&unregister=yes&user_id=" . $myrow['user_id']."\">" . get_lang('UnRegister')."</a>"; |
|
2204 | + } else { |
|
2205 | + $row[] = ''; |
|
2206 | + } |
|
2207 | + |
|
2208 | + $user_data[] = $row; |
|
2209 | + } |
|
2210 | + |
|
2211 | + $query_vars['action'] = 'manage_members'; |
|
2212 | + $query_vars['blog_id'] = $blog_id; |
|
2213 | + echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">'; |
|
2214 | + Display::display_sortable_table($column_header, $user_data,null,null,$query_vars); |
|
2215 | + $link = ''; |
|
2216 | + $link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']). '&' : ''; |
|
2217 | + $link .= "blog_id=$blog_id&"; |
|
2218 | + |
|
2219 | + echo '<a href="blog.php?' . $link . 'selectall=unsubscribe">' . get_lang('SelectAll') . '</a> - '; |
|
2220 | + echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> '; |
|
2221 | + echo get_lang('WithSelected') . ' : '; |
|
2222 | + echo '<select name="action">'; |
|
2223 | + echo '<option value="select_unsubscribe">' . get_lang('UnRegister') . '</option>'; |
|
2224 | + echo '</select>'; |
|
2225 | + echo '<input type="hidden" name="unregister" value="true" />'; |
|
2226 | + echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>'; |
|
2227 | + echo '</form>'; |
|
2228 | + } |
|
2229 | + |
|
2230 | + /** |
|
2231 | + * Displays a matrix with selectboxes. On the left: users, on top: possible rights. |
|
2232 | + * The blog admin can thus select what a certain user can do in the current blog |
|
2233 | + * |
|
2234 | + * @param Integer $blog_id |
|
2235 | + */ |
|
2236 | + public static function display_form_user_rights ($blog_id) |
|
2237 | + { |
|
2238 | + echo '<legend>'.get_lang('RightsManager').'</legend>'; |
|
2239 | + echo '<br />'; |
|
2240 | + |
|
2241 | + // Integration of patricks permissions system. |
|
2242 | + require_once api_get_path(SYS_CODE_PATH).'permissions/blog_permissions.inc.php'; |
|
2243 | + } |
|
2244 | + |
|
2245 | + /** |
|
2246 | + * Displays the form to create a new post |
|
2247 | + * @author Toon Keppens |
|
2248 | + * |
|
2249 | + * @param Integer $blog_id |
|
2250 | + * @param integer $post_id |
|
2251 | + */ |
|
2252 | + public static function display_new_comment_form($blog_id, $post_id, $title) |
|
2238 | 2253 | { |
2239 | - echo '<legend>'.get_lang('RightsManager').'</legend>'; |
|
2240 | - echo '<br />'; |
|
2241 | - |
|
2242 | - // Integration of patricks permissions system. |
|
2243 | - require_once api_get_path(SYS_CODE_PATH).'permissions/blog_permissions.inc.php'; |
|
2244 | - } |
|
2245 | - |
|
2246 | - /** |
|
2247 | - * Displays the form to create a new post |
|
2248 | - * @author Toon Keppens |
|
2249 | - * |
|
2250 | - * @param Integer $blog_id |
|
2251 | - * @param integer $post_id |
|
2252 | - */ |
|
2253 | - public static function display_new_comment_form($blog_id, $post_id, $title) |
|
2254 | - { |
|
2255 | - $form = new FormValidator( |
|
2256 | - 'add_post', |
|
2257 | - 'post', |
|
2258 | - api_get_path(WEB_CODE_PATH)."blog/blog.php?action=view_post&blog_id=" . intval($blog_id) . "&post_id=".intval($post_id)."&".api_get_cidreq(), |
|
2259 | - null, |
|
2260 | - array('enctype' => 'multipart/form-data') |
|
2261 | - ); |
|
2262 | - |
|
2263 | - $header = get_lang('AddNewComment'); |
|
2264 | - if (isset($_GET['task_id'])) { |
|
2265 | - $header = get_lang('ExecuteThisTask'); |
|
2266 | - } |
|
2267 | - $form->addHeader($header); |
|
2268 | - $form->addText('title', get_lang('Title')); |
|
2269 | - |
|
2270 | - $config = array(); |
|
2271 | - if (!api_is_allowed_to_edit()) { |
|
2272 | - $config['ToolbarSet'] = 'ProjectComment'; |
|
2273 | - } else { |
|
2274 | - $config['ToolbarSet'] = 'ProjectCommentStudent'; |
|
2275 | - } |
|
2276 | - $form->addHtmlEditor('comment', get_lang('Comment'), false, false, $config); |
|
2277 | - $form->addFile('user_upload', get_lang('AddAnAttachment')); |
|
2278 | - |
|
2279 | - $form->addTextarea('post_file_comment', get_lang('FileComment')); |
|
2280 | - |
|
2281 | - $form->addHidden('action', null); |
|
2282 | - $form->addHidden('comment_parent_id', 0); |
|
2283 | - |
|
2284 | - if (isset($_GET['task_id'])) { |
|
2285 | - $form->addHidden('new_task_execution_submit', 'true'); |
|
2286 | - $form->addHidden('task_id', intval($_GET['task_id'])); |
|
2287 | - } else { |
|
2288 | - $form->addHidden('new_comment_submit', 'true'); |
|
2289 | - } |
|
2290 | - $form->addButton('save', get_lang('Save')); |
|
2291 | - $form->display(); |
|
2292 | - } |
|
2293 | - |
|
2294 | - |
|
2295 | - /** |
|
2296 | - * show the calender of the given month |
|
2297 | - * @author Patrick Cool |
|
2298 | - * @author Toon Keppens |
|
2299 | - * |
|
2300 | - * @param Integer $month: the integer value of the month we are viewing |
|
2301 | - * @param Integer $year: the 4-digit year indication e.g. 2005 |
|
2302 | - * |
|
2303 | - * @return html code |
|
2304 | - */ |
|
2305 | - public static function display_minimonthcalendar($month, $year, $blog_id) |
|
2306 | - { |
|
2307 | - // Init |
|
2308 | - $_user = api_get_user_info(); |
|
2309 | - global $DaysShort; |
|
2310 | - global $MonthsLong; |
|
2311 | - |
|
2312 | - $posts = array(); |
|
2313 | - $tasks = array(); |
|
2314 | - |
|
2315 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
2316 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
2317 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
2318 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
2319 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
2320 | - |
|
2321 | - $course_id = api_get_course_int_id(); |
|
2322 | - |
|
2323 | - //Handle leap year |
|
2324 | - $numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); |
|
2325 | - |
|
2326 | - if(($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0)) |
|
2327 | - $numberofdays[2] = 29; |
|
2328 | - |
|
2329 | - //Get the first day of the month |
|
2330 | - $dayone = getdate(mktime(0, 0, 0, $month, 1, $year)); |
|
2331 | - $monthName = $MonthsLong[$month-1]; |
|
2332 | - |
|
2333 | - //Start the week on monday |
|
2334 | - $startdayofweek = $dayone['wday'] <> 0 ? ($dayone['wday'] - 1) : 6; |
|
2335 | - $blogId = isset($_GET['blog_id']) ? intval($_GET['blog_id']) : null; |
|
2336 | - $filter = isset($_GET['filter']) ? Security::remove_XSS($_GET['filter']) : null; |
|
2337 | - $backwardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 1 ? 12 : $month -1)."&year=". ($month == 1 ? $year -1 : $year); |
|
2338 | - $forewardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 12 ? 1 : $month +1)."&year=". ($month == 12 ? $year +1 : $year); |
|
2339 | - |
|
2340 | - // Get posts for this month |
|
2341 | - $sql = "SELECT post.*, DAYOFMONTH(date_creation) as post_day, user.lastname, user.firstname |
|
2254 | + $form = new FormValidator( |
|
2255 | + 'add_post', |
|
2256 | + 'post', |
|
2257 | + api_get_path(WEB_CODE_PATH)."blog/blog.php?action=view_post&blog_id=" . intval($blog_id) . "&post_id=".intval($post_id)."&".api_get_cidreq(), |
|
2258 | + null, |
|
2259 | + array('enctype' => 'multipart/form-data') |
|
2260 | + ); |
|
2261 | + |
|
2262 | + $header = get_lang('AddNewComment'); |
|
2263 | + if (isset($_GET['task_id'])) { |
|
2264 | + $header = get_lang('ExecuteThisTask'); |
|
2265 | + } |
|
2266 | + $form->addHeader($header); |
|
2267 | + $form->addText('title', get_lang('Title')); |
|
2268 | + |
|
2269 | + $config = array(); |
|
2270 | + if (!api_is_allowed_to_edit()) { |
|
2271 | + $config['ToolbarSet'] = 'ProjectComment'; |
|
2272 | + } else { |
|
2273 | + $config['ToolbarSet'] = 'ProjectCommentStudent'; |
|
2274 | + } |
|
2275 | + $form->addHtmlEditor('comment', get_lang('Comment'), false, false, $config); |
|
2276 | + $form->addFile('user_upload', get_lang('AddAnAttachment')); |
|
2277 | + |
|
2278 | + $form->addTextarea('post_file_comment', get_lang('FileComment')); |
|
2279 | + |
|
2280 | + $form->addHidden('action', null); |
|
2281 | + $form->addHidden('comment_parent_id', 0); |
|
2282 | + |
|
2283 | + if (isset($_GET['task_id'])) { |
|
2284 | + $form->addHidden('new_task_execution_submit', 'true'); |
|
2285 | + $form->addHidden('task_id', intval($_GET['task_id'])); |
|
2286 | + } else { |
|
2287 | + $form->addHidden('new_comment_submit', 'true'); |
|
2288 | + } |
|
2289 | + $form->addButton('save', get_lang('Save')); |
|
2290 | + $form->display(); |
|
2291 | + } |
|
2292 | + |
|
2293 | + |
|
2294 | + /** |
|
2295 | + * show the calender of the given month |
|
2296 | + * @author Patrick Cool |
|
2297 | + * @author Toon Keppens |
|
2298 | + * |
|
2299 | + * @param Integer $month: the integer value of the month we are viewing |
|
2300 | + * @param Integer $year: the 4-digit year indication e.g. 2005 |
|
2301 | + * |
|
2302 | + * @return html code |
|
2303 | + */ |
|
2304 | + public static function display_minimonthcalendar($month, $year, $blog_id) |
|
2305 | + { |
|
2306 | + // Init |
|
2307 | + $_user = api_get_user_info(); |
|
2308 | + global $DaysShort; |
|
2309 | + global $MonthsLong; |
|
2310 | + |
|
2311 | + $posts = array(); |
|
2312 | + $tasks = array(); |
|
2313 | + |
|
2314 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
2315 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
2316 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
2317 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
2318 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
2319 | + |
|
2320 | + $course_id = api_get_course_int_id(); |
|
2321 | + |
|
2322 | + //Handle leap year |
|
2323 | + $numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); |
|
2324 | + |
|
2325 | + if(($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0)) |
|
2326 | + $numberofdays[2] = 29; |
|
2327 | + |
|
2328 | + //Get the first day of the month |
|
2329 | + $dayone = getdate(mktime(0, 0, 0, $month, 1, $year)); |
|
2330 | + $monthName = $MonthsLong[$month-1]; |
|
2331 | + |
|
2332 | + //Start the week on monday |
|
2333 | + $startdayofweek = $dayone['wday'] <> 0 ? ($dayone['wday'] - 1) : 6; |
|
2334 | + $blogId = isset($_GET['blog_id']) ? intval($_GET['blog_id']) : null; |
|
2335 | + $filter = isset($_GET['filter']) ? Security::remove_XSS($_GET['filter']) : null; |
|
2336 | + $backwardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 1 ? 12 : $month -1)."&year=". ($month == 1 ? $year -1 : $year); |
|
2337 | + $forewardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 12 ? 1 : $month +1)."&year=". ($month == 12 ? $year +1 : $year); |
|
2338 | + |
|
2339 | + // Get posts for this month |
|
2340 | + $sql = "SELECT post.*, DAYOFMONTH(date_creation) as post_day, user.lastname, user.firstname |
|
2342 | 2341 | FROM $tbl_blogs_posts post |
2343 | 2342 | INNER JOIN $tbl_users user |
2344 | 2343 | ON post.author_id = user.user_id |
@@ -2348,20 +2347,20 @@ discard block |
||
2348 | 2347 | MONTH(date_creation) = '".(int)$month."' AND |
2349 | 2348 | YEAR(date_creation) = '".(int)$year."' |
2350 | 2349 | ORDER BY date_creation"; |
2351 | - $result = Database::query($sql); |
|
2352 | - |
|
2353 | - // We will create an array of days on which there are posts. |
|
2354 | - if( Database::num_rows($result) > 0) { |
|
2355 | - while($blog_post = Database::fetch_array($result)) { |
|
2356 | - // If the day of this post is not yet in the array, add it. |
|
2357 | - if (!in_array($blog_post['post_day'], $posts)) |
|
2358 | - $posts[] = $blog_post['post_day']; |
|
2359 | - } |
|
2360 | - } |
|
2361 | - |
|
2362 | - // Get tasks for this month |
|
2363 | - if ($_user['user_id']) { |
|
2364 | - $sql = " SELECT task_rel_user.*, DAYOFMONTH(target_date) as task_day, task.title, blog.blog_name |
|
2350 | + $result = Database::query($sql); |
|
2351 | + |
|
2352 | + // We will create an array of days on which there are posts. |
|
2353 | + if( Database::num_rows($result) > 0) { |
|
2354 | + while($blog_post = Database::fetch_array($result)) { |
|
2355 | + // If the day of this post is not yet in the array, add it. |
|
2356 | + if (!in_array($blog_post['post_day'], $posts)) |
|
2357 | + $posts[] = $blog_post['post_day']; |
|
2358 | + } |
|
2359 | + } |
|
2360 | + |
|
2361 | + // Get tasks for this month |
|
2362 | + if ($_user['user_id']) { |
|
2363 | + $sql = " SELECT task_rel_user.*, DAYOFMONTH(target_date) as task_day, task.title, blog.blog_name |
|
2365 | 2364 | FROM $tbl_blogs_tasks_rel_user task_rel_user |
2366 | 2365 | INNER JOIN $tbl_blogs_tasks task ON task_rel_user.task_id = task.task_id |
2367 | 2366 | INNER JOIN $tbl_blogs blog ON task_rel_user.blog_id = blog.blog_id |
@@ -2373,85 +2372,85 @@ discard block |
||
2373 | 2372 | MONTH(target_date) = '".(int)$month."' AND |
2374 | 2373 | YEAR(target_date) = '".(int)$year."' |
2375 | 2374 | ORDER BY target_date ASC"; |
2376 | - $result = Database::query($sql); |
|
2377 | - |
|
2378 | - if (Database::num_rows($result) > 0) { |
|
2379 | - while ($mytask = Database::fetch_array($result)) { |
|
2380 | - $tasks[$mytask['task_day']][$mytask['task_id']]['task_id'] = $mytask['task_id']; |
|
2381 | - $tasks[$mytask['task_day']][$mytask['task_id']]['title'] = $mytask['title']; |
|
2382 | - $tasks[$mytask['task_day']][$mytask['task_id']]['blog_id'] = $mytask['blog_id']; |
|
2383 | - $tasks[$mytask['task_day']][$mytask['task_id']]['blog_name'] = $mytask['blog_name']; |
|
2384 | - $tasks[$mytask['task_day']][$mytask['task_id']]['day'] = $mytask['task_day']; |
|
2385 | - } |
|
2386 | - } |
|
2387 | - } |
|
2388 | - |
|
2389 | - echo '<table id="smallcalendar" class="table table-responsive">', |
|
2390 | - "<tr id=\"title\">", |
|
2391 | - "<th width=\"10%\"><a href=\"", $backwardsURL, "\">«</a></th>", |
|
2392 | - "<th align=\"center\" width=\"80%\" colspan=\"5\">", $monthName, " ", $year, "</th>", |
|
2393 | - "<th width=\"10%\" align=\"right\"><a href=\"", $forewardsURL, "\">»</a></th>", "</tr>"; |
|
2394 | - |
|
2395 | - echo "<tr>"; |
|
2396 | - |
|
2397 | - for($ii = 1; $ii < 8; $ii ++) |
|
2398 | - echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>"; |
|
2399 | - |
|
2400 | - echo "</tr>"; |
|
2401 | - |
|
2402 | - $curday = -1; |
|
2403 | - $today = getdate(); |
|
2404 | - |
|
2405 | - while ($curday <= $numberofdays[$month]) { |
|
2406 | - echo "<tr>"; |
|
2407 | - for ($ii = 0; $ii < 7; $ii ++) { |
|
2408 | - if (($curday == -1) && ($ii == $startdayofweek)) |
|
2409 | - $curday = 1; |
|
2410 | - |
|
2411 | - if (($curday > 0) && ($curday <= $numberofdays[$month])) { |
|
2412 | - $bgcolor = $ii < 5 ? $class="class=\"days_week\"" : $class="class=\"days_weekend\""; |
|
2413 | - $dayheader = "$curday"; |
|
2414 | - |
|
2415 | - if(($curday == $today['mday']) && ($year == $today['year']) && ($month == $today['mon'])) { |
|
2416 | - $dayheader = "$curday"; |
|
2417 | - $class = "class=\"days_today\""; |
|
2418 | - } |
|
2419 | - |
|
2420 | - echo "<td " . $class.">"; |
|
2421 | - |
|
2422 | - // If there are posts on this day, create a filter link. |
|
2423 | - if(in_array($curday, $posts)) |
|
2424 | - echo '<a href="blog.php?blog_id=' . $blog_id . '&filter=' . $year . '-' . $month . '-' . $curday . '&month=' . $month . '&year=' . $year . '" title="' . get_lang('ViewPostsOfThisDay') . '">' . $curday . '</a>'; |
|
2425 | - else |
|
2426 | - echo $dayheader; |
|
2427 | - |
|
2428 | - if (count($tasks) > 0) { |
|
2429 | - if (isset($tasks[$curday]) && is_array($tasks[$curday])) { |
|
2430 | - // Add tasks to calendar |
|
2431 | - foreach ($tasks[$curday] as $task) { |
|
2432 | - echo '<a href="blog.php?action=execute_task&blog_id=' . $task['blog_id'] . '&task_id='.stripslashes($task['task_id']) . '" title="' . $task['title'] . ' : ' . get_lang('InBlog') . ' : ' . $task['blog_name'] . ' - ' . get_lang('ExecuteThisTask') . '">'; |
|
2433 | - echo Display::return_icon('blog_task.gif', get_lang('ExecuteThisTask')); |
|
2375 | + $result = Database::query($sql); |
|
2376 | + |
|
2377 | + if (Database::num_rows($result) > 0) { |
|
2378 | + while ($mytask = Database::fetch_array($result)) { |
|
2379 | + $tasks[$mytask['task_day']][$mytask['task_id']]['task_id'] = $mytask['task_id']; |
|
2380 | + $tasks[$mytask['task_day']][$mytask['task_id']]['title'] = $mytask['title']; |
|
2381 | + $tasks[$mytask['task_day']][$mytask['task_id']]['blog_id'] = $mytask['blog_id']; |
|
2382 | + $tasks[$mytask['task_day']][$mytask['task_id']]['blog_name'] = $mytask['blog_name']; |
|
2383 | + $tasks[$mytask['task_day']][$mytask['task_id']]['day'] = $mytask['task_day']; |
|
2384 | + } |
|
2385 | + } |
|
2386 | + } |
|
2387 | + |
|
2388 | + echo '<table id="smallcalendar" class="table table-responsive">', |
|
2389 | + "<tr id=\"title\">", |
|
2390 | + "<th width=\"10%\"><a href=\"", $backwardsURL, "\">«</a></th>", |
|
2391 | + "<th align=\"center\" width=\"80%\" colspan=\"5\">", $monthName, " ", $year, "</th>", |
|
2392 | + "<th width=\"10%\" align=\"right\"><a href=\"", $forewardsURL, "\">»</a></th>", "</tr>"; |
|
2393 | + |
|
2394 | + echo "<tr>"; |
|
2395 | + |
|
2396 | + for($ii = 1; $ii < 8; $ii ++) |
|
2397 | + echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>"; |
|
2398 | + |
|
2399 | + echo "</tr>"; |
|
2400 | + |
|
2401 | + $curday = -1; |
|
2402 | + $today = getdate(); |
|
2403 | + |
|
2404 | + while ($curday <= $numberofdays[$month]) { |
|
2405 | + echo "<tr>"; |
|
2406 | + for ($ii = 0; $ii < 7; $ii ++) { |
|
2407 | + if (($curday == -1) && ($ii == $startdayofweek)) |
|
2408 | + $curday = 1; |
|
2409 | + |
|
2410 | + if (($curday > 0) && ($curday <= $numberofdays[$month])) { |
|
2411 | + $bgcolor = $ii < 5 ? $class="class=\"days_week\"" : $class="class=\"days_weekend\""; |
|
2412 | + $dayheader = "$curday"; |
|
2413 | + |
|
2414 | + if(($curday == $today['mday']) && ($year == $today['year']) && ($month == $today['mon'])) { |
|
2415 | + $dayheader = "$curday"; |
|
2416 | + $class = "class=\"days_today\""; |
|
2417 | + } |
|
2418 | + |
|
2419 | + echo "<td " . $class.">"; |
|
2420 | + |
|
2421 | + // If there are posts on this day, create a filter link. |
|
2422 | + if(in_array($curday, $posts)) |
|
2423 | + echo '<a href="blog.php?blog_id=' . $blog_id . '&filter=' . $year . '-' . $month . '-' . $curday . '&month=' . $month . '&year=' . $year . '" title="' . get_lang('ViewPostsOfThisDay') . '">' . $curday . '</a>'; |
|
2424 | + else |
|
2425 | + echo $dayheader; |
|
2426 | + |
|
2427 | + if (count($tasks) > 0) { |
|
2428 | + if (isset($tasks[$curday]) && is_array($tasks[$curday])) { |
|
2429 | + // Add tasks to calendar |
|
2430 | + foreach ($tasks[$curday] as $task) { |
|
2431 | + echo '<a href="blog.php?action=execute_task&blog_id=' . $task['blog_id'] . '&task_id='.stripslashes($task['task_id']) . '" title="' . $task['title'] . ' : ' . get_lang('InBlog') . ' : ' . $task['blog_name'] . ' - ' . get_lang('ExecuteThisTask') . '">'; |
|
2432 | + echo Display::return_icon('blog_task.gif', get_lang('ExecuteThisTask')); |
|
2434 | 2433 | echo '</a>'; |
2435 | - } |
|
2436 | - } |
|
2437 | - } |
|
2438 | - |
|
2439 | - echo "</td>"; |
|
2440 | - $curday ++; |
|
2441 | - } else |
|
2442 | - echo "<td> </td>"; |
|
2443 | - } |
|
2444 | - echo "</tr>"; |
|
2445 | - } |
|
2446 | - echo "</table>"; |
|
2447 | - } |
|
2448 | - |
|
2449 | - /** |
|
2450 | - * Blog admin | Display the form to add a new blog. |
|
2451 | - * |
|
2452 | - */ |
|
2453 | - public static function display_new_blog_form() |
|
2454 | - { |
|
2434 | + } |
|
2435 | + } |
|
2436 | + } |
|
2437 | + |
|
2438 | + echo "</td>"; |
|
2439 | + $curday ++; |
|
2440 | + } else |
|
2441 | + echo "<td> </td>"; |
|
2442 | + } |
|
2443 | + echo "</tr>"; |
|
2444 | + } |
|
2445 | + echo "</table>"; |
|
2446 | + } |
|
2447 | + |
|
2448 | + /** |
|
2449 | + * Blog admin | Display the form to add a new blog. |
|
2450 | + * |
|
2451 | + */ |
|
2452 | + public static function display_new_blog_form() |
|
2453 | + { |
|
2455 | 2454 | $form = new FormValidator('add_blog', 'post', 'blog_admin.php?action=add'); |
2456 | 2455 | $form->addElement('header', get_lang('AddBlog')); |
2457 | 2456 | $form->addElement('text', 'blog_name', get_lang('Title')); |
@@ -2461,34 +2460,34 @@ discard block |
||
2461 | 2460 | $form->addButtonSave(get_lang('SaveProject')); |
2462 | 2461 | |
2463 | 2462 | $defaults = array( |
2464 | - 'blog_name' => isset($_POST['blog_name']) ? Security::remove_XSS($_POST['blog_name']) : null, |
|
2465 | - 'blog_subtitle' => isset($_POST['blog_subtitle']) ? Security::remove_XSS($_POST['blog_subtitle']) : null |
|
2466 | - ); |
|
2463 | + 'blog_name' => isset($_POST['blog_name']) ? Security::remove_XSS($_POST['blog_name']) : null, |
|
2464 | + 'blog_subtitle' => isset($_POST['blog_subtitle']) ? Security::remove_XSS($_POST['blog_subtitle']) : null |
|
2465 | + ); |
|
2467 | 2466 | $form->setDefaults($defaults); |
2468 | 2467 | $form->display(); |
2469 | - } |
|
2470 | - |
|
2471 | - /** |
|
2472 | - * Blog admin | Display the form to edit a blog. |
|
2473 | - * |
|
2474 | - */ |
|
2475 | - public static function display_edit_blog_form($blog_id) |
|
2476 | - { |
|
2477 | - $course_id = api_get_course_int_id(); |
|
2478 | - $blog_id= intval($blog_id); |
|
2479 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
2480 | - |
|
2481 | - $sql = "SELECT blog_id, blog_name, blog_subtitle |
|
2468 | + } |
|
2469 | + |
|
2470 | + /** |
|
2471 | + * Blog admin | Display the form to edit a blog. |
|
2472 | + * |
|
2473 | + */ |
|
2474 | + public static function display_edit_blog_form($blog_id) |
|
2475 | + { |
|
2476 | + $course_id = api_get_course_int_id(); |
|
2477 | + $blog_id= intval($blog_id); |
|
2478 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
2479 | + |
|
2480 | + $sql = "SELECT blog_id, blog_name, blog_subtitle |
|
2482 | 2481 | FROM $tbl_blogs |
2483 | 2482 | WHERE c_id = $course_id AND blog_id = '".$blog_id."'"; |
2484 | - $result = Database::query($sql); |
|
2485 | - $blog = Database::fetch_array($result); |
|
2483 | + $result = Database::query($sql); |
|
2484 | + $blog = Database::fetch_array($result); |
|
2486 | 2485 | |
2487 | - // the form contained errors but we do not want to lose the changes the user already did |
|
2488 | - if ($_POST) { |
|
2489 | - $blog['blog_name'] = Security::remove_XSS($_POST['blog_name']); |
|
2490 | - $blog['blog_subtitle'] = Security::remove_XSS($_POST['blog_subtitle']); |
|
2491 | - } |
|
2486 | + // the form contained errors but we do not want to lose the changes the user already did |
|
2487 | + if ($_POST) { |
|
2488 | + $blog['blog_name'] = Security::remove_XSS($_POST['blog_name']); |
|
2489 | + $blog['blog_subtitle'] = Security::remove_XSS($_POST['blog_subtitle']); |
|
2490 | + } |
|
2492 | 2491 | |
2493 | 2492 | $form = new FormValidator('edit_blog', 'post','blog_admin.php?action=edit&blog_id='.intval($_GET['blog_id'])); |
2494 | 2493 | $form->addElement('header', get_lang('EditBlog')); |
@@ -2504,76 +2503,76 @@ discard block |
||
2504 | 2503 | $defaults['blog_subtitle'] = $blog['blog_subtitle']; |
2505 | 2504 | $form->setDefaults($defaults); |
2506 | 2505 | $form->display(); |
2507 | - } |
|
2506 | + } |
|
2508 | 2507 | |
2509 | - /** |
|
2510 | - * Blog admin | Returns table with blogs in this course |
|
2511 | - */ |
|
2512 | - public static function display_blog_list() |
|
2508 | + /** |
|
2509 | + * Blog admin | Returns table with blogs in this course |
|
2510 | + */ |
|
2511 | + public static function display_blog_list() |
|
2513 | 2512 | { |
2514 | - global $charset; |
|
2515 | - $_user = api_get_user_info(); |
|
2513 | + global $charset; |
|
2514 | + $_user = api_get_user_info(); |
|
2516 | 2515 | $course_id = api_get_course_int_id(); |
2517 | 2516 | |
2518 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
2517 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
2519 | 2518 | |
2520 | - //condition for the session |
|
2521 | - $session_id = api_get_session_id(); |
|
2519 | + //condition for the session |
|
2520 | + $session_id = api_get_session_id(); |
|
2522 | 2521 | |
2523 | - $sql = "SELECT blog_name, blog_subtitle, visibility, blog_id, session_id |
|
2522 | + $sql = "SELECT blog_name, blog_subtitle, visibility, blog_id, session_id |
|
2524 | 2523 | FROM $tbl_blogs WHERE c_id = $course_id |
2525 | 2524 | ORDER BY date_creation DESC"; |
2526 | - $result = Database::query($sql); |
|
2527 | - $list_info = array(); |
|
2528 | - if (Database::num_rows($result)) { |
|
2529 | - while ($row_project=Database::fetch_row($result)) { |
|
2530 | - $list_info[]=$row_project; |
|
2531 | - } |
|
2532 | - } |
|
2533 | - |
|
2534 | - $list_content_blog = array(); |
|
2535 | - $list_body_blog = array(); |
|
2536 | - |
|
2537 | - if (is_array($list_info)) { |
|
2538 | - foreach ($list_info as $key => $info_log) { |
|
2539 | - // Validation when belongs to a session |
|
2540 | - $session_img = api_get_session_image($info_log[4], $_user['status']); |
|
2541 | - |
|
2542 | - $url_start_blog = 'blog.php' ."?". "blog_id=".$info_log[3]. "&".api_get_cidreq(); |
|
2543 | - $title = $info_log[0]; |
|
2525 | + $result = Database::query($sql); |
|
2526 | + $list_info = array(); |
|
2527 | + if (Database::num_rows($result)) { |
|
2528 | + while ($row_project=Database::fetch_row($result)) { |
|
2529 | + $list_info[]=$row_project; |
|
2530 | + } |
|
2531 | + } |
|
2532 | + |
|
2533 | + $list_content_blog = array(); |
|
2534 | + $list_body_blog = array(); |
|
2535 | + |
|
2536 | + if (is_array($list_info)) { |
|
2537 | + foreach ($list_info as $key => $info_log) { |
|
2538 | + // Validation when belongs to a session |
|
2539 | + $session_img = api_get_session_image($info_log[4], $_user['status']); |
|
2540 | + |
|
2541 | + $url_start_blog = 'blog.php' ."?". "blog_id=".$info_log[3]. "&".api_get_cidreq(); |
|
2542 | + $title = $info_log[0]; |
|
2544 | 2543 | $image = Display::return_icon('blog.png', $title); |
2545 | - $list_name = '<div style="float: left; width: 35px; height: 22px;"><a href="'.$url_start_blog.'">' . $image . '</a></div><a href="'.$url_start_blog.'">' .$title. '</a>' . $session_img; |
|
2544 | + $list_name = '<div style="float: left; width: 35px; height: 22px;"><a href="'.$url_start_blog.'">' . $image . '</a></div><a href="'.$url_start_blog.'">' .$title. '</a>' . $session_img; |
|
2546 | 2545 | |
2547 | - $list_body_blog[] = $list_name; |
|
2548 | - $list_body_blog[] = $info_log[1]; |
|
2546 | + $list_body_blog[] = $list_name; |
|
2547 | + $list_body_blog[] = $info_log[1]; |
|
2549 | 2548 | |
2550 | - $visibility_icon=($info_log[2]==0) ? 'invisible' : 'visible'; |
|
2551 | - $visibility_info=($info_log[2]==0) ? 'Visible' : 'Invisible'; |
|
2552 | - $my_image = '<a href="' .api_get_self(). '?action=edit&blog_id=' . $info_log[3] . '">'; |
|
2549 | + $visibility_icon=($info_log[2]==0) ? 'invisible' : 'visible'; |
|
2550 | + $visibility_info=($info_log[2]==0) ? 'Visible' : 'Invisible'; |
|
2551 | + $my_image = '<a href="' .api_get_self(). '?action=edit&blog_id=' . $info_log[3] . '">'; |
|
2553 | 2552 | $my_image.= Display::return_icon('edit.png', get_lang('EditBlog')); |
2554 | 2553 | |
2555 | - $my_image.= "</a>"; |
|
2556 | - $my_image.= '<a href="' .api_get_self(). '?action=delete&blog_id=' . $info_log[3] . '" '; |
|
2557 | - $my_image.= 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;" >'; |
|
2554 | + $my_image.= "</a>"; |
|
2555 | + $my_image.= '<a href="' .api_get_self(). '?action=delete&blog_id=' . $info_log[3] . '" '; |
|
2556 | + $my_image.= 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;" >'; |
|
2558 | 2557 | $my_image.= Display::return_icon('delete.png', get_lang('DeleteBlog')); |
2559 | 2558 | |
2560 | - $my_image.= "</a>"; |
|
2561 | - $my_image.= '<a href="' .api_get_self(). '?action=visibility&blog_id=' . $info_log[3] . '">'; |
|
2559 | + $my_image.= "</a>"; |
|
2560 | + $my_image.= '<a href="' .api_get_self(). '?action=visibility&blog_id=' . $info_log[3] . '">'; |
|
2562 | 2561 | $my_image.= Display::return_icon($visibility_icon . '.gif', get_lang($visibility_info)); |
2563 | 2562 | |
2564 | - $my_image.= "</a>"; |
|
2565 | - $list_body_blog[]=$my_image; |
|
2566 | - $list_content_blog[]=$list_body_blog; |
|
2567 | - $list_body_blog = array(); |
|
2568 | - } |
|
2569 | - |
|
2570 | - $table = new SortableTableFromArrayConfig($list_content_blog, 1,20,'project'); |
|
2571 | - $table->set_header(0, get_lang('Title')); |
|
2572 | - $table->set_header(1, get_lang('SubTitle')); |
|
2573 | - $table->set_header(2, get_lang('Modify')); |
|
2574 | - $table->display(); |
|
2575 | - } |
|
2576 | - } |
|
2563 | + $my_image.= "</a>"; |
|
2564 | + $list_body_blog[]=$my_image; |
|
2565 | + $list_content_blog[]=$list_body_blog; |
|
2566 | + $list_body_blog = array(); |
|
2567 | + } |
|
2568 | + |
|
2569 | + $table = new SortableTableFromArrayConfig($list_content_blog, 1,20,'project'); |
|
2570 | + $table->set_header(0, get_lang('Title')); |
|
2571 | + $table->set_header(1, get_lang('SubTitle')); |
|
2572 | + $table->set_header(2, get_lang('Modify')); |
|
2573 | + $table->display(); |
|
2574 | + } |
|
2575 | + } |
|
2577 | 2576 | } |
2578 | 2577 | |
2579 | 2578 | /** |
@@ -2594,34 +2593,34 @@ discard block |
||
2594 | 2593 | */ |
2595 | 2594 | function get_blog_attachment($blog_id, $post_id=null,$comment_id=null) |
2596 | 2595 | { |
2597 | - $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
2598 | - |
|
2599 | - $blog_id = intval($blog_id); |
|
2600 | - $comment_id = intval($comment_id); |
|
2601 | - $post_id = intval($post_id); |
|
2602 | - $row=array(); |
|
2603 | - $where=''; |
|
2604 | - if (!empty ($post_id) && is_numeric($post_id)) { |
|
2605 | - $where.=' AND post_id ="'.$post_id.'" '; |
|
2606 | - } |
|
2607 | - |
|
2608 | - if (!empty ($comment_id) && is_numeric($comment_id)) { |
|
2609 | - if (!empty ($post_id)) { |
|
2610 | - $where.= ' AND '; |
|
2611 | - } |
|
2612 | - $where.=' comment_id ="'.$comment_id.'" '; |
|
2613 | - } |
|
2596 | + $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
2597 | + |
|
2598 | + $blog_id = intval($blog_id); |
|
2599 | + $comment_id = intval($comment_id); |
|
2600 | + $post_id = intval($post_id); |
|
2601 | + $row=array(); |
|
2602 | + $where=''; |
|
2603 | + if (!empty ($post_id) && is_numeric($post_id)) { |
|
2604 | + $where.=' AND post_id ="'.$post_id.'" '; |
|
2605 | + } |
|
2606 | + |
|
2607 | + if (!empty ($comment_id) && is_numeric($comment_id)) { |
|
2608 | + if (!empty ($post_id)) { |
|
2609 | + $where.= ' AND '; |
|
2610 | + } |
|
2611 | + $where.=' comment_id ="'.$comment_id.'" '; |
|
2612 | + } |
|
2614 | 2613 | |
2615 | 2614 | $course_id = api_get_course_int_id(); |
2616 | 2615 | |
2617 | - $sql = 'SELECT path, filename, comment FROM '. $blog_table_attachment.' |
|
2616 | + $sql = 'SELECT path, filename, comment FROM '. $blog_table_attachment.' |
|
2618 | 2617 | WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; |
2619 | 2618 | |
2620 | - $result=Database::query($sql); |
|
2621 | - if (Database::num_rows($result)!=0) { |
|
2622 | - $row=Database::fetch_array($result); |
|
2623 | - } |
|
2624 | - return $row; |
|
2619 | + $result=Database::query($sql); |
|
2620 | + if (Database::num_rows($result)!=0) { |
|
2621 | + $row=Database::fetch_array($result); |
|
2622 | + } |
|
2623 | + return $row; |
|
2625 | 2624 | } |
2626 | 2625 | |
2627 | 2626 | /** |
@@ -2638,16 +2637,16 @@ discard block |
||
2638 | 2637 | |
2639 | 2638 | function delete_all_blog_attachment($blog_id,$post_id=null,$comment_id=null) |
2640 | 2639 | { |
2641 | - $_course = api_get_course_info(); |
|
2642 | - $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
2643 | - $blog_id = intval($blog_id); |
|
2644 | - $comment_id = intval($comment_id); |
|
2645 | - $post_id = intval($post_id); |
|
2640 | + $_course = api_get_course_info(); |
|
2641 | + $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
2642 | + $blog_id = intval($blog_id); |
|
2643 | + $comment_id = intval($comment_id); |
|
2644 | + $post_id = intval($post_id); |
|
2646 | 2645 | |
2647 | 2646 | $course_id = api_get_course_int_id(); |
2648 | - $where = null; |
|
2647 | + $where = null; |
|
2649 | 2648 | |
2650 | - // delete files in DB |
|
2649 | + // delete files in DB |
|
2651 | 2650 | if (!empty ($post_id) && is_numeric($post_id)) { |
2652 | 2651 | $where .= ' AND post_id ="'.$post_id.'" '; |
2653 | 2652 | } |
@@ -2659,25 +2658,25 @@ discard block |
||
2659 | 2658 | $where .= ' comment_id ="'.$comment_id.'" '; |
2660 | 2659 | } |
2661 | 2660 | |
2662 | - // delete all files in directory |
|
2663 | - $courseDir = $_course['path'].'/upload/blog'; |
|
2664 | - $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
2665 | - $updir = $sys_course_path.$courseDir; |
|
2661 | + // delete all files in directory |
|
2662 | + $courseDir = $_course['path'].'/upload/blog'; |
|
2663 | + $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
2664 | + $updir = $sys_course_path.$courseDir; |
|
2666 | 2665 | |
2667 | - $sql = 'SELECT path FROM '.$blog_table_attachment.' |
|
2666 | + $sql = 'SELECT path FROM '.$blog_table_attachment.' |
|
2668 | 2667 | WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; |
2669 | - $result=Database::query($sql); |
|
2670 | - |
|
2671 | - while ($row=Database::fetch_row($result)) { |
|
2672 | - $file=$updir.'/'.$row[0]; |
|
2673 | - if (Security::check_abs_path($file,$updir) ) |
|
2674 | - { |
|
2675 | - @ unlink($file); |
|
2676 | - } |
|
2677 | - } |
|
2678 | - $sql = 'DELETE FROM '. $blog_table_attachment.' |
|
2668 | + $result=Database::query($sql); |
|
2669 | + |
|
2670 | + while ($row=Database::fetch_row($result)) { |
|
2671 | + $file=$updir.'/'.$row[0]; |
|
2672 | + if (Security::check_abs_path($file,$updir) ) |
|
2673 | + { |
|
2674 | + @ unlink($file); |
|
2675 | + } |
|
2676 | + } |
|
2677 | + $sql = 'DELETE FROM '. $blog_table_attachment.' |
|
2679 | 2678 | WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; |
2680 | - Database::query($sql); |
|
2679 | + Database::query($sql); |
|
2681 | 2680 | } |
2682 | 2681 | |
2683 | 2682 | /** |
@@ -2687,12 +2686,12 @@ discard block |
||
2687 | 2686 | */ |
2688 | 2687 | function get_blog_post_from_user($course_code, $user_id) |
2689 | 2688 | { |
2690 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
2691 | - $tbl_blog_post = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
2692 | - $course_info = api_get_course_info($course_code); |
|
2693 | - $course_id = $course_info['real_id']; |
|
2689 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
2690 | + $tbl_blog_post = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
2691 | + $course_info = api_get_course_info($course_code); |
|
2692 | + $course_id = $course_info['real_id']; |
|
2694 | 2693 | |
2695 | - $sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation |
|
2694 | + $sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation |
|
2696 | 2695 | FROM $tbl_blogs blog |
2697 | 2696 | INNER JOIN $tbl_blog_post post |
2698 | 2697 | ON (blog.blog_id = post.blog_id) |
@@ -2701,19 +2700,19 @@ discard block |
||
2701 | 2700 | post.c_id = $course_id AND |
2702 | 2701 | author_id = $user_id AND visibility = 1 |
2703 | 2702 | ORDER BY post.date_creation DESC "; |
2704 | - $result = Database::query($sql); |
|
2705 | - $return_data = ''; |
|
2706 | - |
|
2707 | - if (Database::num_rows($result)!=0) { |
|
2708 | - while ($row=Database::fetch_array($result)) { |
|
2709 | - $return_data.= '<div class="clear"></div><br />'; |
|
2710 | - $return_data.= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.Display::return_icon('blog_article.png',get_lang('BlogPosts')).' '.$row['title'].' <div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.$my_course_id.' " >'.get_lang('SeeBlog').'</a></div></div>'; |
|
2711 | - $return_data.= '<br / >'; |
|
2712 | - $return_data.= $row['full_text']; |
|
2713 | - $return_data.= '<br /><br />'; |
|
2714 | - } |
|
2715 | - } |
|
2716 | - return $return_data; |
|
2703 | + $result = Database::query($sql); |
|
2704 | + $return_data = ''; |
|
2705 | + |
|
2706 | + if (Database::num_rows($result)!=0) { |
|
2707 | + while ($row=Database::fetch_array($result)) { |
|
2708 | + $return_data.= '<div class="clear"></div><br />'; |
|
2709 | + $return_data.= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.Display::return_icon('blog_article.png',get_lang('BlogPosts')).' '.$row['title'].' <div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.$my_course_id.' " >'.get_lang('SeeBlog').'</a></div></div>'; |
|
2710 | + $return_data.= '<br / >'; |
|
2711 | + $return_data.= $row['full_text']; |
|
2712 | + $return_data.= '<br /><br />'; |
|
2713 | + } |
|
2714 | + } |
|
2715 | + return $return_data; |
|
2717 | 2716 | } |
2718 | 2717 | |
2719 | 2718 | /** |
@@ -2730,7 +2729,7 @@ discard block |
||
2730 | 2729 | $course_info = api_get_course_info($course_code); |
2731 | 2730 | $course_id = $course_info['real_id']; |
2732 | 2731 | |
2733 | - $sql = "SELECT DISTINCT blog.blog_id, comment_id, title, comment, comment.date_creation |
|
2732 | + $sql = "SELECT DISTINCT blog.blog_id, comment_id, title, comment, comment.date_creation |
|
2734 | 2733 | FROM $tbl_blogs blog INNER JOIN $tbl_blog_comment comment |
2735 | 2734 | ON (blog.blog_id = comment.blog_id) |
2736 | 2735 | WHERE blog.c_id = $course_id AND |
@@ -2738,18 +2737,18 @@ discard block |
||
2738 | 2737 | author_id = $user_id AND |
2739 | 2738 | visibility = 1 |
2740 | 2739 | ORDER BY blog_name"; |
2741 | - $result = Database::query($sql); |
|
2742 | - $return_data = ''; |
|
2743 | - if (Database::num_rows($result)!=0) { |
|
2744 | - while ($row=Database::fetch_array($result)) { |
|
2745 | - $return_data.= '<div class="clear"></div><br />'; |
|
2746 | - $return_data.= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.$row['title'].' <div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.Security::remove_XSS($course_code).' " >'.get_lang('SeeBlog').'</a></div></div>'; |
|
2747 | - $return_data.= '<br / >'; |
|
2748 | - //$return_data.= '<strong>'.$row['title'].'</strong>'; echo '<br>';*/ |
|
2749 | - $return_data.= $row['comment']; |
|
2750 | - $return_data.= '<br />'; |
|
2751 | - } |
|
2752 | - } |
|
2753 | - return $return_data; |
|
2740 | + $result = Database::query($sql); |
|
2741 | + $return_data = ''; |
|
2742 | + if (Database::num_rows($result)!=0) { |
|
2743 | + while ($row=Database::fetch_array($result)) { |
|
2744 | + $return_data.= '<div class="clear"></div><br />'; |
|
2745 | + $return_data.= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.$row['title'].' <div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.Security::remove_XSS($course_code).' " >'.get_lang('SeeBlog').'</a></div></div>'; |
|
2746 | + $return_data.= '<br / >'; |
|
2747 | + //$return_data.= '<strong>'.$row['title'].'</strong>'; echo '<br>';*/ |
|
2748 | + $return_data.= $row['comment']; |
|
2749 | + $return_data.= '<br />'; |
|
2750 | + } |
|
2751 | + } |
|
2752 | + return $return_data; |
|
2754 | 2753 | } |
2755 | 2754 |
@@ -29,11 +29,11 @@ |
||
29 | 29 | krsort($langs, SORT_NUMERIC); |
30 | 30 | // Choosing the best match |
31 | 31 | foreach($langs as $weight => $codes) { |
32 | - foreach ($codes as $code) { |
|
33 | - if (in_array($code, $available_langs)) { |
|
34 | - return $code; |
|
35 | - } |
|
36 | - } |
|
32 | + foreach ($codes as $code) { |
|
33 | + if (in_array($code, $available_langs)) { |
|
34 | + return $code; |
|
35 | + } |
|
36 | + } |
|
37 | 37 | } |
38 | 38 | // No match |
39 | 39 | return null; |
@@ -24,15 +24,15 @@ |
||
24 | 24 | $lang_match = $chamilo_langs[get_preferred_language($available_langs)]; |
25 | 25 | // recover previous value ... |
26 | 26 | if (isset($_SESSION['user_language_choice'])) |
27 | - $lang_match = $_SESSION['user_language_choice']; |
|
27 | + $lang_match = $_SESSION['user_language_choice']; |
|
28 | 28 | |
29 | 29 | // Chamilo parameter, on logout |
30 | 30 | if (isset($_REQUEST['language']) && !empty($_REQUEST['language']) && in_array($_REQUEST['language'], $chamilo_langs)) { |
31 | - $lang_match = $_REQUEST['language']; |
|
31 | + $lang_match = $_REQUEST['language']; |
|
32 | 32 | } |
33 | 33 | // Incoming link parameter |
34 | 34 | if (isset($_REQUEST['lang']) && !empty($_REQUEST['lang']) && in_array($_REQUEST['lang'], $available_langs)) { |
35 | - $lang_match = $chamilo_langs[$_REQUEST['lang']]; |
|
35 | + $lang_match = $chamilo_langs[$_REQUEST['lang']]; |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | $detect = api_get_setting('auto_detect_language_custom_pages'); |
@@ -11,235 +11,235 @@ discard block |
||
11 | 11 | */ |
12 | 12 | class nusoap_parser extends nusoap_base |
13 | 13 | { |
14 | - var $xml = ''; |
|
15 | - var $xml_encoding = ''; |
|
16 | - var $method = ''; |
|
17 | - var $root_struct = ''; |
|
18 | - var $root_struct_name = ''; |
|
19 | - var $root_struct_namespace = ''; |
|
20 | - var $root_header = ''; |
|
14 | + var $xml = ''; |
|
15 | + var $xml_encoding = ''; |
|
16 | + var $method = ''; |
|
17 | + var $root_struct = ''; |
|
18 | + var $root_struct_name = ''; |
|
19 | + var $root_struct_namespace = ''; |
|
20 | + var $root_header = ''; |
|
21 | 21 | var $document = ''; // incoming SOAP body (text) |
22 | - // determines where in the message we are (envelope,header,body,method) |
|
23 | - var $status = ''; |
|
24 | - var $position = 0; |
|
25 | - var $depth = 0; |
|
26 | - var $default_namespace = ''; |
|
27 | - var $namespaces = array(); |
|
28 | - var $message = array(); |
|
22 | + // determines where in the message we are (envelope,header,body,method) |
|
23 | + var $status = ''; |
|
24 | + var $position = 0; |
|
25 | + var $depth = 0; |
|
26 | + var $default_namespace = ''; |
|
27 | + var $namespaces = array(); |
|
28 | + var $message = array(); |
|
29 | 29 | var $parent; |
30 | - var $fault = false; |
|
31 | - var $fault_code = ''; |
|
32 | - var $fault_str = ''; |
|
33 | - var $fault_detail = ''; |
|
34 | - var $depth_array = array(); |
|
35 | - var $debug_flag = true; |
|
36 | - var $soapresponse = NULL; // parsed SOAP Body |
|
37 | - var $soapheader = NULL; // parsed SOAP Header |
|
38 | - var $responseHeaders = ''; // incoming SOAP headers (text) |
|
39 | - var $body_position = 0; |
|
40 | - // for multiref parsing: |
|
41 | - // array of id => pos |
|
42 | - var $ids = array(); |
|
43 | - // array of id => hrefs => pos |
|
44 | - var $multirefs = array(); |
|
45 | - // toggle for auto-decoding element content |
|
46 | - var $decode_utf8 = true; |
|
30 | + var $fault = false; |
|
31 | + var $fault_code = ''; |
|
32 | + var $fault_str = ''; |
|
33 | + var $fault_detail = ''; |
|
34 | + var $depth_array = array(); |
|
35 | + var $debug_flag = true; |
|
36 | + var $soapresponse = NULL; // parsed SOAP Body |
|
37 | + var $soapheader = NULL; // parsed SOAP Header |
|
38 | + var $responseHeaders = ''; // incoming SOAP headers (text) |
|
39 | + var $body_position = 0; |
|
40 | + // for multiref parsing: |
|
41 | + // array of id => pos |
|
42 | + var $ids = array(); |
|
43 | + // array of id => hrefs => pos |
|
44 | + var $multirefs = array(); |
|
45 | + // toggle for auto-decoding element content |
|
46 | + var $decode_utf8 = true; |
|
47 | 47 | |
48 | - /** |
|
49 | - * constructor that actually does the parsing |
|
50 | - * |
|
51 | - * @param string $xml SOAP message |
|
52 | - * @param string $encoding character encoding scheme of message |
|
53 | - * @param string $method method for which XML is parsed (unused?) |
|
54 | - * @param bool $decode_utf8 whether to decode UTF-8 to ISO-8859-1 |
|
55 | - * @return void|bool |
|
56 | - * @access public |
|
57 | - */ |
|
58 | - function nusoap_parser($xml,$encoding='UTF-8',$method='',$decode_utf8=true){ |
|
59 | - parent::nusoap_base(); |
|
60 | - $this->xml = $xml; |
|
61 | - $this->xml_encoding = $encoding; |
|
62 | - $this->method = $method; |
|
63 | - $this->decode_utf8 = $decode_utf8; |
|
48 | + /** |
|
49 | + * constructor that actually does the parsing |
|
50 | + * |
|
51 | + * @param string $xml SOAP message |
|
52 | + * @param string $encoding character encoding scheme of message |
|
53 | + * @param string $method method for which XML is parsed (unused?) |
|
54 | + * @param bool $decode_utf8 whether to decode UTF-8 to ISO-8859-1 |
|
55 | + * @return void|bool |
|
56 | + * @access public |
|
57 | + */ |
|
58 | + function nusoap_parser($xml,$encoding='UTF-8',$method='',$decode_utf8=true){ |
|
59 | + parent::nusoap_base(); |
|
60 | + $this->xml = $xml; |
|
61 | + $this->xml_encoding = $encoding; |
|
62 | + $this->method = $method; |
|
63 | + $this->decode_utf8 = $decode_utf8; |
|
64 | 64 | |
65 | - // Check whether content has been read. |
|
66 | - if(!empty($this->xml)){ |
|
67 | - // Check XML encoding |
|
68 | - $pos_xml = strpos($xml, '<?xml'); |
|
69 | - if ($pos_xml !== FALSE) { |
|
70 | - $xml_decl = substr($xml, $pos_xml, strpos($xml, '?>', $pos_xml + 2) - $pos_xml + 1); |
|
71 | - if (preg_match("/encoding=[\"']([^\"']*)[\"']/", $xml_decl, $res)) { |
|
72 | - $xml_encoding = $res[1]; |
|
73 | - if (strtoupper($xml_encoding) != $encoding) { |
|
74 | - $err = "Charset from HTTP Content-Type '" . $encoding . "' does not match encoding from XML declaration '" . $xml_encoding . "'"; |
|
75 | - $this->debug($err); |
|
76 | - if ($encoding != 'ISO-8859-1' || strtoupper($xml_encoding) != 'UTF-8') { |
|
77 | - $this->setError($err); |
|
78 | - return false; |
|
79 | - } |
|
80 | - // when HTTP says ISO-8859-1 (the default) and XML says UTF-8 (the typical), assume the other endpoint is just sloppy and proceed |
|
81 | - } else { |
|
82 | - $this->debug('Charset from HTTP Content-Type matches encoding from XML declaration'); |
|
83 | - } |
|
84 | - } else { |
|
85 | - $this->debug('No encoding specified in XML declaration'); |
|
86 | - } |
|
87 | - } else { |
|
88 | - $this->debug('No XML declaration'); |
|
89 | - } |
|
90 | - $this->debug('Entering nusoap_parser(), length='.strlen($xml).', encoding='.$encoding); |
|
91 | - // Create an XML parser - why not xml_parser_create_ns? |
|
92 | - $this->parser = xml_parser_create($this->xml_encoding); |
|
93 | - // Set the options for parsing the XML data. |
|
94 | - //xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); |
|
95 | - xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); |
|
96 | - xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $this->xml_encoding); |
|
97 | - // Set the object for the parser. |
|
98 | - xml_set_object($this->parser, $this); |
|
99 | - // Set the element handlers for the parser. |
|
100 | - xml_set_element_handler($this->parser, 'start_element','end_element'); |
|
101 | - xml_set_character_data_handler($this->parser,'character_data'); |
|
65 | + // Check whether content has been read. |
|
66 | + if(!empty($this->xml)){ |
|
67 | + // Check XML encoding |
|
68 | + $pos_xml = strpos($xml, '<?xml'); |
|
69 | + if ($pos_xml !== FALSE) { |
|
70 | + $xml_decl = substr($xml, $pos_xml, strpos($xml, '?>', $pos_xml + 2) - $pos_xml + 1); |
|
71 | + if (preg_match("/encoding=[\"']([^\"']*)[\"']/", $xml_decl, $res)) { |
|
72 | + $xml_encoding = $res[1]; |
|
73 | + if (strtoupper($xml_encoding) != $encoding) { |
|
74 | + $err = "Charset from HTTP Content-Type '" . $encoding . "' does not match encoding from XML declaration '" . $xml_encoding . "'"; |
|
75 | + $this->debug($err); |
|
76 | + if ($encoding != 'ISO-8859-1' || strtoupper($xml_encoding) != 'UTF-8') { |
|
77 | + $this->setError($err); |
|
78 | + return false; |
|
79 | + } |
|
80 | + // when HTTP says ISO-8859-1 (the default) and XML says UTF-8 (the typical), assume the other endpoint is just sloppy and proceed |
|
81 | + } else { |
|
82 | + $this->debug('Charset from HTTP Content-Type matches encoding from XML declaration'); |
|
83 | + } |
|
84 | + } else { |
|
85 | + $this->debug('No encoding specified in XML declaration'); |
|
86 | + } |
|
87 | + } else { |
|
88 | + $this->debug('No XML declaration'); |
|
89 | + } |
|
90 | + $this->debug('Entering nusoap_parser(), length='.strlen($xml).', encoding='.$encoding); |
|
91 | + // Create an XML parser - why not xml_parser_create_ns? |
|
92 | + $this->parser = xml_parser_create($this->xml_encoding); |
|
93 | + // Set the options for parsing the XML data. |
|
94 | + //xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); |
|
95 | + xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); |
|
96 | + xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $this->xml_encoding); |
|
97 | + // Set the object for the parser. |
|
98 | + xml_set_object($this->parser, $this); |
|
99 | + // Set the element handlers for the parser. |
|
100 | + xml_set_element_handler($this->parser, 'start_element','end_element'); |
|
101 | + xml_set_character_data_handler($this->parser,'character_data'); |
|
102 | 102 | |
103 | - xml_parse($this->parser, $this->xml); |
|
103 | + xml_parse($this->parser, $this->xml); |
|
104 | 104 | |
105 | - // Parse the XML file. |
|
106 | - //if (!xml_parse($this->parser,$xml,true)){ |
|
107 | - if (false) { |
|
108 | - // Display an error message. |
|
109 | - $err = sprintf('XML error parsing SOAP payload on line %d: %s', |
|
110 | - xml_get_current_line_number($this->parser), |
|
111 | - xml_error_string(xml_get_error_code($this->parser))); |
|
112 | - $this->debug($err); |
|
113 | - $this->debug("XML payload:\n" . $xml); |
|
114 | - $this->setError($err); |
|
115 | - } else { |
|
116 | - $this->debug('in nusoap_parser ctor, message:'); |
|
117 | - $this->appendDebug($this->varDump($this->message)); |
|
118 | - $this->debug('parsed successfully, found root struct: '.$this->root_struct.' of name '.$this->root_struct_name); |
|
119 | - // get final value |
|
120 | - $this->soapresponse = $this->message[$this->root_struct]['result']; |
|
121 | - // get header value |
|
122 | - if($this->root_header != '' && isset($this->message[$this->root_header]['result'])){ |
|
123 | - $this->soapheader = $this->message[$this->root_header]['result']; |
|
124 | - } |
|
125 | - // resolve hrefs/ids |
|
126 | - if(sizeof($this->multirefs) > 0){ |
|
127 | - foreach($this->multirefs as $id => $hrefs){ |
|
128 | - $this->debug('resolving multirefs for id: '.$id); |
|
129 | - $idVal = $this->buildVal($this->ids[$id]); |
|
130 | - if (is_array($idVal) && isset($idVal['!id'])) { |
|
131 | - unset($idVal['!id']); |
|
132 | - } |
|
133 | - foreach($hrefs as $refPos => $ref){ |
|
134 | - $this->debug('resolving href at pos '.$refPos); |
|
135 | - $this->multirefs[$id][$refPos] = $idVal; |
|
136 | - } |
|
137 | - } |
|
138 | - } |
|
139 | - } |
|
140 | - xml_parser_free($this->parser); |
|
141 | - } else { |
|
142 | - $this->debug('xml was empty, didn\'t parse!'); |
|
143 | - $this->setError('xml was empty, didn\'t parse!'); |
|
144 | - } |
|
145 | - } |
|
105 | + // Parse the XML file. |
|
106 | + //if (!xml_parse($this->parser,$xml,true)){ |
|
107 | + if (false) { |
|
108 | + // Display an error message. |
|
109 | + $err = sprintf('XML error parsing SOAP payload on line %d: %s', |
|
110 | + xml_get_current_line_number($this->parser), |
|
111 | + xml_error_string(xml_get_error_code($this->parser))); |
|
112 | + $this->debug($err); |
|
113 | + $this->debug("XML payload:\n" . $xml); |
|
114 | + $this->setError($err); |
|
115 | + } else { |
|
116 | + $this->debug('in nusoap_parser ctor, message:'); |
|
117 | + $this->appendDebug($this->varDump($this->message)); |
|
118 | + $this->debug('parsed successfully, found root struct: '.$this->root_struct.' of name '.$this->root_struct_name); |
|
119 | + // get final value |
|
120 | + $this->soapresponse = $this->message[$this->root_struct]['result']; |
|
121 | + // get header value |
|
122 | + if($this->root_header != '' && isset($this->message[$this->root_header]['result'])){ |
|
123 | + $this->soapheader = $this->message[$this->root_header]['result']; |
|
124 | + } |
|
125 | + // resolve hrefs/ids |
|
126 | + if(sizeof($this->multirefs) > 0){ |
|
127 | + foreach($this->multirefs as $id => $hrefs){ |
|
128 | + $this->debug('resolving multirefs for id: '.$id); |
|
129 | + $idVal = $this->buildVal($this->ids[$id]); |
|
130 | + if (is_array($idVal) && isset($idVal['!id'])) { |
|
131 | + unset($idVal['!id']); |
|
132 | + } |
|
133 | + foreach($hrefs as $refPos => $ref){ |
|
134 | + $this->debug('resolving href at pos '.$refPos); |
|
135 | + $this->multirefs[$id][$refPos] = $idVal; |
|
136 | + } |
|
137 | + } |
|
138 | + } |
|
139 | + } |
|
140 | + xml_parser_free($this->parser); |
|
141 | + } else { |
|
142 | + $this->debug('xml was empty, didn\'t parse!'); |
|
143 | + $this->setError('xml was empty, didn\'t parse!'); |
|
144 | + } |
|
145 | + } |
|
146 | 146 | |
147 | - /** |
|
148 | - * start-element handler |
|
149 | - * |
|
150 | - * @param resource $parser XML parser object |
|
151 | - * @param string $name element name |
|
152 | - * @param array $attrs associative array of attributes |
|
153 | - * @access private |
|
154 | - */ |
|
155 | - function start_element($parser, $name, $attrs) { |
|
147 | + /** |
|
148 | + * start-element handler |
|
149 | + * |
|
150 | + * @param resource $parser XML parser object |
|
151 | + * @param string $name element name |
|
152 | + * @param array $attrs associative array of attributes |
|
153 | + * @access private |
|
154 | + */ |
|
155 | + function start_element($parser, $name, $attrs) { |
|
156 | 156 | |
157 | - // position in a total number of elements, starting from 0 |
|
158 | - // update class level pos |
|
159 | - $pos = $this->position++; |
|
160 | - // and set mine |
|
161 | - $this->message[$pos] = array('pos' => $pos,'children'=>'','cdata'=>''); |
|
162 | - // depth = how many levels removed from root? |
|
163 | - // set mine as current global depth and increment global depth value |
|
164 | - $this->message[$pos]['depth'] = $this->depth++; |
|
157 | + // position in a total number of elements, starting from 0 |
|
158 | + // update class level pos |
|
159 | + $pos = $this->position++; |
|
160 | + // and set mine |
|
161 | + $this->message[$pos] = array('pos' => $pos,'children'=>'','cdata'=>''); |
|
162 | + // depth = how many levels removed from root? |
|
163 | + // set mine as current global depth and increment global depth value |
|
164 | + $this->message[$pos]['depth'] = $this->depth++; |
|
165 | 165 | |
166 | - // else add self as child to whoever the current parent is |
|
167 | - if($pos != 0){ |
|
168 | - $this->message[$this->parent]['children'] .= '|'.$pos; |
|
169 | - } |
|
170 | - // set my parent |
|
171 | - $this->message[$pos]['parent'] = $this->parent; |
|
172 | - // set self as current parent |
|
173 | - $this->parent = $pos; |
|
174 | - // set self as current value for this depth |
|
175 | - $this->depth_array[$this->depth] = $pos; |
|
176 | - // get element prefix |
|
177 | - if(strpos($name,':')){ |
|
178 | - // get ns prefix |
|
179 | - $prefix = substr($name,0,strpos($name,':')); |
|
180 | - // get unqualified name |
|
181 | - $name = substr(strstr($name,':'),1); |
|
182 | - } |
|
183 | - // set status |
|
184 | - if ($name == 'Envelope' && $this->status == '') { |
|
185 | - $this->status = 'envelope'; |
|
186 | - } elseif ($name == 'Header' && $this->status == 'envelope') { |
|
187 | - $this->root_header = $pos; |
|
188 | - $this->status = 'header'; |
|
189 | - } elseif ($name == 'Body' && $this->status == 'envelope'){ |
|
190 | - $this->status = 'body'; |
|
191 | - $this->body_position = $pos; |
|
192 | - // set method |
|
193 | - } elseif($this->status == 'body' && $pos == ($this->body_position+1)) { |
|
194 | - $this->status = 'method'; |
|
195 | - $this->root_struct_name = $name; |
|
196 | - $this->root_struct = $pos; |
|
197 | - $this->message[$pos]['type'] = 'struct'; |
|
198 | - $this->debug("found root struct $this->root_struct_name, pos $this->root_struct"); |
|
199 | - } |
|
200 | - // set my status |
|
201 | - $this->message[$pos]['status'] = $this->status; |
|
202 | - // set name |
|
203 | - $this->message[$pos]['name'] = htmlspecialchars($name); |
|
204 | - // set attrs |
|
205 | - $this->message[$pos]['attrs'] = $attrs; |
|
166 | + // else add self as child to whoever the current parent is |
|
167 | + if($pos != 0){ |
|
168 | + $this->message[$this->parent]['children'] .= '|'.$pos; |
|
169 | + } |
|
170 | + // set my parent |
|
171 | + $this->message[$pos]['parent'] = $this->parent; |
|
172 | + // set self as current parent |
|
173 | + $this->parent = $pos; |
|
174 | + // set self as current value for this depth |
|
175 | + $this->depth_array[$this->depth] = $pos; |
|
176 | + // get element prefix |
|
177 | + if(strpos($name,':')){ |
|
178 | + // get ns prefix |
|
179 | + $prefix = substr($name,0,strpos($name,':')); |
|
180 | + // get unqualified name |
|
181 | + $name = substr(strstr($name,':'),1); |
|
182 | + } |
|
183 | + // set status |
|
184 | + if ($name == 'Envelope' && $this->status == '') { |
|
185 | + $this->status = 'envelope'; |
|
186 | + } elseif ($name == 'Header' && $this->status == 'envelope') { |
|
187 | + $this->root_header = $pos; |
|
188 | + $this->status = 'header'; |
|
189 | + } elseif ($name == 'Body' && $this->status == 'envelope'){ |
|
190 | + $this->status = 'body'; |
|
191 | + $this->body_position = $pos; |
|
192 | + // set method |
|
193 | + } elseif($this->status == 'body' && $pos == ($this->body_position+1)) { |
|
194 | + $this->status = 'method'; |
|
195 | + $this->root_struct_name = $name; |
|
196 | + $this->root_struct = $pos; |
|
197 | + $this->message[$pos]['type'] = 'struct'; |
|
198 | + $this->debug("found root struct $this->root_struct_name, pos $this->root_struct"); |
|
199 | + } |
|
200 | + // set my status |
|
201 | + $this->message[$pos]['status'] = $this->status; |
|
202 | + // set name |
|
203 | + $this->message[$pos]['name'] = htmlspecialchars($name); |
|
204 | + // set attrs |
|
205 | + $this->message[$pos]['attrs'] = $attrs; |
|
206 | 206 | |
207 | - // loop through atts, logging ns and type declarations |
|
207 | + // loop through atts, logging ns and type declarations |
|
208 | 208 | $attstr = ''; |
209 | - foreach($attrs as $key => $value){ |
|
210 | - $key_prefix = $this->getPrefix($key); |
|
211 | - $key_localpart = $this->getLocalPart($key); |
|
212 | - // if ns declarations, add to class level array of valid namespaces |
|
209 | + foreach($attrs as $key => $value){ |
|
210 | + $key_prefix = $this->getPrefix($key); |
|
211 | + $key_localpart = $this->getLocalPart($key); |
|
212 | + // if ns declarations, add to class level array of valid namespaces |
|
213 | 213 | if($key_prefix == 'xmlns'){ |
214 | - if(preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/',$value)){ |
|
215 | - $this->XMLSchemaVersion = $value; |
|
216 | - $this->namespaces['xsd'] = $this->XMLSchemaVersion; |
|
217 | - $this->namespaces['xsi'] = $this->XMLSchemaVersion.'-instance'; |
|
218 | - } |
|
214 | + if(preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/',$value)){ |
|
215 | + $this->XMLSchemaVersion = $value; |
|
216 | + $this->namespaces['xsd'] = $this->XMLSchemaVersion; |
|
217 | + $this->namespaces['xsi'] = $this->XMLSchemaVersion.'-instance'; |
|
218 | + } |
|
219 | 219 | $this->namespaces[$key_localpart] = $value; |
220 | - // set method namespace |
|
221 | - if($name == $this->root_struct_name){ |
|
222 | - $this->methodNamespace = $value; |
|
223 | - } |
|
224 | - // if it's a type declaration, set type |
|
220 | + // set method namespace |
|
221 | + if($name == $this->root_struct_name){ |
|
222 | + $this->methodNamespace = $value; |
|
223 | + } |
|
224 | + // if it's a type declaration, set type |
|
225 | 225 | } elseif($key_localpart == 'type'){ |
226 | - if (isset($this->message[$pos]['type']) && $this->message[$pos]['type'] == 'array') { |
|
227 | - // do nothing: already processed arrayType |
|
228 | - } else { |
|
229 | - $value_prefix = $this->getPrefix($value); |
|
230 | - $value_localpart = $this->getLocalPart($value); |
|
231 | - $this->message[$pos]['type'] = $value_localpart; |
|
232 | - $this->message[$pos]['typePrefix'] = $value_prefix; |
|
233 | - if(isset($this->namespaces[$value_prefix])){ |
|
234 | - $this->message[$pos]['type_namespace'] = $this->namespaces[$value_prefix]; |
|
235 | - } else if(isset($attrs['xmlns:'.$value_prefix])) { |
|
236 | - $this->message[$pos]['type_namespace'] = $attrs['xmlns:'.$value_prefix]; |
|
237 | - } |
|
238 | - // should do something here with the namespace of specified type? |
|
239 | - } |
|
240 | - } elseif($key_localpart == 'arrayType'){ |
|
241 | - $this->message[$pos]['type'] = 'array'; |
|
242 | - /* do arrayType ereg here |
|
226 | + if (isset($this->message[$pos]['type']) && $this->message[$pos]['type'] == 'array') { |
|
227 | + // do nothing: already processed arrayType |
|
228 | + } else { |
|
229 | + $value_prefix = $this->getPrefix($value); |
|
230 | + $value_localpart = $this->getLocalPart($value); |
|
231 | + $this->message[$pos]['type'] = $value_localpart; |
|
232 | + $this->message[$pos]['typePrefix'] = $value_prefix; |
|
233 | + if(isset($this->namespaces[$value_prefix])){ |
|
234 | + $this->message[$pos]['type_namespace'] = $this->namespaces[$value_prefix]; |
|
235 | + } else if(isset($attrs['xmlns:'.$value_prefix])) { |
|
236 | + $this->message[$pos]['type_namespace'] = $attrs['xmlns:'.$value_prefix]; |
|
237 | + } |
|
238 | + // should do something here with the namespace of specified type? |
|
239 | + } |
|
240 | + } elseif($key_localpart == 'arrayType'){ |
|
241 | + $this->message[$pos]['type'] = 'array'; |
|
242 | + /* do arrayType ereg here |
|
243 | 243 | [1] arrayTypeValue ::= atype asize |
244 | 244 | [2] atype ::= QName rank* |
245 | 245 | [3] rank ::= '[' (',')* ']' |
@@ -247,129 +247,129 @@ discard block |
||
247 | 247 | [5] length ::= nextDimension* Digit+ |
248 | 248 | [6] nextDimension ::= Digit+ ',' |
249 | 249 | */ |
250 | - $expr = '/([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]/'; |
|
251 | - if(preg_match($expr,$value,$regs)){ |
|
252 | - $this->message[$pos]['typePrefix'] = $regs[1]; |
|
253 | - $this->message[$pos]['arrayTypePrefix'] = $regs[1]; |
|
254 | - if (isset($this->namespaces[$regs[1]])) { |
|
255 | - $this->message[$pos]['arrayTypeNamespace'] = $this->namespaces[$regs[1]]; |
|
256 | - } else if (isset($attrs['xmlns:'.$regs[1]])) { |
|
257 | - $this->message[$pos]['arrayTypeNamespace'] = $attrs['xmlns:'.$regs[1]]; |
|
258 | - } |
|
259 | - $this->message[$pos]['arrayType'] = $regs[2]; |
|
260 | - $this->message[$pos]['arraySize'] = $regs[3]; |
|
261 | - $this->message[$pos]['arrayCols'] = $regs[4]; |
|
262 | - } |
|
263 | - // specifies nil value (or not) |
|
264 | - } elseif ($key_localpart == 'nil'){ |
|
265 | - $this->message[$pos]['nil'] = ($value == 'true' || $value == '1'); |
|
266 | - // some other attribute |
|
267 | - } elseif ($key != 'href' && $key != 'xmlns' && $key_localpart != 'encodingStyle' && $key_localpart != 'root') { |
|
268 | - $this->message[$pos]['xattrs']['!' . $key] = $value; |
|
269 | - } |
|
250 | + $expr = '/([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]/'; |
|
251 | + if(preg_match($expr,$value,$regs)){ |
|
252 | + $this->message[$pos]['typePrefix'] = $regs[1]; |
|
253 | + $this->message[$pos]['arrayTypePrefix'] = $regs[1]; |
|
254 | + if (isset($this->namespaces[$regs[1]])) { |
|
255 | + $this->message[$pos]['arrayTypeNamespace'] = $this->namespaces[$regs[1]]; |
|
256 | + } else if (isset($attrs['xmlns:'.$regs[1]])) { |
|
257 | + $this->message[$pos]['arrayTypeNamespace'] = $attrs['xmlns:'.$regs[1]]; |
|
258 | + } |
|
259 | + $this->message[$pos]['arrayType'] = $regs[2]; |
|
260 | + $this->message[$pos]['arraySize'] = $regs[3]; |
|
261 | + $this->message[$pos]['arrayCols'] = $regs[4]; |
|
262 | + } |
|
263 | + // specifies nil value (or not) |
|
264 | + } elseif ($key_localpart == 'nil'){ |
|
265 | + $this->message[$pos]['nil'] = ($value == 'true' || $value == '1'); |
|
266 | + // some other attribute |
|
267 | + } elseif ($key != 'href' && $key != 'xmlns' && $key_localpart != 'encodingStyle' && $key_localpart != 'root') { |
|
268 | + $this->message[$pos]['xattrs']['!' . $key] = $value; |
|
269 | + } |
|
270 | 270 | |
271 | - if ($key == 'xmlns') { |
|
272 | - $this->default_namespace = $value; |
|
273 | - } |
|
274 | - // log id |
|
275 | - if($key == 'id'){ |
|
276 | - $this->ids[$value] = $pos; |
|
277 | - } |
|
278 | - // root |
|
279 | - if($key_localpart == 'root' && $value == 1){ |
|
280 | - $this->status = 'method'; |
|
281 | - $this->root_struct_name = $name; |
|
282 | - $this->root_struct = $pos; |
|
283 | - $this->debug("found root struct $this->root_struct_name, pos $pos"); |
|
284 | - } |
|
271 | + if ($key == 'xmlns') { |
|
272 | + $this->default_namespace = $value; |
|
273 | + } |
|
274 | + // log id |
|
275 | + if($key == 'id'){ |
|
276 | + $this->ids[$value] = $pos; |
|
277 | + } |
|
278 | + // root |
|
279 | + if($key_localpart == 'root' && $value == 1){ |
|
280 | + $this->status = 'method'; |
|
281 | + $this->root_struct_name = $name; |
|
282 | + $this->root_struct = $pos; |
|
283 | + $this->debug("found root struct $this->root_struct_name, pos $pos"); |
|
284 | + } |
|
285 | 285 | // for doclit |
286 | 286 | $attstr .= " $key=\"$value\""; |
287 | - } |
|
287 | + } |
|
288 | 288 | // get namespace - must be done after namespace atts are processed |
289 | - if(isset($prefix)){ |
|
290 | - $this->message[$pos]['namespace'] = $this->namespaces[$prefix]; |
|
291 | - $this->default_namespace = $this->namespaces[$prefix]; |
|
292 | - } else { |
|
293 | - $this->message[$pos]['namespace'] = $this->default_namespace; |
|
294 | - } |
|
289 | + if(isset($prefix)){ |
|
290 | + $this->message[$pos]['namespace'] = $this->namespaces[$prefix]; |
|
291 | + $this->default_namespace = $this->namespaces[$prefix]; |
|
292 | + } else { |
|
293 | + $this->message[$pos]['namespace'] = $this->default_namespace; |
|
294 | + } |
|
295 | 295 | if($this->status == 'header'){ |
296 | - if ($this->root_header != $pos) { |
|
297 | - $this->responseHeaders .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>"; |
|
298 | - } |
|
296 | + if ($this->root_header != $pos) { |
|
297 | + $this->responseHeaders .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>"; |
|
298 | + } |
|
299 | 299 | } elseif($this->root_struct_name != ''){ |
300 | - $this->document .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>"; |
|
300 | + $this->document .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>"; |
|
301 | 301 | } |
302 | - } |
|
302 | + } |
|
303 | 303 | |
304 | - /** |
|
305 | - * end-element handler |
|
306 | - * |
|
307 | - * @param resource $parser XML parser object |
|
308 | - * @param string $name element name |
|
309 | - * @access private |
|
310 | - */ |
|
311 | - function end_element($parser, $name) { |
|
312 | - // position of current element is equal to the last value left in depth_array for my depth |
|
313 | - $pos = $this->depth_array[$this->depth--]; |
|
304 | + /** |
|
305 | + * end-element handler |
|
306 | + * |
|
307 | + * @param resource $parser XML parser object |
|
308 | + * @param string $name element name |
|
309 | + * @access private |
|
310 | + */ |
|
311 | + function end_element($parser, $name) { |
|
312 | + // position of current element is equal to the last value left in depth_array for my depth |
|
313 | + $pos = $this->depth_array[$this->depth--]; |
|
314 | 314 | |
315 | 315 | // get element prefix |
316 | - if(strpos($name,':')){ |
|
317 | - // get ns prefix |
|
318 | - $prefix = substr($name,0,strpos($name,':')); |
|
319 | - // get unqualified name |
|
320 | - $name = substr(strstr($name,':'),1); |
|
321 | - } |
|
316 | + if(strpos($name,':')){ |
|
317 | + // get ns prefix |
|
318 | + $prefix = substr($name,0,strpos($name,':')); |
|
319 | + // get unqualified name |
|
320 | + $name = substr(strstr($name,':'),1); |
|
321 | + } |
|
322 | 322 | |
323 | - // build to native type |
|
324 | - if(isset($this->body_position) && $pos > $this->body_position){ |
|
325 | - // deal w/ multirefs |
|
326 | - if(isset($this->message[$pos]['attrs']['href'])){ |
|
327 | - // get id |
|
328 | - $id = substr($this->message[$pos]['attrs']['href'],1); |
|
329 | - // add placeholder to href array |
|
330 | - $this->multirefs[$id][$pos] = 'placeholder'; |
|
331 | - // add set a reference to it as the result value |
|
332 | - $this->message[$pos]['result'] =& $this->multirefs[$id][$pos]; |
|
323 | + // build to native type |
|
324 | + if(isset($this->body_position) && $pos > $this->body_position){ |
|
325 | + // deal w/ multirefs |
|
326 | + if(isset($this->message[$pos]['attrs']['href'])){ |
|
327 | + // get id |
|
328 | + $id = substr($this->message[$pos]['attrs']['href'],1); |
|
329 | + // add placeholder to href array |
|
330 | + $this->multirefs[$id][$pos] = 'placeholder'; |
|
331 | + // add set a reference to it as the result value |
|
332 | + $this->message[$pos]['result'] =& $this->multirefs[$id][$pos]; |
|
333 | 333 | // build complexType values |
334 | - } elseif($this->message[$pos]['children'] != ''){ |
|
335 | - // if result has already been generated (struct/array) |
|
336 | - if(!isset($this->message[$pos]['result'])){ |
|
337 | - $this->message[$pos]['result'] = $this->buildVal($pos); |
|
338 | - } |
|
339 | - // build complexType values of attributes and possibly simpleContent |
|
340 | - } elseif (isset($this->message[$pos]['xattrs'])) { |
|
341 | - if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) { |
|
342 | - $this->message[$pos]['xattrs']['!'] = null; |
|
343 | - } elseif (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') { |
|
344 | - if (isset($this->message[$pos]['type'])) { |
|
345 | - $this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
346 | - } else { |
|
347 | - $parent = $this->message[$pos]['parent']; |
|
348 | - if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
349 | - $this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
350 | - } else { |
|
351 | - $this->message[$pos]['xattrs']['!'] = $this->message[$pos]['cdata']; |
|
352 | - } |
|
353 | - } |
|
354 | - } |
|
355 | - $this->message[$pos]['result'] = $this->message[$pos]['xattrs']; |
|
356 | - // set value of simpleType (or nil complexType) |
|
357 | - } else { |
|
358 | - //$this->debug('adding data for scalar value '.$this->message[$pos]['name'].' of value '.$this->message[$pos]['cdata']); |
|
359 | - if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) { |
|
360 | - $this->message[$pos]['xattrs']['!'] = null; |
|
361 | - } elseif (isset($this->message[$pos]['type'])) { |
|
362 | - $this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
363 | - } else { |
|
364 | - $parent = $this->message[$pos]['parent']; |
|
365 | - if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
366 | - $this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
367 | - } else { |
|
368 | - $this->message[$pos]['result'] = $this->message[$pos]['cdata']; |
|
369 | - } |
|
370 | - } |
|
334 | + } elseif($this->message[$pos]['children'] != ''){ |
|
335 | + // if result has already been generated (struct/array) |
|
336 | + if(!isset($this->message[$pos]['result'])){ |
|
337 | + $this->message[$pos]['result'] = $this->buildVal($pos); |
|
338 | + } |
|
339 | + // build complexType values of attributes and possibly simpleContent |
|
340 | + } elseif (isset($this->message[$pos]['xattrs'])) { |
|
341 | + if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) { |
|
342 | + $this->message[$pos]['xattrs']['!'] = null; |
|
343 | + } elseif (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') { |
|
344 | + if (isset($this->message[$pos]['type'])) { |
|
345 | + $this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
346 | + } else { |
|
347 | + $parent = $this->message[$pos]['parent']; |
|
348 | + if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
349 | + $this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
350 | + } else { |
|
351 | + $this->message[$pos]['xattrs']['!'] = $this->message[$pos]['cdata']; |
|
352 | + } |
|
353 | + } |
|
354 | + } |
|
355 | + $this->message[$pos]['result'] = $this->message[$pos]['xattrs']; |
|
356 | + // set value of simpleType (or nil complexType) |
|
357 | + } else { |
|
358 | + //$this->debug('adding data for scalar value '.$this->message[$pos]['name'].' of value '.$this->message[$pos]['cdata']); |
|
359 | + if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) { |
|
360 | + $this->message[$pos]['xattrs']['!'] = null; |
|
361 | + } elseif (isset($this->message[$pos]['type'])) { |
|
362 | + $this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
363 | + } else { |
|
364 | + $parent = $this->message[$pos]['parent']; |
|
365 | + if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
366 | + $this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
367 | + } else { |
|
368 | + $this->message[$pos]['result'] = $this->message[$pos]['cdata']; |
|
369 | + } |
|
370 | + } |
|
371 | 371 | |
372 | - /* add value to parent's result, if parent is struct/array |
|
372 | + /* add value to parent's result, if parent is struct/array |
|
373 | 373 | $parent = $this->message[$pos]['parent']; |
374 | 374 | if($this->message[$parent]['type'] != 'map'){ |
375 | 375 | if(strtolower($this->message[$parent]['type']) == 'array'){ |
@@ -379,261 +379,261 @@ discard block |
||
379 | 379 | } |
380 | 380 | } |
381 | 381 | */ |
382 | - } |
|
383 | - } |
|
382 | + } |
|
383 | + } |
|
384 | 384 | |
385 | 385 | // for doclit |
386 | 386 | if($this->status == 'header'){ |
387 | - if ($this->root_header != $pos) { |
|
388 | - $this->responseHeaders .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>"; |
|
389 | - } |
|
387 | + if ($this->root_header != $pos) { |
|
388 | + $this->responseHeaders .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>"; |
|
389 | + } |
|
390 | 390 | } elseif($pos >= $this->root_struct){ |
391 | - $this->document .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>"; |
|
391 | + $this->document .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>"; |
|
392 | 392 | } |
393 | - // switch status |
|
394 | - if ($pos == $this->root_struct){ |
|
395 | - $this->status = 'body'; |
|
396 | - $this->root_struct_namespace = $this->message[$pos]['namespace']; |
|
397 | - } elseif ($pos == $this->root_header) { |
|
398 | - $this->status = 'envelope'; |
|
399 | - } elseif ($name == 'Body' && $this->status == 'body') { |
|
400 | - $this->status = 'envelope'; |
|
401 | - } elseif ($name == 'Header' && $this->status == 'header') { // will never happen |
|
402 | - $this->status = 'envelope'; |
|
403 | - } elseif ($name == 'Envelope' && $this->status == 'envelope') { |
|
404 | - $this->status = ''; |
|
405 | - } |
|
406 | - // set parent back to my parent |
|
407 | - $this->parent = $this->message[$pos]['parent']; |
|
408 | - } |
|
393 | + // switch status |
|
394 | + if ($pos == $this->root_struct){ |
|
395 | + $this->status = 'body'; |
|
396 | + $this->root_struct_namespace = $this->message[$pos]['namespace']; |
|
397 | + } elseif ($pos == $this->root_header) { |
|
398 | + $this->status = 'envelope'; |
|
399 | + } elseif ($name == 'Body' && $this->status == 'body') { |
|
400 | + $this->status = 'envelope'; |
|
401 | + } elseif ($name == 'Header' && $this->status == 'header') { // will never happen |
|
402 | + $this->status = 'envelope'; |
|
403 | + } elseif ($name == 'Envelope' && $this->status == 'envelope') { |
|
404 | + $this->status = ''; |
|
405 | + } |
|
406 | + // set parent back to my parent |
|
407 | + $this->parent = $this->message[$pos]['parent']; |
|
408 | + } |
|
409 | 409 | |
410 | - /** |
|
411 | - * element content handler |
|
412 | - * |
|
413 | - * @param resource $parser XML parser object |
|
414 | - * @param string $data element content |
|
415 | - * @access private |
|
416 | - */ |
|
417 | - function character_data($parser, $data) |
|
410 | + /** |
|
411 | + * element content handler |
|
412 | + * |
|
413 | + * @param resource $parser XML parser object |
|
414 | + * @param string $data element content |
|
415 | + * @access private |
|
416 | + */ |
|
417 | + function character_data($parser, $data) |
|
418 | 418 | { |
419 | - $pos = $this->depth_array[$this->depth]; |
|
420 | - if ($this->xml_encoding == 'UTF-8'){ |
|
421 | - // TODO: add an option to disable this for folks who want |
|
422 | - // raw UTF-8 that, e.g., might not map to iso-8859-1 |
|
423 | - // TODO: this can also be handled with xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, "ISO-8859-1"); |
|
424 | - if($this->decode_utf8){ |
|
425 | - $data = utf8_decode($data); |
|
426 | - } |
|
427 | - } |
|
419 | + $pos = $this->depth_array[$this->depth]; |
|
420 | + if ($this->xml_encoding == 'UTF-8'){ |
|
421 | + // TODO: add an option to disable this for folks who want |
|
422 | + // raw UTF-8 that, e.g., might not map to iso-8859-1 |
|
423 | + // TODO: this can also be handled with xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, "ISO-8859-1"); |
|
424 | + if($this->decode_utf8){ |
|
425 | + $data = utf8_decode($data); |
|
426 | + } |
|
427 | + } |
|
428 | 428 | $this->message[$pos]['cdata'] .= $data; |
429 | 429 | // for doclit |
430 | 430 | if($this->status == 'header'){ |
431 | - $this->responseHeaders .= $data; |
|
431 | + $this->responseHeaders .= $data; |
|
432 | 432 | } else { |
433 | - $this->document .= $data; |
|
433 | + $this->document .= $data; |
|
434 | 434 | } |
435 | - } |
|
435 | + } |
|
436 | 436 | |
437 | - /** |
|
438 | - * get the parsed message (SOAP Body) |
|
439 | - * |
|
440 | - * @return mixed |
|
441 | - * @access public |
|
442 | - * @deprecated use get_soapbody instead |
|
443 | - */ |
|
444 | - function get_response(){ |
|
445 | - return $this->soapresponse; |
|
446 | - } |
|
437 | + /** |
|
438 | + * get the parsed message (SOAP Body) |
|
439 | + * |
|
440 | + * @return mixed |
|
441 | + * @access public |
|
442 | + * @deprecated use get_soapbody instead |
|
443 | + */ |
|
444 | + function get_response(){ |
|
445 | + return $this->soapresponse; |
|
446 | + } |
|
447 | 447 | |
448 | - /** |
|
449 | - * get the parsed SOAP Body (NULL if there was none) |
|
450 | - * |
|
451 | - * @return mixed |
|
452 | - * @access public |
|
453 | - */ |
|
454 | - function get_soapbody(){ |
|
455 | - return $this->soapresponse; |
|
456 | - } |
|
448 | + /** |
|
449 | + * get the parsed SOAP Body (NULL if there was none) |
|
450 | + * |
|
451 | + * @return mixed |
|
452 | + * @access public |
|
453 | + */ |
|
454 | + function get_soapbody(){ |
|
455 | + return $this->soapresponse; |
|
456 | + } |
|
457 | 457 | |
458 | - /** |
|
459 | - * get the parsed SOAP Header (NULL if there was none) |
|
460 | - * |
|
461 | - * @return mixed |
|
462 | - * @access public |
|
463 | - */ |
|
464 | - function get_soapheader(){ |
|
465 | - return $this->soapheader; |
|
466 | - } |
|
458 | + /** |
|
459 | + * get the parsed SOAP Header (NULL if there was none) |
|
460 | + * |
|
461 | + * @return mixed |
|
462 | + * @access public |
|
463 | + */ |
|
464 | + function get_soapheader(){ |
|
465 | + return $this->soapheader; |
|
466 | + } |
|
467 | 467 | |
468 | - /** |
|
469 | - * get the unparsed SOAP Header |
|
470 | - * |
|
471 | - * @return string XML or empty if no Header |
|
472 | - * @access public |
|
473 | - */ |
|
474 | - function getHeaders(){ |
|
475 | - return $this->responseHeaders; |
|
476 | - } |
|
468 | + /** |
|
469 | + * get the unparsed SOAP Header |
|
470 | + * |
|
471 | + * @return string XML or empty if no Header |
|
472 | + * @access public |
|
473 | + */ |
|
474 | + function getHeaders(){ |
|
475 | + return $this->responseHeaders; |
|
476 | + } |
|
477 | 477 | |
478 | - /** |
|
479 | - * decodes simple types into PHP variables |
|
480 | - * |
|
481 | - * @param string $value value to decode |
|
482 | - * @param string $type XML type to decode |
|
483 | - * @param string $typens XML type namespace to decode |
|
484 | - * @return mixed PHP value |
|
485 | - * @access private |
|
486 | - */ |
|
487 | - function decodeSimple($value, $type, $typens) { |
|
488 | - // TODO: use the namespace! |
|
489 | - if ((!isset($type)) || $type == 'string' || $type == 'long' || $type == 'unsignedLong') { |
|
490 | - return (string) $value; |
|
491 | - } |
|
492 | - if ($type == 'int' || $type == 'integer' || $type == 'short' || $type == 'byte') { |
|
493 | - return (int) $value; |
|
494 | - } |
|
495 | - if ($type == 'float' || $type == 'double' || $type == 'decimal') { |
|
496 | - return (double) $value; |
|
497 | - } |
|
498 | - if ($type == 'boolean') { |
|
499 | - if (strtolower($value) == 'false' || strtolower($value) == 'f') { |
|
500 | - return false; |
|
501 | - } |
|
502 | - return (boolean) $value; |
|
503 | - } |
|
504 | - if ($type == 'base64' || $type == 'base64Binary') { |
|
505 | - $this->debug('Decode base64 value'); |
|
506 | - return base64_decode($value); |
|
507 | - } |
|
508 | - // obscure numeric types |
|
509 | - if ($type == 'nonPositiveInteger' || $type == 'negativeInteger' |
|
510 | - || $type == 'nonNegativeInteger' || $type == 'positiveInteger' |
|
511 | - || $type == 'unsignedInt' |
|
512 | - || $type == 'unsignedShort' || $type == 'unsignedByte') { |
|
513 | - return (int) $value; |
|
514 | - } |
|
515 | - // bogus: parser treats array with no elements as a simple type |
|
516 | - if ($type == 'array') { |
|
517 | - return array(); |
|
518 | - } |
|
519 | - // everything else |
|
520 | - return (string) $value; |
|
521 | - } |
|
478 | + /** |
|
479 | + * decodes simple types into PHP variables |
|
480 | + * |
|
481 | + * @param string $value value to decode |
|
482 | + * @param string $type XML type to decode |
|
483 | + * @param string $typens XML type namespace to decode |
|
484 | + * @return mixed PHP value |
|
485 | + * @access private |
|
486 | + */ |
|
487 | + function decodeSimple($value, $type, $typens) { |
|
488 | + // TODO: use the namespace! |
|
489 | + if ((!isset($type)) || $type == 'string' || $type == 'long' || $type == 'unsignedLong') { |
|
490 | + return (string) $value; |
|
491 | + } |
|
492 | + if ($type == 'int' || $type == 'integer' || $type == 'short' || $type == 'byte') { |
|
493 | + return (int) $value; |
|
494 | + } |
|
495 | + if ($type == 'float' || $type == 'double' || $type == 'decimal') { |
|
496 | + return (double) $value; |
|
497 | + } |
|
498 | + if ($type == 'boolean') { |
|
499 | + if (strtolower($value) == 'false' || strtolower($value) == 'f') { |
|
500 | + return false; |
|
501 | + } |
|
502 | + return (boolean) $value; |
|
503 | + } |
|
504 | + if ($type == 'base64' || $type == 'base64Binary') { |
|
505 | + $this->debug('Decode base64 value'); |
|
506 | + return base64_decode($value); |
|
507 | + } |
|
508 | + // obscure numeric types |
|
509 | + if ($type == 'nonPositiveInteger' || $type == 'negativeInteger' |
|
510 | + || $type == 'nonNegativeInteger' || $type == 'positiveInteger' |
|
511 | + || $type == 'unsignedInt' |
|
512 | + || $type == 'unsignedShort' || $type == 'unsignedByte') { |
|
513 | + return (int) $value; |
|
514 | + } |
|
515 | + // bogus: parser treats array with no elements as a simple type |
|
516 | + if ($type == 'array') { |
|
517 | + return array(); |
|
518 | + } |
|
519 | + // everything else |
|
520 | + return (string) $value; |
|
521 | + } |
|
522 | 522 | |
523 | - /** |
|
524 | - * builds response structures for compound values (arrays/structs) |
|
525 | - * and scalars |
|
526 | - * |
|
527 | - * @param integer $pos position in node tree |
|
528 | - * @return mixed PHP value |
|
529 | - * @access private |
|
530 | - */ |
|
531 | - function buildVal($pos){ |
|
532 | - if(!isset($this->message[$pos]['type'])){ |
|
533 | - $this->message[$pos]['type'] = ''; |
|
534 | - } |
|
535 | - $this->debug('in buildVal() for '.$this->message[$pos]['name']."(pos $pos) of type ".$this->message[$pos]['type']); |
|
536 | - // if there are children... |
|
537 | - if($this->message[$pos]['children'] != ''){ |
|
538 | - $this->debug('in buildVal, there are children'); |
|
539 | - $children = explode('|',$this->message[$pos]['children']); |
|
540 | - array_shift($children); // knock off empty |
|
541 | - // md array |
|
542 | - if(isset($this->message[$pos]['arrayCols']) && $this->message[$pos]['arrayCols'] != ''){ |
|
543 | - $r=0; // rowcount |
|
544 | - $c=0; // colcount |
|
545 | - foreach($children as $child_pos){ |
|
546 | - $this->debug("in buildVal, got an MD array element: $r, $c"); |
|
547 | - $params[$r][] = $this->message[$child_pos]['result']; |
|
548 | - $c++; |
|
549 | - if($c == $this->message[$pos]['arrayCols']){ |
|
550 | - $c = 0; |
|
551 | - $r++; |
|
552 | - } |
|
523 | + /** |
|
524 | + * builds response structures for compound values (arrays/structs) |
|
525 | + * and scalars |
|
526 | + * |
|
527 | + * @param integer $pos position in node tree |
|
528 | + * @return mixed PHP value |
|
529 | + * @access private |
|
530 | + */ |
|
531 | + function buildVal($pos){ |
|
532 | + if(!isset($this->message[$pos]['type'])){ |
|
533 | + $this->message[$pos]['type'] = ''; |
|
534 | + } |
|
535 | + $this->debug('in buildVal() for '.$this->message[$pos]['name']."(pos $pos) of type ".$this->message[$pos]['type']); |
|
536 | + // if there are children... |
|
537 | + if($this->message[$pos]['children'] != ''){ |
|
538 | + $this->debug('in buildVal, there are children'); |
|
539 | + $children = explode('|',$this->message[$pos]['children']); |
|
540 | + array_shift($children); // knock off empty |
|
541 | + // md array |
|
542 | + if(isset($this->message[$pos]['arrayCols']) && $this->message[$pos]['arrayCols'] != ''){ |
|
543 | + $r=0; // rowcount |
|
544 | + $c=0; // colcount |
|
545 | + foreach($children as $child_pos){ |
|
546 | + $this->debug("in buildVal, got an MD array element: $r, $c"); |
|
547 | + $params[$r][] = $this->message[$child_pos]['result']; |
|
548 | + $c++; |
|
549 | + if($c == $this->message[$pos]['arrayCols']){ |
|
550 | + $c = 0; |
|
551 | + $r++; |
|
552 | + } |
|
553 | 553 | } |
554 | 554 | // array |
555 | - } elseif($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array'){ |
|
555 | + } elseif($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array'){ |
|
556 | 556 | $this->debug('in buildVal, adding array '.$this->message[$pos]['name']); |
557 | 557 | foreach($children as $child_pos){ |
558 | - $params[] = &$this->message[$child_pos]['result']; |
|
558 | + $params[] = &$this->message[$child_pos]['result']; |
|
559 | 559 | } |
560 | 560 | // apache Map type: java hashtable |
561 | 561 | } elseif($this->message[$pos]['type'] == 'Map' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap'){ |
562 | 562 | $this->debug('in buildVal, Java Map '.$this->message[$pos]['name']); |
563 | 563 | foreach($children as $child_pos){ |
564 | - $kv = explode("|",$this->message[$child_pos]['children']); |
|
565 | - $params[$this->message[$kv[1]]['result']] = &$this->message[$kv[2]]['result']; |
|
564 | + $kv = explode("|",$this->message[$child_pos]['children']); |
|
565 | + $params[$this->message[$kv[1]]['result']] = &$this->message[$kv[2]]['result']; |
|
566 | 566 | } |
567 | 567 | // generic compound type |
568 | 568 | //} elseif($this->message[$pos]['type'] == 'SOAPStruct' || $this->message[$pos]['type'] == 'struct') { |
569 | - } else { |
|
570 | - // Apache Vector type: treat as an array |
|
569 | + } else { |
|
570 | + // Apache Vector type: treat as an array |
|
571 | 571 | $this->debug('in buildVal, adding Java Vector or generic compound type '.$this->message[$pos]['name']); |
572 | - if ($this->message[$pos]['type'] == 'Vector' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap') { |
|
573 | - $notstruct = 1; |
|
574 | - } else { |
|
575 | - $notstruct = 0; |
|
576 | - } |
|
577 | - // |
|
578 | - foreach($children as $child_pos){ |
|
579 | - if($notstruct){ |
|
580 | - $params[] = &$this->message[$child_pos]['result']; |
|
581 | - } else { |
|
582 | - if (isset($params[$this->message[$child_pos]['name']])) { |
|
583 | - // de-serialize repeated element name into an array |
|
584 | - if ((!is_array($params[$this->message[$child_pos]['name']])) || (!isset($params[$this->message[$child_pos]['name']][0]))) { |
|
585 | - $params[$this->message[$child_pos]['name']] = array($params[$this->message[$child_pos]['name']]); |
|
586 | - } |
|
587 | - $params[$this->message[$child_pos]['name']][] = &$this->message[$child_pos]['result']; |
|
588 | - } else { |
|
589 | - $params[$this->message[$child_pos]['name']] = &$this->message[$child_pos]['result']; |
|
590 | - } |
|
591 | - } |
|
572 | + if ($this->message[$pos]['type'] == 'Vector' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap') { |
|
573 | + $notstruct = 1; |
|
574 | + } else { |
|
575 | + $notstruct = 0; |
|
592 | 576 | } |
593 | - } |
|
594 | - if (isset($this->message[$pos]['xattrs'])) { |
|
577 | + // |
|
578 | + foreach($children as $child_pos){ |
|
579 | + if($notstruct){ |
|
580 | + $params[] = &$this->message[$child_pos]['result']; |
|
581 | + } else { |
|
582 | + if (isset($params[$this->message[$child_pos]['name']])) { |
|
583 | + // de-serialize repeated element name into an array |
|
584 | + if ((!is_array($params[$this->message[$child_pos]['name']])) || (!isset($params[$this->message[$child_pos]['name']][0]))) { |
|
585 | + $params[$this->message[$child_pos]['name']] = array($params[$this->message[$child_pos]['name']]); |
|
586 | + } |
|
587 | + $params[$this->message[$child_pos]['name']][] = &$this->message[$child_pos]['result']; |
|
588 | + } else { |
|
589 | + $params[$this->message[$child_pos]['name']] = &$this->message[$child_pos]['result']; |
|
590 | + } |
|
591 | + } |
|
592 | + } |
|
593 | + } |
|
594 | + if (isset($this->message[$pos]['xattrs'])) { |
|
595 | 595 | $this->debug('in buildVal, handling attributes'); |
596 | - foreach ($this->message[$pos]['xattrs'] as $n => $v) { |
|
597 | - $params[$n] = $v; |
|
598 | - } |
|
599 | - } |
|
600 | - // handle simpleContent |
|
601 | - if (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') { |
|
596 | + foreach ($this->message[$pos]['xattrs'] as $n => $v) { |
|
597 | + $params[$n] = $v; |
|
598 | + } |
|
599 | + } |
|
600 | + // handle simpleContent |
|
601 | + if (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') { |
|
602 | 602 | $this->debug('in buildVal, handling simpleContent'); |
603 | - if (isset($this->message[$pos]['type'])) { |
|
604 | - $params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
605 | - } else { |
|
606 | - $parent = $this->message[$pos]['parent']; |
|
607 | - if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
608 | - $params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
609 | - } else { |
|
610 | - $params['!'] = $this->message[$pos]['cdata']; |
|
611 | - } |
|
612 | - } |
|
613 | - } |
|
614 | - $ret = is_array($params) ? $params : array(); |
|
615 | - $this->debug('in buildVal, return:'); |
|
616 | - //$this->appendDebug($this->varDump($ret)); |
|
617 | - return $ret; |
|
618 | - } else { |
|
619 | - $this->debug('in buildVal, no children, building scalar'); |
|
620 | - $cdata = isset($this->message[$pos]['cdata']) ? $this->message[$pos]['cdata'] : ''; |
|
621 | - if (isset($this->message[$pos]['type'])) { |
|
622 | - $ret = $this->decodeSimple($cdata, $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
623 | - $this->debug("in buildVal, return: $ret"); |
|
624 | - return $ret; |
|
625 | - } |
|
626 | - $parent = $this->message[$pos]['parent']; |
|
627 | - if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
628 | - $ret = $this->decodeSimple($cdata, $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
629 | - $this->debug("in buildVal, return: $ret"); |
|
630 | - return $ret; |
|
631 | - } |
|
632 | - $ret = $this->message[$pos]['cdata']; |
|
633 | - $this->debug("in buildVal, return: $ret"); |
|
634 | - return $ret; |
|
635 | - } |
|
636 | - } |
|
603 | + if (isset($this->message[$pos]['type'])) { |
|
604 | + $params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
605 | + } else { |
|
606 | + $parent = $this->message[$pos]['parent']; |
|
607 | + if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
608 | + $params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
609 | + } else { |
|
610 | + $params['!'] = $this->message[$pos]['cdata']; |
|
611 | + } |
|
612 | + } |
|
613 | + } |
|
614 | + $ret = is_array($params) ? $params : array(); |
|
615 | + $this->debug('in buildVal, return:'); |
|
616 | + //$this->appendDebug($this->varDump($ret)); |
|
617 | + return $ret; |
|
618 | + } else { |
|
619 | + $this->debug('in buildVal, no children, building scalar'); |
|
620 | + $cdata = isset($this->message[$pos]['cdata']) ? $this->message[$pos]['cdata'] : ''; |
|
621 | + if (isset($this->message[$pos]['type'])) { |
|
622 | + $ret = $this->decodeSimple($cdata, $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
623 | + $this->debug("in buildVal, return: $ret"); |
|
624 | + return $ret; |
|
625 | + } |
|
626 | + $parent = $this->message[$pos]['parent']; |
|
627 | + if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
628 | + $ret = $this->decodeSimple($cdata, $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
629 | + $this->debug("in buildVal, return: $ret"); |
|
630 | + return $ret; |
|
631 | + } |
|
632 | + $ret = $this->message[$pos]['cdata']; |
|
633 | + $this->debug("in buildVal, return: $ret"); |
|
634 | + return $ret; |
|
635 | + } |
|
636 | + } |
|
637 | 637 | } |
638 | 638 | |
639 | 639 | /** |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | <option value = "%">--</option> |
198 | 198 | <?php |
199 | 199 | echo Display :: get_alphabet_options(); |
200 | - ?> |
|
200 | + ?> |
|
201 | 201 | </select> |
202 | 202 | </td> |
203 | 203 | <td align="center"> </td> |
@@ -207,31 +207,31 @@ discard block |
||
207 | 207 | <td align="center"> |
208 | 208 | <div id="content_source"> |
209 | 209 | <?php |
210 | - if (!($add_type=='multiple')) { |
|
210 | + if (!($add_type=='multiple')) { |
|
211 | 211 | ?> |
212 | 212 | <input type="text" id="user_to_add" onkeyup="xajax_search_users(this.value,'single')" /> |
213 | 213 | <div id="ajax_list_users_single"></div> |
214 | 214 | <?php |
215 | - } else { |
|
216 | - ?> |
|
215 | + } else { |
|
216 | + ?> |
|
217 | 217 | <div id="ajax_list_multiple"> |
218 | 218 | <?php echo Display::select('session_not_in_promotion_name',$session_not_in_promotion, '',array('style'=>'width:360px', 'multiple'=>'multiple','id'=>'session_not_in_promotion','size'=>'15px'),false); ?> |
219 | 219 | </div> |
220 | 220 | <?php |
221 | - } |
|
222 | - ?> |
|
221 | + } |
|
222 | + ?> |
|
223 | 223 | </div> |
224 | 224 | </td> |
225 | 225 | <td width="10%" valign="middle" align="center"> |
226 | 226 | <?php |
227 | - if ($ajax_search) { |
|
228 | - ?> |
|
227 | + if ($ajax_search) { |
|
228 | + ?> |
|
229 | 229 | <button class="btn btn-default" type="button" onclick="remove_item(document.getElementById('session_in_promotion'))" > |
230 | 230 | <em class="fa fa-arrow-left"></em> |
231 | 231 | </button> |
232 | 232 | <?php |
233 | - } else { |
|
234 | - ?> |
|
233 | + } else { |
|
234 | + ?> |
|
235 | 235 | <button class="btn btn-default" type="button" onclick="moveItem(document.getElementById('session_not_in_promotion'), document.getElementById('session_in_promotion'))" onclick="moveItem(document.getElementById('session_not_in_promotion'), document.getElementById('session_in_promotion'))"> |
236 | 236 | <em class="fa fa-arrow-right"></em> |
237 | 237 | </button> |
@@ -240,8 +240,8 @@ discard block |
||
240 | 240 | <em class="fa fa-arrow-left"></em> |
241 | 241 | </button> |
242 | 242 | <?php |
243 | - } |
|
244 | - ?> |
|
243 | + } |
|
244 | + ?> |
|
245 | 245 | <br /><br /><br /><br /><br /><br /> |
246 | 246 | </td> |
247 | 247 | <td align="center"> |
@@ -24,10 +24,10 @@ discard block |
||
24 | 24 | */ |
25 | 25 | |
26 | 26 | function unset_session_resources() { |
27 | - $_SESSION['addedresource']=''; |
|
28 | - $_SESSION['addedresourceid']=''; |
|
29 | - Session::erase('addedresource'); |
|
30 | - Session::erase('addedresourceid'); |
|
27 | + $_SESSION['addedresource']=''; |
|
28 | + $_SESSION['addedresourceid']=''; |
|
29 | + Session::erase('addedresource'); |
|
30 | + Session::erase('addedresourceid'); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -35,24 +35,24 @@ discard block |
||
35 | 35 | */ |
36 | 36 | function show_folder_up() |
37 | 37 | { |
38 | - global $folder; |
|
39 | - global $source_id, $action, $learnpath_id, $chapter_id, $originalresource; |
|
40 | - |
|
41 | - $level = get_levels($folder); |
|
42 | - |
|
43 | - if ($level == 1) |
|
44 | - { |
|
45 | - echo "<a href='".api_get_self()."?content=Document&source_forum=".$_GET['source_forum']."&source_id=$source_id&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no'><img src='../img/folder_up.gif' border='0' />".get_lang('LevelUp')."</a>"; |
|
46 | - } |
|
47 | - if ($level and $level != 0 and $level != 1) |
|
48 | - { |
|
49 | - $folder_up=$folder; |
|
50 | - $folder_temp=explode('/',$folder); |
|
51 | - $last=count($folder_temp)-1; |
|
52 | - unset($folder_temp[$last]); |
|
53 | - $folder_up=implode('/',$folder_temp); |
|
54 | - echo "<a href='".api_get_self()."?content=Document&source_forum=".$_GET['source_forum']."&folder=$folder_up&source_id=$source_id&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no'><img src='../img/folder_up.gif' border='0' />".get_lang('LevelUp')."</a>"; |
|
55 | - } |
|
38 | + global $folder; |
|
39 | + global $source_id, $action, $learnpath_id, $chapter_id, $originalresource; |
|
40 | + |
|
41 | + $level = get_levels($folder); |
|
42 | + |
|
43 | + if ($level == 1) |
|
44 | + { |
|
45 | + echo "<a href='".api_get_self()."?content=Document&source_forum=".$_GET['source_forum']."&source_id=$source_id&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no'><img src='../img/folder_up.gif' border='0' />".get_lang('LevelUp')."</a>"; |
|
46 | + } |
|
47 | + if ($level and $level != 0 and $level != 1) |
|
48 | + { |
|
49 | + $folder_up=$folder; |
|
50 | + $folder_temp=explode('/',$folder); |
|
51 | + $last=count($folder_temp)-1; |
|
52 | + unset($folder_temp[$last]); |
|
53 | + $folder_up=implode('/',$folder_temp); |
|
54 | + echo "<a href='".api_get_self()."?content=Document&source_forum=".$_GET['source_forum']."&folder=$folder_up&source_id=$source_id&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no'><img src='../img/folder_up.gif' border='0' />".get_lang('LevelUp')."</a>"; |
|
55 | + } |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -61,23 +61,23 @@ discard block |
||
61 | 61 | */ |
62 | 62 | function show_documents($folder) |
63 | 63 | { |
64 | - global $_course; |
|
65 | - global $source_id, $action, $learnpath_id, $chapter_id, $originalresource; |
|
66 | - |
|
67 | - // documents are a special case: the teacher can add an invisible document (it will be viewable by the user) |
|
68 | - // other tools do not have this feature. This only counts |
|
69 | - if (api_is_allowed_to_edit()) |
|
70 | - { |
|
71 | - $visibility="ip.visibility<>'2'"; |
|
72 | - } |
|
73 | - else |
|
74 | - { |
|
75 | - $visibility="ip.visibility='1'"; |
|
76 | - } |
|
77 | - |
|
78 | - $item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY); |
|
79 | - $document_table = Database::get_course_table(TABLE_DOCUMENT); |
|
80 | - $sql = "SELECT * from $document_table docs, $item_property_table ip |
|
64 | + global $_course; |
|
65 | + global $source_id, $action, $learnpath_id, $chapter_id, $originalresource; |
|
66 | + |
|
67 | + // documents are a special case: the teacher can add an invisible document (it will be viewable by the user) |
|
68 | + // other tools do not have this feature. This only counts |
|
69 | + if (api_is_allowed_to_edit()) |
|
70 | + { |
|
71 | + $visibility="ip.visibility<>'2'"; |
|
72 | + } |
|
73 | + else |
|
74 | + { |
|
75 | + $visibility="ip.visibility='1'"; |
|
76 | + } |
|
77 | + |
|
78 | + $item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY); |
|
79 | + $document_table = Database::get_course_table(TABLE_DOCUMENT); |
|
80 | + $sql = "SELECT * from $document_table docs, $item_property_table ip |
|
81 | 81 | WHERE |
82 | 82 | docs.id=ip.ref AND |
83 | 83 | ip.tool = '".TOOL_DOCUMENT."' AND |
@@ -85,104 +85,104 @@ discard block |
||
85 | 85 | (ip.to_group_id = 0 OR i.to_group_id IS NULL) AND |
86 | 86 | ip.to_user_id IS NULL |
87 | 87 | ORDER BY docs.path ASC"; |
88 | - $result=Database::query($sql); |
|
89 | - while ($row=Database::fetch_array($result)) |
|
90 | - { |
|
91 | - if (!$folder) |
|
92 | - { |
|
93 | - if (get_levels($row['path'])-1==1) |
|
94 | - { |
|
95 | - // showing the right icon |
|
96 | - if (file_or_folder($row['path'])) |
|
97 | - { |
|
98 | - echo '<img src="../img/file.gif" align="middle" />'; |
|
99 | - } |
|
100 | - else |
|
101 | - { |
|
102 | - $image = choose_image($row['path']); |
|
103 | - echo "<img src=\"../img/$image\" align=\"middle\" />"; |
|
104 | - } |
|
105 | - |
|
106 | - // folders should be clickable |
|
107 | - if (file_or_folder($row['path'])) |
|
108 | - { |
|
109 | - echo "<a href='".api_get_self()."?content=Document"; |
|
110 | - echo "&folder=".substr($row['path'],1)."&source_id=$source_id&source_forum=".$_GET['source_forum']."&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no'>".substr($row['path'],1).'</a><br />'; |
|
111 | - } |
|
112 | - else |
|
113 | - { |
|
114 | - echo substr($row['path'],1).' '; |
|
115 | - echo showorhide_addresourcelink('Document',$row['id']); |
|
116 | - echo '<br />'; |
|
117 | - } |
|
118 | - } |
|
119 | - } |
|
120 | - else |
|
121 | - { |
|
122 | - // we calculate the level we are in by using the $folder in the url |
|
123 | - // we put +1 because it does not start with an / and in the database it does |
|
124 | - $level=get_levels($folder)+1; |
|
125 | - |
|
126 | - // we calculate each level of the database entry |
|
127 | - $file_level=get_levels($row['path'])-1; |
|
128 | - // if the level of the database entry is equal to the level we ar in, we put it into an array |
|
129 | - // as this is a potential good entry |
|
130 | - if ($file_level==$level) |
|
131 | - { |
|
132 | - $good_paths[]=$row['path']; |
|
133 | - $good_ids[]=$row['id']; |
|
134 | - } |
|
135 | - //$haystack=$row['path']; |
|
136 | - //$conform_folder=strstr($haystack, $folder); |
|
137 | - //if (str_replace($folder.'/','',$conform_folder)!==$folder) |
|
138 | - // { |
|
139 | - // $good_folders[]=$row['path']; |
|
140 | - //echo str_replace($folder.'/','',$conform_folder); |
|
141 | - // echo '<br />'; |
|
142 | - // }// if (str_replace($folder.'/','',$conform_folder)!==$folder) |
|
143 | - } // else (if (!$folder)) |
|
144 | - } //while ($row=Database::fetch_array($result)) |
|
145 | - |
|
146 | - // this is code for the case that we are in a subfolder |
|
147 | - if ($good_paths) |
|
148 | - { |
|
149 | - // we have all the potential good database entries, the good ones are those that start with $folder |
|
150 | - foreach ($good_paths as $path) |
|
151 | - { |
|
152 | - if (strstr($path,$folder)) |
|
153 | - { |
|
154 | - $good_key=key($good_paths); |
|
155 | - // showing the right icon |
|
156 | - if (file_or_folder($path)) |
|
157 | - { |
|
158 | - echo '<img src="../img/file.gif" align="middle" />'; |
|
159 | - } |
|
160 | - else |
|
161 | - { |
|
162 | - $image = choose_image($path); |
|
163 | - echo "<img src=\"../img/$image\" align=\"middle\" />"; |
|
164 | - } |
|
165 | - |
|
166 | - // folders should be clickable |
|
167 | - if (file_or_folder($path)) |
|
168 | - { |
|
169 | - $path=substr($path,1); // remove the first / in folder_up |
|
170 | - $uri=str_replace($folder,$path,$_SERVER['REQUEST_URI']); |
|
171 | - $newuri=str_replace('add=','addnot=',$uri); |
|
172 | - //using the correct name of the folder |
|
173 | - $folder_name=str_replace($folder.'/','',$path); |
|
174 | - echo "<a href='$newuri'>".$folder_name.'</a><br />'; |
|
175 | - } |
|
176 | - else |
|
177 | - { |
|
178 | - echo str_replace("/$folder/", '',$path).' '; |
|
179 | - echo showorhide_addresourcelink('Document',$good_ids[$good_key]); |
|
180 | - echo '<br />'; |
|
181 | - } |
|
182 | - } |
|
183 | - next($good_paths); |
|
184 | - } |
|
185 | - } |
|
88 | + $result=Database::query($sql); |
|
89 | + while ($row=Database::fetch_array($result)) |
|
90 | + { |
|
91 | + if (!$folder) |
|
92 | + { |
|
93 | + if (get_levels($row['path'])-1==1) |
|
94 | + { |
|
95 | + // showing the right icon |
|
96 | + if (file_or_folder($row['path'])) |
|
97 | + { |
|
98 | + echo '<img src="../img/file.gif" align="middle" />'; |
|
99 | + } |
|
100 | + else |
|
101 | + { |
|
102 | + $image = choose_image($row['path']); |
|
103 | + echo "<img src=\"../img/$image\" align=\"middle\" />"; |
|
104 | + } |
|
105 | + |
|
106 | + // folders should be clickable |
|
107 | + if (file_or_folder($row['path'])) |
|
108 | + { |
|
109 | + echo "<a href='".api_get_self()."?content=Document"; |
|
110 | + echo "&folder=".substr($row['path'],1)."&source_id=$source_id&source_forum=".$_GET['source_forum']."&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no'>".substr($row['path'],1).'</a><br />'; |
|
111 | + } |
|
112 | + else |
|
113 | + { |
|
114 | + echo substr($row['path'],1).' '; |
|
115 | + echo showorhide_addresourcelink('Document',$row['id']); |
|
116 | + echo '<br />'; |
|
117 | + } |
|
118 | + } |
|
119 | + } |
|
120 | + else |
|
121 | + { |
|
122 | + // we calculate the level we are in by using the $folder in the url |
|
123 | + // we put +1 because it does not start with an / and in the database it does |
|
124 | + $level=get_levels($folder)+1; |
|
125 | + |
|
126 | + // we calculate each level of the database entry |
|
127 | + $file_level=get_levels($row['path'])-1; |
|
128 | + // if the level of the database entry is equal to the level we ar in, we put it into an array |
|
129 | + // as this is a potential good entry |
|
130 | + if ($file_level==$level) |
|
131 | + { |
|
132 | + $good_paths[]=$row['path']; |
|
133 | + $good_ids[]=$row['id']; |
|
134 | + } |
|
135 | + //$haystack=$row['path']; |
|
136 | + //$conform_folder=strstr($haystack, $folder); |
|
137 | + //if (str_replace($folder.'/','',$conform_folder)!==$folder) |
|
138 | + // { |
|
139 | + // $good_folders[]=$row['path']; |
|
140 | + //echo str_replace($folder.'/','',$conform_folder); |
|
141 | + // echo '<br />'; |
|
142 | + // }// if (str_replace($folder.'/','',$conform_folder)!==$folder) |
|
143 | + } // else (if (!$folder)) |
|
144 | + } //while ($row=Database::fetch_array($result)) |
|
145 | + |
|
146 | + // this is code for the case that we are in a subfolder |
|
147 | + if ($good_paths) |
|
148 | + { |
|
149 | + // we have all the potential good database entries, the good ones are those that start with $folder |
|
150 | + foreach ($good_paths as $path) |
|
151 | + { |
|
152 | + if (strstr($path,$folder)) |
|
153 | + { |
|
154 | + $good_key=key($good_paths); |
|
155 | + // showing the right icon |
|
156 | + if (file_or_folder($path)) |
|
157 | + { |
|
158 | + echo '<img src="../img/file.gif" align="middle" />'; |
|
159 | + } |
|
160 | + else |
|
161 | + { |
|
162 | + $image = choose_image($path); |
|
163 | + echo "<img src=\"../img/$image\" align=\"middle\" />"; |
|
164 | + } |
|
165 | + |
|
166 | + // folders should be clickable |
|
167 | + if (file_or_folder($path)) |
|
168 | + { |
|
169 | + $path=substr($path,1); // remove the first / in folder_up |
|
170 | + $uri=str_replace($folder,$path,$_SERVER['REQUEST_URI']); |
|
171 | + $newuri=str_replace('add=','addnot=',$uri); |
|
172 | + //using the correct name of the folder |
|
173 | + $folder_name=str_replace($folder.'/','',$path); |
|
174 | + echo "<a href='$newuri'>".$folder_name.'</a><br />'; |
|
175 | + } |
|
176 | + else |
|
177 | + { |
|
178 | + echo str_replace("/$folder/", '',$path).' '; |
|
179 | + echo showorhide_addresourcelink('Document',$good_ids[$good_key]); |
|
180 | + echo '<br />'; |
|
181 | + } |
|
182 | + } |
|
183 | + next($good_paths); |
|
184 | + } |
|
185 | + } |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
@@ -193,13 +193,13 @@ discard block |
||
193 | 193 | */ |
194 | 194 | function file_or_folder($filefolder) |
195 | 195 | { |
196 | - global $_course; |
|
197 | - global $baseServDir; |
|
196 | + global $_course; |
|
197 | + global $baseServDir; |
|
198 | 198 | |
199 | - $courseDir = $_course['path'].'/document'; |
|
200 | - $baseWorkDir = api_get_path(SYS_COURSE_PATH).$courseDir; |
|
199 | + $courseDir = $_course['path'].'/document'; |
|
200 | + $baseWorkDir = api_get_path(SYS_COURSE_PATH).$courseDir; |
|
201 | 201 | |
202 | - return (is_dir($baseWorkDir.$filefolder) ? 1 : 0); |
|
202 | + return (is_dir($baseWorkDir.$filefolder) ? 1 : 0); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | /** |
@@ -210,23 +210,23 @@ discard block |
||
210 | 210 | */ |
211 | 211 | function store_resources($source_type, $source_id) |
212 | 212 | { |
213 | - global $_course; |
|
214 | - $resource_table = Database::get_course_table(TABLE_LINKED_RESOURCES); |
|
215 | - |
|
216 | - $addedresource = $_SESSION['addedresource']; |
|
217 | - $addedresourceid = $_SESSION['addedresourceid']; |
|
218 | - if ($_SESSION['addedresource']) |
|
219 | - { |
|
220 | - foreach ($addedresource as $resource_type) |
|
221 | - { |
|
222 | - $sql="INSERT INTO $resource_table (source_type, source_id, resource_type, resource_id) VALUES ('$source_type', '$source_id', '$resource_type', '".$addedresourceid[key($addedresource)]."')"; |
|
223 | - Database::query($sql); |
|
224 | - $i=key($addedresource); |
|
225 | - next($addedresource); |
|
226 | - } |
|
227 | - $_SESSION['addedresource']=''; |
|
228 | - $_SESSION['addedresourceid']=''; |
|
229 | - } |
|
213 | + global $_course; |
|
214 | + $resource_table = Database::get_course_table(TABLE_LINKED_RESOURCES); |
|
215 | + |
|
216 | + $addedresource = $_SESSION['addedresource']; |
|
217 | + $addedresourceid = $_SESSION['addedresourceid']; |
|
218 | + if ($_SESSION['addedresource']) |
|
219 | + { |
|
220 | + foreach ($addedresource as $resource_type) |
|
221 | + { |
|
222 | + $sql="INSERT INTO $resource_table (source_type, source_id, resource_type, resource_id) VALUES ('$source_type', '$source_id', '$resource_type', '".$addedresourceid[key($addedresource)]."')"; |
|
223 | + Database::query($sql); |
|
224 | + $i=key($addedresource); |
|
225 | + next($addedresource); |
|
226 | + } |
|
227 | + $_SESSION['addedresource']=''; |
|
228 | + $_SESSION['addedresourceid']=''; |
|
229 | + } |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -240,87 +240,87 @@ discard block |
||
240 | 240 | */ |
241 | 241 | function display_addedresource_link($type, $id, $style='') |
242 | 242 | { |
243 | - global $_course; |
|
243 | + global $_course; |
|
244 | 244 | |
245 | - // styling the link of the added resource |
|
246 | - if ($style <> '') |
|
247 | - { |
|
248 | - $styling = ' class="'.$style.'"'; |
|
249 | - } |
|
245 | + // styling the link of the added resource |
|
246 | + if ($style <> '') |
|
247 | + { |
|
248 | + $styling = ' class="'.$style.'"'; |
|
249 | + } |
|
250 | 250 | |
251 | 251 | $course_id = api_get_course_int_id(); |
252 | 252 | |
253 | - switch ($type) |
|
254 | - { |
|
255 | - case 'Agenda': |
|
256 | - $TABLEAGENDA = Database::get_course_table(TABLE_AGENDA); |
|
257 | - $result = Database::query("SELECT * FROM $TABLEAGENDA WHERE c_id = $course_id AND id=$id"); |
|
258 | - $myrow = Database::fetch_array($result); |
|
259 | - echo '<img src="../img/agenda.gif" align="middle" /> <a href="../calendar/agenda.php"'.$styling.'>'.$myrow['title']."</a><br />\n"; |
|
260 | - break; |
|
261 | - case 'Ad_Valvas': |
|
262 | - $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT); |
|
263 | - $result = Database::query("SELECT * FROM $tbl_announcement WHERE c_id = $course_id AND id=$id"); |
|
264 | - $myrow = Database::fetch_array($result); |
|
265 | - echo '<img src="../img/valves.gif" align="middle" /> <a href="../announcements/announcements.php"'.$styling.'>'.$myrow['title']."</a><br />\n"; |
|
266 | - break; |
|
267 | - case 'Link':Database::get_course_table(TABLE_LINK); |
|
268 | - $result = Database::query("SELECT * FROM $TABLETOOLLINK WHERE c_id = $course_id AND id=$id"); |
|
269 | - $myrow = Database::fetch_array($result); |
|
270 | - echo '<img src="../img/links.gif" align="middle" /> <a href="#" onclick="javascript:window.open(\'../link/link_goto.php?link_id='.$myrow['id'].'&link_url='.urlencode($myrow['url'])."','MyWindow','width=500,height=400,top='+((screen.height-400)/2)+',left='+((screen.width-500)/2)+',scrollbars=1,resizable=1,menubar=1'); return false;\"".$styling.'>'.$myrow['title']."</a><br />\n"; |
|
271 | - break; |
|
272 | - case 'Exercise': |
|
273 | - $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST); |
|
274 | - $result = Database::query("SELECT * FROM $TBL_EXERCICES WHERE c_id = $course_id AND id=$id"); |
|
275 | - $myrow = Database::fetch_array($result); |
|
276 | - echo '<img src="../img/quiz.gif" align="middle" /> <a href="../exercise/exercise_submit.php?exerciseId='.$myrow['id'].'"'.$styling.'>'.$myrow['title']."</a><br />\n"; |
|
277 | - break; |
|
278 | - case 'Forum': |
|
279 | - $TBL_FORUMS = Database::get_course_table(TABLE_FORUM); |
|
280 | - $result = Database::query("SELECT * FROM $TBL_FORUMS WHERE c_id = $course_id AND forum_id=$id"); |
|
281 | - $myrow = Database::fetch_array($result); |
|
282 | - echo '<img src="../img/forum.gif" align="middle" /> <a href="../forum/viewforum.php?forum='.$myrow['forum_id'].'&md5='.$myrow['md5'].'"'.$styling.'>'.$myrow['forum_name']."</a><br />\n"; |
|
283 | - break; |
|
284 | - case 'Thread': //=topics |
|
253 | + switch ($type) |
|
254 | + { |
|
255 | + case 'Agenda': |
|
256 | + $TABLEAGENDA = Database::get_course_table(TABLE_AGENDA); |
|
257 | + $result = Database::query("SELECT * FROM $TABLEAGENDA WHERE c_id = $course_id AND id=$id"); |
|
258 | + $myrow = Database::fetch_array($result); |
|
259 | + echo '<img src="../img/agenda.gif" align="middle" /> <a href="../calendar/agenda.php"'.$styling.'>'.$myrow['title']."</a><br />\n"; |
|
260 | + break; |
|
261 | + case 'Ad_Valvas': |
|
262 | + $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT); |
|
263 | + $result = Database::query("SELECT * FROM $tbl_announcement WHERE c_id = $course_id AND id=$id"); |
|
264 | + $myrow = Database::fetch_array($result); |
|
265 | + echo '<img src="../img/valves.gif" align="middle" /> <a href="../announcements/announcements.php"'.$styling.'>'.$myrow['title']."</a><br />\n"; |
|
266 | + break; |
|
267 | + case 'Link':Database::get_course_table(TABLE_LINK); |
|
268 | + $result = Database::query("SELECT * FROM $TABLETOOLLINK WHERE c_id = $course_id AND id=$id"); |
|
269 | + $myrow = Database::fetch_array($result); |
|
270 | + echo '<img src="../img/links.gif" align="middle" /> <a href="#" onclick="javascript:window.open(\'../link/link_goto.php?link_id='.$myrow['id'].'&link_url='.urlencode($myrow['url'])."','MyWindow','width=500,height=400,top='+((screen.height-400)/2)+',left='+((screen.width-500)/2)+',scrollbars=1,resizable=1,menubar=1'); return false;\"".$styling.'>'.$myrow['title']."</a><br />\n"; |
|
271 | + break; |
|
272 | + case 'Exercise': |
|
273 | + $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST); |
|
274 | + $result = Database::query("SELECT * FROM $TBL_EXERCICES WHERE c_id = $course_id AND id=$id"); |
|
275 | + $myrow = Database::fetch_array($result); |
|
276 | + echo '<img src="../img/quiz.gif" align="middle" /> <a href="../exercise/exercise_submit.php?exerciseId='.$myrow['id'].'"'.$styling.'>'.$myrow['title']."</a><br />\n"; |
|
277 | + break; |
|
278 | + case 'Forum': |
|
279 | + $TBL_FORUMS = Database::get_course_table(TABLE_FORUM); |
|
280 | + $result = Database::query("SELECT * FROM $TBL_FORUMS WHERE c_id = $course_id AND forum_id=$id"); |
|
281 | + $myrow = Database::fetch_array($result); |
|
282 | + echo '<img src="../img/forum.gif" align="middle" /> <a href="../forum/viewforum.php?forum='.$myrow['forum_id'].'&md5='.$myrow['md5'].'"'.$styling.'>'.$myrow['forum_name']."</a><br />\n"; |
|
283 | + break; |
|
284 | + case 'Thread': //=topics |
|
285 | 285 | //deprecated |
286 | - $tbl_posts = $_course['dbNameGlu'].'bb_posts'; |
|
287 | - $tbl_posts_text = $_course['dbNameGlu'].'bb_posts_text'; |
|
288 | - $TBL_FORUMS = $_course['dbNameGlu'].'bb_forums'; |
|
289 | - $result = Database::query("SELECT * FROM $tbl_posts posts, $TBL_FORUMS forum WHERE forum.forum_id=posts.forum_id and post_id=$id"); |
|
290 | - $myrow = Database::fetch_array($result); |
|
291 | - // grabbing the title of the post |
|
292 | - $sql_title = "SELECT * FROM $tbl_posts_text WHERE post_id=".$myrow["post_id"]; |
|
293 | - $result_title = Database::query($sql_title); |
|
294 | - $myrow_title = Database::fetch_array($result_title); |
|
295 | - echo '<img src="../img/forum.gif" align="middle" /> <a href="../forum/viewtopic.php?topic='.$myrow['topic_id'].'&forum='.$myrow['forum_id'].'&md5='.$myrow['md5'].'"'.$styling.'>'.$myrow_title['post_title']."</a><br />\n"; |
|
296 | - break; |
|
297 | - case 'Post': |
|
286 | + $tbl_posts = $_course['dbNameGlu'].'bb_posts'; |
|
287 | + $tbl_posts_text = $_course['dbNameGlu'].'bb_posts_text'; |
|
288 | + $TBL_FORUMS = $_course['dbNameGlu'].'bb_forums'; |
|
289 | + $result = Database::query("SELECT * FROM $tbl_posts posts, $TBL_FORUMS forum WHERE forum.forum_id=posts.forum_id and post_id=$id"); |
|
290 | + $myrow = Database::fetch_array($result); |
|
291 | + // grabbing the title of the post |
|
292 | + $sql_title = "SELECT * FROM $tbl_posts_text WHERE post_id=".$myrow["post_id"]; |
|
293 | + $result_title = Database::query($sql_title); |
|
294 | + $myrow_title = Database::fetch_array($result_title); |
|
295 | + echo '<img src="../img/forum.gif" align="middle" /> <a href="../forum/viewtopic.php?topic='.$myrow['topic_id'].'&forum='.$myrow['forum_id'].'&md5='.$myrow['md5'].'"'.$styling.'>'.$myrow_title['post_title']."</a><br />\n"; |
|
296 | + break; |
|
297 | + case 'Post': |
|
298 | 298 | //deprecated |
299 | - $tbl_post = Database::get_course_table(TABLE_FORUM_POST); |
|
300 | - $tbl_post_text = Database::get_course_table(TOOL_FORUM_POST_TEXT_TABLE); |
|
301 | - $sql = "SELECT * FROM $tbl_post p, $tbl_post_text t WHERE p.post_id = t.post_id AND p.post_id = $id"; |
|
302 | - $result = Database::query($sql); |
|
303 | - $post = Database::fetch_object($result); |
|
304 | - echo '<img src="../img/forum.gif" align="middle" /> <a href="../phpbb/viewtopic.php?topic='.$post->topic_id.'&forum='.$post->forum_id.'"'.$styling.'>'.$post->post_title."</a><br />\n"; |
|
305 | - break; |
|
306 | - case 'Document': |
|
307 | - $dbTable = Database::get_course_table(TABLE_DOCUMENT); |
|
308 | - $result = Database::query("SELECT * FROM $dbTable WHERE c_id = $course_id AND id=$id"); |
|
309 | - $myrow = Database::fetch_array($result); |
|
310 | - $pathname = explode('/',$myrow['path']); // making a correct name for the link |
|
311 | - $last = count($pathname) - 1; // making a correct name for the link |
|
312 | - $filename = $pathname[$last]; // making a correct name for the link |
|
313 | - $image = choose_image($filename); |
|
314 | - $ext = explode('.',$filename); |
|
315 | - $ext = strtolower($ext[sizeof($ext)-1]); |
|
316 | - $myrow['path'] = rawurlencode($myrow['path']); |
|
317 | - $in_frames = in_array($ext, array('htm','html','gif','jpg','jpeg','png')); |
|
318 | - echo '<img src="../img/'.$image.'" align="middle" /> <a href="../document/'.($in_frames ? 'showinframes.php?file=' : 'download.php?doc_url=').$myrow['path'].'"'.$styling.'>'.$filename."</a><br />\n"; |
|
319 | - break; |
|
320 | - case 'Externallink': |
|
321 | - echo '<img src="../img/links.gif" align="middle" /> <a href="'.$id.'"'.$styling.'>'.$id."</a><br />\n"; |
|
322 | - break; |
|
323 | - } |
|
299 | + $tbl_post = Database::get_course_table(TABLE_FORUM_POST); |
|
300 | + $tbl_post_text = Database::get_course_table(TOOL_FORUM_POST_TEXT_TABLE); |
|
301 | + $sql = "SELECT * FROM $tbl_post p, $tbl_post_text t WHERE p.post_id = t.post_id AND p.post_id = $id"; |
|
302 | + $result = Database::query($sql); |
|
303 | + $post = Database::fetch_object($result); |
|
304 | + echo '<img src="../img/forum.gif" align="middle" /> <a href="../phpbb/viewtopic.php?topic='.$post->topic_id.'&forum='.$post->forum_id.'"'.$styling.'>'.$post->post_title."</a><br />\n"; |
|
305 | + break; |
|
306 | + case 'Document': |
|
307 | + $dbTable = Database::get_course_table(TABLE_DOCUMENT); |
|
308 | + $result = Database::query("SELECT * FROM $dbTable WHERE c_id = $course_id AND id=$id"); |
|
309 | + $myrow = Database::fetch_array($result); |
|
310 | + $pathname = explode('/',$myrow['path']); // making a correct name for the link |
|
311 | + $last = count($pathname) - 1; // making a correct name for the link |
|
312 | + $filename = $pathname[$last]; // making a correct name for the link |
|
313 | + $image = choose_image($filename); |
|
314 | + $ext = explode('.',$filename); |
|
315 | + $ext = strtolower($ext[sizeof($ext)-1]); |
|
316 | + $myrow['path'] = rawurlencode($myrow['path']); |
|
317 | + $in_frames = in_array($ext, array('htm','html','gif','jpg','jpeg','png')); |
|
318 | + echo '<img src="../img/'.$image.'" align="middle" /> <a href="../document/'.($in_frames ? 'showinframes.php?file=' : 'download.php?doc_url=').$myrow['path'].'"'.$styling.'>'.$filename."</a><br />\n"; |
|
319 | + break; |
|
320 | + case 'Externallink': |
|
321 | + echo '<img src="../img/links.gif" align="middle" /> <a href="'.$id.'"'.$styling.'>'.$id."</a><br />\n"; |
|
322 | + break; |
|
323 | + } |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | /** |
@@ -342,766 +342,766 @@ discard block |
||
342 | 342 | */ |
343 | 343 | function display_addedresource_link_in_learnpath($type, $id, $completed, $id_in_path, $builder, $icon, $level = 0) |
344 | 344 | { |
345 | - global $learnpath_id, $tbl_learnpath_item, $items; |
|
346 | - global $_course, $curDirPath, $_configuration, $enableDocumentParsing, $_user, $_cid; |
|
347 | - |
|
348 | - $hyperlink_target_parameter = ''; //or e.g. 'target="_blank"' |
|
349 | - |
|
350 | - $length = ((($builder == 'builder') and ($icon == 'nolink')) ? 65 : 32); |
|
351 | - |
|
352 | - if ($builder != 'builder') $origin = 'learnpath'; //origin = learnpath in student view |
|
353 | - $linktype = $type; |
|
354 | - if (($type == 'Link _self') or ($type == 'Link _blank')) $type = 'Link'; |
|
355 | - |
|
356 | - switch ($type) |
|
357 | - { |
|
358 | - case "Agenda": |
|
359 | - $TABLEAGENDA = Database::get_course_table(TABLE_AGENDA); |
|
360 | - $result = Database::query("SELECT * FROM $TABLEAGENDA WHERE id=$id"); |
|
361 | - $myrow=Database::fetch_array($result); |
|
362 | - |
|
363 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
364 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
365 | - if ($row['title'] != '') { $myrow["title"]=$row['title']; } |
|
366 | - $desc=$row['description']; |
|
367 | - $agenda_id=$row['item_id']; |
|
368 | - echo str_repeat(" >",$level); |
|
369 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
370 | - if ($icon != 'nolink') |
|
371 | - { |
|
372 | - if ($completed=='completed') { |
|
373 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
374 | - } else { |
|
375 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
376 | - //echo " "; |
|
377 | - } |
|
378 | - } |
|
379 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
380 | - |
|
381 | - if ($myrow["title"]=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
382 | - |
|
383 | - if ($icon == 'nolink') { return(shorten($myrow["title"],$length)); } |
|
384 | - if ($icon == 'icon') { echo "<img src='../img/agenda.gif' align=\"absmiddle\" alt='agenda'>"; } |
|
385 | - if ($builder != 'builder') |
|
386 | - { |
|
387 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Agenda&origin=$origin&agenda_id=$agenda_id#$id_in_path\" class='$completed'>".shorten($myrow["title"],($length-3*$level))."</a>"; |
|
388 | - $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Agenda&origin=$origin&agenda_id=$agenda_id#$id_in_path"; |
|
389 | - if ($desc != '') |
|
390 | - { |
|
391 | - if ($icon != 'wrap') |
|
392 | - { |
|
393 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
394 | - } |
|
395 | - else |
|
396 | - { |
|
397 | - echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
398 | - } |
|
399 | - } |
|
400 | - } |
|
401 | - else |
|
402 | - { |
|
403 | - echo "<a href=\"../calendar/agenda.php?origin=$origin&agenda_id=$agenda_id\" class='$completed' target='_blank'>".shorten($myrow["title"],($length-3*$level))."</a>"; |
|
404 | - } |
|
405 | - break; |
|
406 | - |
|
407 | - case "Ad_Valvas": |
|
408 | - $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT); |
|
409 | - $result = Database::query("SELECT * FROM $tbl_announcement WHERE id=$id"); |
|
410 | - $myrow=Database::fetch_array($result); |
|
411 | - |
|
412 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
413 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
414 | - if ($row['title'] != '') { $myrow["content"]=$row['title']; } |
|
415 | - $desc=$row['description']; |
|
416 | - $ann_id=$row['item_id']; |
|
417 | - echo str_repeat(" >",$level); |
|
418 | - |
|
419 | - // the title and the text are in the content field and we only want to display the title |
|
420 | - list($title, $text)=split('<br>',$myrow['content']); |
|
421 | - if ($title=='') { $title=$myrow['content']; } |
|
422 | - $title=$myrow['title']; |
|
423 | - $text=$myrow['content']; |
|
424 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
425 | - if ($icon != 'nolink') |
|
426 | - { |
|
427 | - if ($completed=='completed') { |
|
428 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
429 | - } else { |
|
430 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
431 | - //echo " "; |
|
432 | - } |
|
433 | - } |
|
434 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
435 | - |
|
436 | - if ($title=='') { |
|
437 | - $type="Announcement"; |
|
438 | - echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; |
|
439 | - return(true); |
|
440 | - } |
|
441 | - |
|
442 | - if ($icon == 'nolink') { return(shorten($title,$length)); } |
|
443 | - if ($icon == 'icon') { echo "<img src='../img/valves.gif' align=\"absmiddle\" alt='ad valvas'>"; } |
|
444 | - if ($builder != 'builder') |
|
445 | - { |
|
446 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Ad_Valvas&origin=$origin&ann_id=$ann_id#$id_in_path\" class='$completed'>".shorten($title,($length-3*$level))."</a>"; |
|
447 | - $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Ad_Valvas&origin=$origin&ann_id=$ann_id#$id_in_path"; |
|
448 | - if ($desc != '') |
|
449 | - { |
|
450 | - if ($icon != 'wrap') |
|
451 | - { |
|
452 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
453 | - } |
|
454 | - else |
|
455 | - { |
|
456 | - echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
457 | - } |
|
458 | - } |
|
459 | - } |
|
460 | - else |
|
461 | - { |
|
462 | - echo "<a href=\"../announcements/announcements.php?origin=$origin&ann_id=$ann_id\" class='$completed' target='_blank'>".shorten($title,($length-3*$level))."</a>"; |
|
463 | - } |
|
464 | - break; |
|
465 | - |
|
466 | - case "Link" : |
|
467 | - $TABLETOOLLINK = Database::get_course_table(TABLE_LINK); |
|
468 | - $result= Database::query("SELECT * FROM $TABLETOOLLINK WHERE id=$id"); |
|
469 | - $myrow=Database::fetch_array($result); |
|
470 | - |
|
471 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
472 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
473 | - if ($row['title'] != '') { $myrow["title"]=$row['title']; } |
|
474 | - $desc=$row['description']; |
|
475 | - echo str_repeat(" >",$level); |
|
476 | - |
|
477 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
478 | - if ($icon != 'nolink') |
|
479 | - { |
|
480 | - if ($completed=='completed') { |
|
481 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
482 | - } else { |
|
483 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
484 | - //echo " "; |
|
485 | - } |
|
486 | - } |
|
487 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
488 | - |
|
489 | - if ($myrow["title"]=='') |
|
490 | - { |
|
491 | - echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; |
|
492 | - return(true); |
|
493 | - } |
|
494 | - |
|
495 | - if ($icon == 'nolink') { return(shorten($myrow["title"],$length)); } |
|
496 | - if ($icon == 'icon') |
|
497 | - { |
|
498 | - if ($linktype=='Link _self') { echo "<img src='../img/links.gif' align=\"absmiddle\" alt='links'>"; } |
|
499 | - else { echo "<img src='../img/link_blank.gif' align=\"absmiddle\" alt='blank links'>"; } |
|
500 | - } |
|
501 | - $thelink=$myrow["url"]; |
|
502 | - if ($builder != 'builder') |
|
503 | - { |
|
504 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=$linktype&origin=$origin&thelink=$thelink#$id_in_path\" class='$completed'>".shorten($myrow["title"],($length-3*$level))."</a>"; |
|
505 | - $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=$linktype&origin=$origin&thelink=$thelink#$id_in_path"; |
|
506 | - if ($desc != '') |
|
507 | - { |
|
508 | - if ($icon != 'wrap') |
|
509 | - { |
|
510 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
511 | - } |
|
512 | - else |
|
513 | - { |
|
514 | - echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
515 | - } |
|
516 | - } |
|
517 | - } |
|
518 | - else |
|
519 | - { |
|
520 | - echo "<a href=\"$thelink\" class='$completed' target='_blank'>".shorten($myrow["title"],($length-3*$level))."</a>"; |
|
521 | - } |
|
522 | - break; |
|
523 | - |
|
524 | - case "Exercise": |
|
525 | - $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST); |
|
526 | - $result= Database::query("SELECT * FROM $TBL_EXERCICES WHERE id=$id"); |
|
527 | - $myrow=Database::fetch_array($result); |
|
528 | - |
|
529 | - if ($builder=='builder') { $origin='builder'; } |
|
530 | - //this is needed for the exercise_submit.php can delete the session info about tests |
|
531 | - |
|
532 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
533 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
534 | - if ($row['title'] != '') { $myrow["title"]=$row['title']; } |
|
535 | - $desc=$row['description']; |
|
536 | - echo str_repeat(" >",$level); |
|
537 | - |
|
538 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
539 | - if ($icon != 'nolink') |
|
540 | - { |
|
541 | - if ($completed=='completed') { |
|
542 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
543 | - } else { |
|
544 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
545 | - //echo " "; |
|
546 | - } |
|
547 | - } |
|
548 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
549 | - |
|
550 | - if ($myrow["title"]=='') { |
|
551 | - echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; |
|
552 | - return(true); |
|
553 | - } |
|
554 | - |
|
555 | - if ($icon == 'nolink') { return(shorten($myrow["title"],$length)); } |
|
556 | - if ($icon == 'icon') { echo "<img src='../img/quiz.gif' align=\"absmiddle\" alt='quizz'>"; } |
|
557 | - if ($builder != 'builder') |
|
558 | - { |
|
559 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Exercise&origin=$origin&exerciseId=".$myrow["id"]."#$id_in_path\" class='$completed'>".shorten($myrow["title"],($length-3*$level))."</a>"; |
|
560 | - $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Exercise&origin=$origin&exerciseId=".$myrow["id"]."#$id_in_path"; |
|
561 | - if ($desc != '') |
|
562 | - { |
|
563 | - if ($icon != 'wrap') |
|
564 | - { |
|
565 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
566 | - } |
|
567 | - else |
|
568 | - { |
|
569 | - echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
570 | - } |
|
571 | - } |
|
572 | - } |
|
573 | - else |
|
574 | - { |
|
575 | - echo "<a href=\"../exercise/exercise_submit.php?origin=$origin&exerciseId=".$myrow["id"]."\" class='$completed' target='_blank'>".shorten($myrow["title"],($length-3*$level))."</a>"; |
|
576 | - } |
|
577 | - break; |
|
578 | - |
|
579 | - case "HotPotatoes": |
|
580 | - $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT); |
|
581 | - $documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; |
|
582 | - $result = Database::query("SELECT * FROM ".$TBL_DOCUMENT." WHERE id=$id"); |
|
583 | - $myrow= Database::fetch_array($result); |
|
584 | - $path=$myrow["path"]; |
|
585 | - $name=GetQuizName($path,$documentPath); |
|
586 | - |
|
587 | - if ($builder=='builder') { $origin='builder'; } |
|
588 | - //this is needed for the exercise_submit.php can delete the session info about tests |
|
589 | - |
|
590 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
591 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
592 | - if ($row['title'] != '') { $name=$row['title']; } |
|
593 | - $desc=$row['description']; |
|
594 | - echo str_repeat(" >",$level); |
|
595 | - |
|
596 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
597 | - if ($icon != 'nolink') |
|
598 | - { |
|
599 | - if ($completed=='completed') { |
|
600 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
601 | - } else { |
|
602 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
603 | - //echo " "; |
|
604 | - } |
|
605 | - } |
|
606 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
607 | - |
|
608 | - if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
609 | - |
|
610 | - if ($icon == 'nolink') { return(shorten($name,$length)); } |
|
611 | - if ($icon == 'icon') { echo "<img src='../img/jqz.gif' align=\"absmiddle\" alt='hot potatoes'>"; } |
|
612 | - |
|
613 | - $cid = $_course['official_code']; |
|
614 | - |
|
615 | - if ($builder != 'builder') |
|
616 | - { |
|
617 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=HotPotatoes&origin=$origin&id=$id#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; |
|
618 | - $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=HotPotatoes&origin=$origin&id=$id#$id_in_path"; |
|
619 | - if ($desc != '') |
|
620 | - { |
|
621 | - if ($icon != 'wrap') |
|
622 | - { |
|
623 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
624 | - } |
|
625 | - else |
|
626 | - { |
|
627 | - echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
628 | - } |
|
629 | - } |
|
630 | - } |
|
631 | - else |
|
632 | - { |
|
633 | - echo " <a href=\"../exercise/showinframes.php?file=$path&cid=$cid&uid=".$_user['user_id']."\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>"; |
|
634 | - } |
|
635 | - break; |
|
636 | - |
|
637 | - case "Forum": |
|
638 | - $TBL_FORUMS = Database::get_course_table(TABLE_FORUM); |
|
639 | - $result= Database::query("SELECT * FROM $TBL_FORUMS WHERE forum_id=$id"); |
|
640 | - $myrow=Database::fetch_array($result); |
|
641 | - |
|
642 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
643 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
644 | - if ($row['title'] != '') { $myrow["forum_name"]=$row['title']; } |
|
645 | - $desc=$row['description']; |
|
646 | - echo str_repeat(" >",$level); |
|
647 | - |
|
648 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
649 | - if ($icon != 'nolink') |
|
650 | - { |
|
651 | - if ($completed=='completed') { |
|
652 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
653 | - } else { |
|
654 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
655 | - //echo " "; |
|
656 | - } |
|
657 | - } |
|
658 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
659 | - |
|
660 | - if ($myrow["forum_name"]=='') { $type="Forum"; echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
661 | - |
|
662 | - if ($icon == 'nolink') { return(shorten($myrow["forum_name"],$length)); } |
|
663 | - if ($icon == 'icon') { echo "<img src='../img/forum.gif' align=\"absmiddle\" alt='forum'>"; } |
|
664 | - $forumparameters="forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]; |
|
665 | - if ($builder != 'builder') |
|
666 | - { |
|
667 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Forum&origin=$origin&forumparameters=$forumparameters#$id_in_path\" class='$completed'>".shorten($myrow["forum_name"],($length-3*$level))."</a>"; |
|
668 | - $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Forum&origin=$origin&forumparameters=$forumparameters#$id_in_path"; |
|
669 | - if ($desc != '') |
|
670 | - { |
|
671 | - if ($icon != 'wrap') |
|
672 | - { |
|
673 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
674 | - } |
|
675 | - else |
|
676 | - { |
|
677 | - echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
678 | - } |
|
679 | - } |
|
680 | - } |
|
681 | - else |
|
682 | - { |
|
683 | - echo "<a href=\"../phpbb/viewforum.php?$forumparameters\" class='$completed' target='_blank'>".shorten($myrow["forum_name"],($length-3*$level))."</a>"; |
|
684 | - } |
|
685 | - break; |
|
686 | - |
|
687 | - case "Thread": //forum post |
|
345 | + global $learnpath_id, $tbl_learnpath_item, $items; |
|
346 | + global $_course, $curDirPath, $_configuration, $enableDocumentParsing, $_user, $_cid; |
|
347 | + |
|
348 | + $hyperlink_target_parameter = ''; //or e.g. 'target="_blank"' |
|
349 | + |
|
350 | + $length = ((($builder == 'builder') and ($icon == 'nolink')) ? 65 : 32); |
|
351 | + |
|
352 | + if ($builder != 'builder') $origin = 'learnpath'; //origin = learnpath in student view |
|
353 | + $linktype = $type; |
|
354 | + if (($type == 'Link _self') or ($type == 'Link _blank')) $type = 'Link'; |
|
355 | + |
|
356 | + switch ($type) |
|
357 | + { |
|
358 | + case "Agenda": |
|
359 | + $TABLEAGENDA = Database::get_course_table(TABLE_AGENDA); |
|
360 | + $result = Database::query("SELECT * FROM $TABLEAGENDA WHERE id=$id"); |
|
361 | + $myrow=Database::fetch_array($result); |
|
362 | + |
|
363 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
364 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
365 | + if ($row['title'] != '') { $myrow["title"]=$row['title']; } |
|
366 | + $desc=$row['description']; |
|
367 | + $agenda_id=$row['item_id']; |
|
368 | + echo str_repeat(" >",$level); |
|
369 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
370 | + if ($icon != 'nolink') |
|
371 | + { |
|
372 | + if ($completed=='completed') { |
|
373 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
374 | + } else { |
|
375 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
376 | + //echo " "; |
|
377 | + } |
|
378 | + } |
|
379 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
380 | + |
|
381 | + if ($myrow["title"]=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
382 | + |
|
383 | + if ($icon == 'nolink') { return(shorten($myrow["title"],$length)); } |
|
384 | + if ($icon == 'icon') { echo "<img src='../img/agenda.gif' align=\"absmiddle\" alt='agenda'>"; } |
|
385 | + if ($builder != 'builder') |
|
386 | + { |
|
387 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Agenda&origin=$origin&agenda_id=$agenda_id#$id_in_path\" class='$completed'>".shorten($myrow["title"],($length-3*$level))."</a>"; |
|
388 | + $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Agenda&origin=$origin&agenda_id=$agenda_id#$id_in_path"; |
|
389 | + if ($desc != '') |
|
390 | + { |
|
391 | + if ($icon != 'wrap') |
|
392 | + { |
|
393 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
394 | + } |
|
395 | + else |
|
396 | + { |
|
397 | + echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
398 | + } |
|
399 | + } |
|
400 | + } |
|
401 | + else |
|
402 | + { |
|
403 | + echo "<a href=\"../calendar/agenda.php?origin=$origin&agenda_id=$agenda_id\" class='$completed' target='_blank'>".shorten($myrow["title"],($length-3*$level))."</a>"; |
|
404 | + } |
|
405 | + break; |
|
406 | + |
|
407 | + case "Ad_Valvas": |
|
408 | + $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT); |
|
409 | + $result = Database::query("SELECT * FROM $tbl_announcement WHERE id=$id"); |
|
410 | + $myrow=Database::fetch_array($result); |
|
411 | + |
|
412 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
413 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
414 | + if ($row['title'] != '') { $myrow["content"]=$row['title']; } |
|
415 | + $desc=$row['description']; |
|
416 | + $ann_id=$row['item_id']; |
|
417 | + echo str_repeat(" >",$level); |
|
418 | + |
|
419 | + // the title and the text are in the content field and we only want to display the title |
|
420 | + list($title, $text)=split('<br>',$myrow['content']); |
|
421 | + if ($title=='') { $title=$myrow['content']; } |
|
422 | + $title=$myrow['title']; |
|
423 | + $text=$myrow['content']; |
|
424 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
425 | + if ($icon != 'nolink') |
|
426 | + { |
|
427 | + if ($completed=='completed') { |
|
428 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
429 | + } else { |
|
430 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
431 | + //echo " "; |
|
432 | + } |
|
433 | + } |
|
434 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
435 | + |
|
436 | + if ($title=='') { |
|
437 | + $type="Announcement"; |
|
438 | + echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; |
|
439 | + return(true); |
|
440 | + } |
|
441 | + |
|
442 | + if ($icon == 'nolink') { return(shorten($title,$length)); } |
|
443 | + if ($icon == 'icon') { echo "<img src='../img/valves.gif' align=\"absmiddle\" alt='ad valvas'>"; } |
|
444 | + if ($builder != 'builder') |
|
445 | + { |
|
446 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Ad_Valvas&origin=$origin&ann_id=$ann_id#$id_in_path\" class='$completed'>".shorten($title,($length-3*$level))."</a>"; |
|
447 | + $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Ad_Valvas&origin=$origin&ann_id=$ann_id#$id_in_path"; |
|
448 | + if ($desc != '') |
|
449 | + { |
|
450 | + if ($icon != 'wrap') |
|
451 | + { |
|
452 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
453 | + } |
|
454 | + else |
|
455 | + { |
|
456 | + echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
457 | + } |
|
458 | + } |
|
459 | + } |
|
460 | + else |
|
461 | + { |
|
462 | + echo "<a href=\"../announcements/announcements.php?origin=$origin&ann_id=$ann_id\" class='$completed' target='_blank'>".shorten($title,($length-3*$level))."</a>"; |
|
463 | + } |
|
464 | + break; |
|
465 | + |
|
466 | + case "Link" : |
|
467 | + $TABLETOOLLINK = Database::get_course_table(TABLE_LINK); |
|
468 | + $result= Database::query("SELECT * FROM $TABLETOOLLINK WHERE id=$id"); |
|
469 | + $myrow=Database::fetch_array($result); |
|
470 | + |
|
471 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
472 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
473 | + if ($row['title'] != '') { $myrow["title"]=$row['title']; } |
|
474 | + $desc=$row['description']; |
|
475 | + echo str_repeat(" >",$level); |
|
476 | + |
|
477 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
478 | + if ($icon != 'nolink') |
|
479 | + { |
|
480 | + if ($completed=='completed') { |
|
481 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
482 | + } else { |
|
483 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
484 | + //echo " "; |
|
485 | + } |
|
486 | + } |
|
487 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
488 | + |
|
489 | + if ($myrow["title"]=='') |
|
490 | + { |
|
491 | + echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; |
|
492 | + return(true); |
|
493 | + } |
|
494 | + |
|
495 | + if ($icon == 'nolink') { return(shorten($myrow["title"],$length)); } |
|
496 | + if ($icon == 'icon') |
|
497 | + { |
|
498 | + if ($linktype=='Link _self') { echo "<img src='../img/links.gif' align=\"absmiddle\" alt='links'>"; } |
|
499 | + else { echo "<img src='../img/link_blank.gif' align=\"absmiddle\" alt='blank links'>"; } |
|
500 | + } |
|
501 | + $thelink=$myrow["url"]; |
|
502 | + if ($builder != 'builder') |
|
503 | + { |
|
504 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=$linktype&origin=$origin&thelink=$thelink#$id_in_path\" class='$completed'>".shorten($myrow["title"],($length-3*$level))."</a>"; |
|
505 | + $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=$linktype&origin=$origin&thelink=$thelink#$id_in_path"; |
|
506 | + if ($desc != '') |
|
507 | + { |
|
508 | + if ($icon != 'wrap') |
|
509 | + { |
|
510 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
511 | + } |
|
512 | + else |
|
513 | + { |
|
514 | + echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
515 | + } |
|
516 | + } |
|
517 | + } |
|
518 | + else |
|
519 | + { |
|
520 | + echo "<a href=\"$thelink\" class='$completed' target='_blank'>".shorten($myrow["title"],($length-3*$level))."</a>"; |
|
521 | + } |
|
522 | + break; |
|
523 | + |
|
524 | + case "Exercise": |
|
525 | + $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST); |
|
526 | + $result= Database::query("SELECT * FROM $TBL_EXERCICES WHERE id=$id"); |
|
527 | + $myrow=Database::fetch_array($result); |
|
528 | + |
|
529 | + if ($builder=='builder') { $origin='builder'; } |
|
530 | + //this is needed for the exercise_submit.php can delete the session info about tests |
|
531 | + |
|
532 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
533 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
534 | + if ($row['title'] != '') { $myrow["title"]=$row['title']; } |
|
535 | + $desc=$row['description']; |
|
536 | + echo str_repeat(" >",$level); |
|
537 | + |
|
538 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
539 | + if ($icon != 'nolink') |
|
540 | + { |
|
541 | + if ($completed=='completed') { |
|
542 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
543 | + } else { |
|
544 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
545 | + //echo " "; |
|
546 | + } |
|
547 | + } |
|
548 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
549 | + |
|
550 | + if ($myrow["title"]=='') { |
|
551 | + echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; |
|
552 | + return(true); |
|
553 | + } |
|
554 | + |
|
555 | + if ($icon == 'nolink') { return(shorten($myrow["title"],$length)); } |
|
556 | + if ($icon == 'icon') { echo "<img src='../img/quiz.gif' align=\"absmiddle\" alt='quizz'>"; } |
|
557 | + if ($builder != 'builder') |
|
558 | + { |
|
559 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Exercise&origin=$origin&exerciseId=".$myrow["id"]."#$id_in_path\" class='$completed'>".shorten($myrow["title"],($length-3*$level))."</a>"; |
|
560 | + $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Exercise&origin=$origin&exerciseId=".$myrow["id"]."#$id_in_path"; |
|
561 | + if ($desc != '') |
|
562 | + { |
|
563 | + if ($icon != 'wrap') |
|
564 | + { |
|
565 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
566 | + } |
|
567 | + else |
|
568 | + { |
|
569 | + echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
570 | + } |
|
571 | + } |
|
572 | + } |
|
573 | + else |
|
574 | + { |
|
575 | + echo "<a href=\"../exercise/exercise_submit.php?origin=$origin&exerciseId=".$myrow["id"]."\" class='$completed' target='_blank'>".shorten($myrow["title"],($length-3*$level))."</a>"; |
|
576 | + } |
|
577 | + break; |
|
578 | + |
|
579 | + case "HotPotatoes": |
|
580 | + $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT); |
|
581 | + $documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; |
|
582 | + $result = Database::query("SELECT * FROM ".$TBL_DOCUMENT." WHERE id=$id"); |
|
583 | + $myrow= Database::fetch_array($result); |
|
584 | + $path=$myrow["path"]; |
|
585 | + $name=GetQuizName($path,$documentPath); |
|
586 | + |
|
587 | + if ($builder=='builder') { $origin='builder'; } |
|
588 | + //this is needed for the exercise_submit.php can delete the session info about tests |
|
589 | + |
|
590 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
591 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
592 | + if ($row['title'] != '') { $name=$row['title']; } |
|
593 | + $desc=$row['description']; |
|
594 | + echo str_repeat(" >",$level); |
|
595 | + |
|
596 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
597 | + if ($icon != 'nolink') |
|
598 | + { |
|
599 | + if ($completed=='completed') { |
|
600 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
601 | + } else { |
|
602 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
603 | + //echo " "; |
|
604 | + } |
|
605 | + } |
|
606 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
607 | + |
|
608 | + if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
609 | + |
|
610 | + if ($icon == 'nolink') { return(shorten($name,$length)); } |
|
611 | + if ($icon == 'icon') { echo "<img src='../img/jqz.gif' align=\"absmiddle\" alt='hot potatoes'>"; } |
|
612 | + |
|
613 | + $cid = $_course['official_code']; |
|
614 | + |
|
615 | + if ($builder != 'builder') |
|
616 | + { |
|
617 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=HotPotatoes&origin=$origin&id=$id#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; |
|
618 | + $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=HotPotatoes&origin=$origin&id=$id#$id_in_path"; |
|
619 | + if ($desc != '') |
|
620 | + { |
|
621 | + if ($icon != 'wrap') |
|
622 | + { |
|
623 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
624 | + } |
|
625 | + else |
|
626 | + { |
|
627 | + echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
628 | + } |
|
629 | + } |
|
630 | + } |
|
631 | + else |
|
632 | + { |
|
633 | + echo " <a href=\"../exercise/showinframes.php?file=$path&cid=$cid&uid=".$_user['user_id']."\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>"; |
|
634 | + } |
|
635 | + break; |
|
636 | + |
|
637 | + case "Forum": |
|
638 | + $TBL_FORUMS = Database::get_course_table(TABLE_FORUM); |
|
639 | + $result= Database::query("SELECT * FROM $TBL_FORUMS WHERE forum_id=$id"); |
|
640 | + $myrow=Database::fetch_array($result); |
|
641 | + |
|
642 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
643 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
644 | + if ($row['title'] != '') { $myrow["forum_name"]=$row['title']; } |
|
645 | + $desc=$row['description']; |
|
646 | + echo str_repeat(" >",$level); |
|
647 | + |
|
648 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
649 | + if ($icon != 'nolink') |
|
650 | + { |
|
651 | + if ($completed=='completed') { |
|
652 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
653 | + } else { |
|
654 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
655 | + //echo " "; |
|
656 | + } |
|
657 | + } |
|
658 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
659 | + |
|
660 | + if ($myrow["forum_name"]=='') { $type="Forum"; echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
661 | + |
|
662 | + if ($icon == 'nolink') { return(shorten($myrow["forum_name"],$length)); } |
|
663 | + if ($icon == 'icon') { echo "<img src='../img/forum.gif' align=\"absmiddle\" alt='forum'>"; } |
|
664 | + $forumparameters="forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]; |
|
665 | + if ($builder != 'builder') |
|
666 | + { |
|
667 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Forum&origin=$origin&forumparameters=$forumparameters#$id_in_path\" class='$completed'>".shorten($myrow["forum_name"],($length-3*$level))."</a>"; |
|
668 | + $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Forum&origin=$origin&forumparameters=$forumparameters#$id_in_path"; |
|
669 | + if ($desc != '') |
|
670 | + { |
|
671 | + if ($icon != 'wrap') |
|
672 | + { |
|
673 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
674 | + } |
|
675 | + else |
|
676 | + { |
|
677 | + echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
678 | + } |
|
679 | + } |
|
680 | + } |
|
681 | + else |
|
682 | + { |
|
683 | + echo "<a href=\"../phpbb/viewforum.php?$forumparameters\" class='$completed' target='_blank'>".shorten($myrow["forum_name"],($length-3*$level))."</a>"; |
|
684 | + } |
|
685 | + break; |
|
686 | + |
|
687 | + case "Thread": //forum post |
|
688 | 688 | //deprecated |
689 | - $tbl_topics = $_course['dbNameGlu'].'bb_topics'; |
|
690 | - $tbl_posts = $_course['dbNameGlu'].'bb_posts'; |
|
691 | - $TBL_FORUMS = $_course['dbNameGlu']."bb_forums"; |
|
692 | - $sql="SELECT * FROM $tbl_topics where topic_id=$id"; |
|
693 | - $result= Database::query($sql); |
|
694 | - $myrow=Database::fetch_array($result); |
|
695 | - |
|
696 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
697 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
698 | - if ($row['title'] != '') { $myrow["topic_title"]=$row['title']; } |
|
699 | - $desc=$row['description']; |
|
700 | - echo str_repeat(" >",$level); |
|
701 | - |
|
702 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
703 | - if ($icon != 'nolink') |
|
704 | - { |
|
705 | - if ($completed=='completed') { |
|
706 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
707 | - } else { |
|
708 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
709 | - //echo " "; |
|
710 | - } |
|
711 | - } |
|
712 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
713 | - |
|
714 | - if ($myrow["topic_title"]=='') { $type="Forum Post"; echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
715 | - |
|
716 | - if ($icon == 'nolink') { return(shorten($myrow["topic_title"],$length)); } |
|
717 | - if ($icon == 'icon') { echo "<img src='../img/forum.gif' align=\"absmiddle\" alt='forum'>"; } |
|
718 | - if ($builder != 'builder') |
|
719 | - { |
|
720 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Thread&origin=$origin&topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."#$id_in_path\" class='$completed'>".shorten($myrow["topic_title"],($length-3*$level))."</a>"; |
|
721 | - $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Thread&origin=$origin&topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."#$id_in_path"; |
|
722 | - if ($desc != '') |
|
723 | - { |
|
724 | - if ($icon != 'wrap') |
|
725 | - { |
|
726 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
727 | - } |
|
728 | - else |
|
729 | - { |
|
730 | - echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
731 | - } |
|
732 | - } |
|
733 | - } |
|
734 | - else |
|
735 | - { |
|
736 | - echo "<a href=\"../phpbb/viewtopic.php?topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."\" class='$completed' target='_blank'>".shorten($myrow["topic_title"],($length-3*$level))."</a>"; |
|
737 | - } |
|
738 | - break; |
|
739 | - |
|
740 | - case "Post": |
|
689 | + $tbl_topics = $_course['dbNameGlu'].'bb_topics'; |
|
690 | + $tbl_posts = $_course['dbNameGlu'].'bb_posts'; |
|
691 | + $TBL_FORUMS = $_course['dbNameGlu']."bb_forums"; |
|
692 | + $sql="SELECT * FROM $tbl_topics where topic_id=$id"; |
|
693 | + $result= Database::query($sql); |
|
694 | + $myrow=Database::fetch_array($result); |
|
695 | + |
|
696 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
697 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
698 | + if ($row['title'] != '') { $myrow["topic_title"]=$row['title']; } |
|
699 | + $desc=$row['description']; |
|
700 | + echo str_repeat(" >",$level); |
|
701 | + |
|
702 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
703 | + if ($icon != 'nolink') |
|
704 | + { |
|
705 | + if ($completed=='completed') { |
|
706 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
707 | + } else { |
|
708 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
709 | + //echo " "; |
|
710 | + } |
|
711 | + } |
|
712 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
713 | + |
|
714 | + if ($myrow["topic_title"]=='') { $type="Forum Post"; echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
715 | + |
|
716 | + if ($icon == 'nolink') { return(shorten($myrow["topic_title"],$length)); } |
|
717 | + if ($icon == 'icon') { echo "<img src='../img/forum.gif' align=\"absmiddle\" alt='forum'>"; } |
|
718 | + if ($builder != 'builder') |
|
719 | + { |
|
720 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Thread&origin=$origin&topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."#$id_in_path\" class='$completed'>".shorten($myrow["topic_title"],($length-3*$level))."</a>"; |
|
721 | + $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Thread&origin=$origin&topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."#$id_in_path"; |
|
722 | + if ($desc != '') |
|
723 | + { |
|
724 | + if ($icon != 'wrap') |
|
725 | + { |
|
726 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
727 | + } |
|
728 | + else |
|
729 | + { |
|
730 | + echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
731 | + } |
|
732 | + } |
|
733 | + } |
|
734 | + else |
|
735 | + { |
|
736 | + echo "<a href=\"../phpbb/viewtopic.php?topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."\" class='$completed' target='_blank'>".shorten($myrow["topic_title"],($length-3*$level))."</a>"; |
|
737 | + } |
|
738 | + break; |
|
739 | + |
|
740 | + case "Post": |
|
741 | 741 | //deprecated |
742 | - $tbl_posts = $_course['dbNameGlu'].'bb_posts'; |
|
743 | - $tbl_posts_text = $_course['dbNameGlu'].'bb_posts_text'; |
|
744 | - $TBL_FORUMS = $_course['dbNameGlu']."bb_forums"; |
|
745 | - $result= Database::query("SELECT * FROM $tbl_posts where post_id=$id"); |
|
746 | - $myrow=Database::fetch_array($result); |
|
747 | - // grabbing the title of the post |
|
748 | - $sql_titel="SELECT * FROM $tbl_posts_text WHERE post_id=".$myrow["post_id"]; |
|
749 | - $result_titel=Database::query($sql_titel); |
|
750 | - $myrow_titel=Database::fetch_array($result_titel); |
|
751 | - |
|
752 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
753 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
754 | - if ($row['title'] != '') { $myrow_titel["post_title"]=$row['title']; } |
|
755 | - $desc=$row['description']; |
|
756 | - echo str_repeat(" >",$level); |
|
757 | - |
|
758 | - $posternom=$myrow['nom']; $posterprenom=$myrow['prenom']; |
|
759 | - $posttime=$myrow['post_time']; $posttext=$myrow_titel['post_text']; |
|
760 | - $posttitle=$myrow_titel['post_title']; |
|
761 | - $posttext = str_replace('"',"'",$posttext); |
|
762 | - |
|
763 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
764 | - if ($icon != 'nolink') |
|
765 | - { |
|
766 | - if ($completed=='completed') { |
|
767 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
768 | - } else { |
|
769 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
770 | - //echo " "; |
|
771 | - } |
|
772 | - } |
|
773 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
774 | - |
|
775 | - if ($myrow_titel["post_title"]=='') |
|
776 | - { |
|
777 | - $type="Forum"; |
|
778 | - echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); |
|
779 | - } |
|
780 | - |
|
781 | - if ($icon == 'nolink') { return(shorten($myrow_titel["post_title"],$length)); } |
|
782 | - if ($icon == 'icon') { echo "<img src='../img/forum.gif' align=\"absmiddle\" alt='forum'>"; } |
|
783 | - if ($builder != 'builder') |
|
784 | - { |
|
785 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Post&origin=$origin&posternom=$posternom&posterprenom=$posterprenom&posttime=$posttime&posttext=$posttext&posttitle=$posttitle#$id_in_path\" class='$completed'>".shorten($myrow_titel["post_title"],($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Post&origin=$origin&posternom=$posternom&posterprenom=$posterprenom&posttime=$posttime&posttext=$posttext&posttitle=$posttitle#$id_in_path"; |
|
786 | - if ($desc != '') |
|
787 | - { |
|
788 | - if ($icon != 'wrap') |
|
789 | - { |
|
790 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
791 | - } |
|
792 | - else |
|
793 | - { |
|
794 | - echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
795 | - } |
|
796 | - } |
|
797 | - } |
|
798 | - else |
|
799 | - { |
|
800 | - echo "<a href=\"../phpbb/viewtopic.php?topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."\" class='$completed' target='_blank'>".shorten($myrow_titel["post_title"],($length-3*$level))."</a>"; |
|
801 | - } |
|
802 | - break; |
|
803 | - |
|
804 | - case "Document": |
|
805 | - $dbTable = Database::get_course_table(TABLE_DOCUMENT); |
|
806 | - $result=Database::query("SELECT * FROM $dbTable WHERE id=$id"); |
|
807 | - $myrow=Database::fetch_array($result); |
|
808 | - |
|
809 | - $pathname=explode("/",$myrow["path"]); // making a correct name for the link |
|
810 | - $last=count($pathname)-1; // making a correct name for the link |
|
811 | - $filename=$pathname[$last]; // making a correct name for the link |
|
812 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
813 | - |
|
814 | - echo str_repeat(" >",$level); |
|
815 | - |
|
816 | - if ($icon != 'nolink') { |
|
817 | - if ($completed=='completed') { |
|
818 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
819 | - } else { |
|
820 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
821 | - //echo " "; |
|
822 | - } |
|
823 | - } |
|
824 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
825 | - $image=choose_image($filename); |
|
826 | - |
|
827 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
828 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
829 | - if ($row['title'] != '') { $filename=$row['title']; } |
|
830 | - $desc=$row['description']; |
|
831 | - |
|
832 | - if (($myrow["path"]=='') and ($filename=='')) { |
|
833 | - echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; |
|
834 | - return(true); |
|
835 | - } |
|
836 | - |
|
837 | - if ($icon == 'nolink') { return(shorten($filename,$length)); } |
|
838 | - if ($icon == 'icon') { echo "<img src='../img/$image' align=\"absmiddle\" alt='$image'>"; } |
|
839 | - if ($builder != 'builder') |
|
840 | - { |
|
841 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Document&origin=$origin&docurl=".$myrow["path"]."#$id_in_path\" class='$completed'>".shorten($filename,($length-3*$level))."</a>"; |
|
842 | - if ($desc != '') |
|
843 | - { |
|
844 | - if ($icon != 'wrap') |
|
845 | - { |
|
846 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
847 | - } |
|
848 | - else |
|
849 | - { |
|
850 | - echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
851 | - } |
|
852 | - } $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Document&origin=$origin&docurl=".$myrow["path"]."#$id_in_path"; |
|
853 | - } |
|
854 | - else |
|
855 | - { |
|
856 | - $enableDocumentParsing='yes'; |
|
857 | - if (!$enableDocumentParsing) |
|
858 | - { //this is the solution for the non-parsing version in the builder |
|
859 | - $file=urlencode($myrow["path"]); |
|
860 | - echo "<a href='../document/showinframes.php?file=$file' class='$completed' $hyperlink_target_parameter>".shorten($filename,($length-3*$level))."</a>"; |
|
861 | - } |
|
862 | - else |
|
863 | - { |
|
864 | - echo "<a href=\"../document/download.php?doc_url=".$myrow["path"]."\" class='$completed' $hyperlink_target_parameter>".shorten($filename,($length-3*$level))."</a>"; |
|
865 | - } |
|
866 | - } |
|
867 | - break; |
|
868 | - |
|
869 | - case "Assignments": |
|
870 | - $name=get_lang('Assignments'); |
|
871 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
872 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
873 | - if ($row['title'] != '') { $name=$row['title']; } |
|
874 | - $desc=$row['description']; |
|
875 | - echo str_repeat(" >",$level); |
|
876 | - |
|
877 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
878 | - if ($icon != 'nolink') |
|
879 | - { |
|
880 | - if ($completed=='completed') { |
|
881 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
882 | - } else { |
|
883 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
884 | - //echo " "; |
|
885 | - } |
|
886 | - } |
|
887 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
888 | - |
|
889 | - if ($name=='') |
|
890 | - { |
|
891 | - echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); |
|
892 | - } |
|
893 | - |
|
894 | - if ($icon == 'nolink') { return(shorten($name,$length)); } |
|
895 | - if ($icon == 'icon') { echo "<img src='../img/works.gif' align=\"absmiddle\">"; } |
|
896 | - if ($builder != 'builder') |
|
897 | - { |
|
898 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Assignments&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Assignments&origin=$origin#$id_in_path"; |
|
899 | - if ($desc != '') |
|
900 | - { |
|
901 | - if ($icon != 'wrap') |
|
902 | - { |
|
903 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
904 | - } |
|
905 | - else |
|
906 | - { |
|
907 | - echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
908 | - } |
|
909 | - } |
|
910 | - } |
|
911 | - else |
|
912 | - { |
|
913 | - echo "<a href=\"../work/work.php\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>"; |
|
914 | - } |
|
915 | - break; |
|
916 | - case "Dropbox": |
|
917 | - $name=get_lang('Dropbox'); |
|
918 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
919 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
920 | - if ($row['title'] != '') { $name=$row['title']; } |
|
921 | - $desc=$row['description']; |
|
922 | - echo str_repeat(" >",$level); |
|
923 | - |
|
924 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
925 | - if ($icon != 'nolink') { |
|
926 | - if ($completed=='completed') { |
|
927 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
928 | - } else { |
|
929 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
930 | - //echo " "; |
|
931 | - } |
|
932 | - } |
|
933 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
934 | - |
|
935 | - if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
936 | - |
|
937 | - if ($icon == 'nolink') { return(shorten($name,$length)); } |
|
938 | - if ($icon == 'icon') { echo "<img src='../img/dropbox.gif' align=\"absmiddle\">"; } |
|
939 | - |
|
940 | - if ($builder != 'builder') |
|
941 | - { |
|
942 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Dropbox&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Dropbox&origin=$origin#$id_in_path"; |
|
943 | - if ($desc != '') { |
|
944 | - if ($icon != 'wrap') { |
|
945 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; } |
|
946 | - else { |
|
947 | - echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; } |
|
948 | - } |
|
949 | - } else { |
|
950 | - echo "<a href=\"../dropbox/index.php\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>"; |
|
951 | - } |
|
952 | - break; |
|
953 | - case "Introduction_text": |
|
954 | - $name=get_lang('IntroductionText'); |
|
955 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
956 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
957 | - if ($row['title'] != '') { $name=$row['title']; } |
|
958 | - $desc=$row['description']; |
|
959 | - echo str_repeat(" >",$level); |
|
960 | - |
|
961 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
962 | - if ($icon != 'nolink') { |
|
963 | - if ($completed=='completed') { |
|
964 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
965 | - } else { |
|
966 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
967 | - //echo " "; |
|
968 | - } |
|
969 | - } |
|
970 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
971 | - |
|
972 | - if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
973 | - |
|
974 | - if ($icon == 'nolink') { return(shorten($name,$length)); } |
|
975 | - if ($icon == 'icon') { echo "<img src='../img/introduction.gif' align=\"absmiddle\" alt='introduction'>"; } |
|
976 | - |
|
977 | - if ($builder != 'builder') |
|
978 | - { |
|
979 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Introduction_text&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; |
|
980 | - $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Introduction_text&origin=$origin#$id_in_path"; |
|
981 | - if ($desc != '') { |
|
982 | - if ($icon != 'wrap') { |
|
983 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; } |
|
984 | - else { |
|
985 | - echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; } |
|
986 | - } |
|
987 | - } else { |
|
988 | - $s = api_get_path(WEB_COURSE_PATH)."$_cid/index.php?intro_cmdEdit=1"; |
|
989 | - echo "<a href=\"$s\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>"; |
|
990 | - } |
|
991 | - break; |
|
992 | - case "Course_description": |
|
993 | - $name=get_lang('CourseDescription'); |
|
994 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
995 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
996 | - if ($row['title'] != '') { $name=$row['title']; } |
|
997 | - $desc=$row['description']; |
|
998 | - echo str_repeat(" >",$level); |
|
999 | - |
|
1000 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
1001 | - if ($icon != 'nolink') { |
|
1002 | - if ($completed=='completed') { |
|
1003 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
1004 | - } else { |
|
1005 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
1006 | - //echo " "; |
|
1007 | - } |
|
1008 | - } |
|
1009 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
1010 | - |
|
1011 | - if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
1012 | - |
|
1013 | - if ($icon == 'nolink') { return(shorten($name,$length)); } |
|
1014 | - if ($icon == 'icon') { echo "<img src='../img/info.gif' align=\"absmiddle\" alt='info'>"; } |
|
1015 | - |
|
1016 | - if ($builder != 'builder') |
|
1017 | - { |
|
1018 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Course_description&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Course_description&origin=$origin#$id_in_path"; |
|
1019 | - if ($desc != '') { |
|
1020 | - if ($icon != 'wrap') { |
|
1021 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; } |
|
1022 | - else { |
|
1023 | - echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; } |
|
1024 | - } |
|
1025 | - } else { |
|
1026 | - $s=api_get_path(WEB_CODE_PATH)."course_description"; |
|
1027 | - echo "<a href=\"$s\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>"; |
|
1028 | - } |
|
1029 | - break; |
|
1030 | - case "Groups": |
|
1031 | - $name=get_lang('Groups'); |
|
1032 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
1033 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
1034 | - if ($row['title'] != '') { $name=$row['title']; } |
|
1035 | - $desc=$row['description']; |
|
1036 | - echo str_repeat(" >",$level); |
|
1037 | - |
|
1038 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
1039 | - if ($icon != 'nolink') { |
|
1040 | - if ($completed=='completed') { |
|
1041 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
1042 | - } else { |
|
1043 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
1044 | - //echo " "; |
|
1045 | - } |
|
1046 | - } |
|
1047 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
1048 | - |
|
1049 | - if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
1050 | - |
|
1051 | - if ($icon == 'nolink') { return(shorten($name,$length)); } |
|
1052 | - if ($icon == 'icon') { echo "<img src='../img/group.gif' align=\"absmiddle\" alt='group'>"; } |
|
1053 | - |
|
1054 | - if ($builder != 'builder') |
|
1055 | - { |
|
1056 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Groups&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Groups&origin=$origin#$id_in_path"; |
|
1057 | - if ($desc != '') { |
|
1058 | - if ($icon != 'wrap') { |
|
1059 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; } |
|
1060 | - else { |
|
1061 | - echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; } |
|
1062 | - } |
|
1063 | - } else { |
|
1064 | - echo "<a href=\"../group/group.php?origin=$origin\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>"; |
|
1065 | - } |
|
1066 | - break; |
|
1067 | - case "Users": |
|
1068 | - $name=get_lang('Users'); |
|
1069 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
1070 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
1071 | - if ($row['title'] != '') { $name=$row['title']; } |
|
1072 | - $desc=$row['description']; |
|
1073 | - echo str_repeat(" >",$level); |
|
1074 | - |
|
1075 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
1076 | - if ($icon != 'nolink') { |
|
1077 | - if ($completed=='completed') { |
|
1078 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
1079 | - } else { |
|
1080 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
1081 | - //echo " "; |
|
1082 | - } |
|
1083 | - } |
|
1084 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
1085 | - |
|
1086 | - if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
1087 | - |
|
1088 | - if ($icon == 'nolink') { return(shorten($name,$length)); } |
|
1089 | - if ($icon == 'icon') { echo "<img src='../img/members.gif' align=\"absmiddle\" alt='members'>"; } |
|
1090 | - |
|
1091 | - if ($builder != 'builder') |
|
1092 | - { |
|
1093 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Users&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Users&origin=$origin#$id_in_path"; |
|
1094 | - if ($desc != '') { |
|
1095 | - if ($icon != 'wrap') { |
|
1096 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; } |
|
1097 | - else { |
|
1098 | - echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; } |
|
1099 | - } |
|
1100 | - } else { |
|
1101 | - echo "<a href=\"../user/user.php?origin=$origin\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>"; |
|
1102 | - } |
|
1103 | - break; |
|
1104 | - }//end huge switch-statement |
|
742 | + $tbl_posts = $_course['dbNameGlu'].'bb_posts'; |
|
743 | + $tbl_posts_text = $_course['dbNameGlu'].'bb_posts_text'; |
|
744 | + $TBL_FORUMS = $_course['dbNameGlu']."bb_forums"; |
|
745 | + $result= Database::query("SELECT * FROM $tbl_posts where post_id=$id"); |
|
746 | + $myrow=Database::fetch_array($result); |
|
747 | + // grabbing the title of the post |
|
748 | + $sql_titel="SELECT * FROM $tbl_posts_text WHERE post_id=".$myrow["post_id"]; |
|
749 | + $result_titel=Database::query($sql_titel); |
|
750 | + $myrow_titel=Database::fetch_array($result_titel); |
|
751 | + |
|
752 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
753 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
754 | + if ($row['title'] != '') { $myrow_titel["post_title"]=$row['title']; } |
|
755 | + $desc=$row['description']; |
|
756 | + echo str_repeat(" >",$level); |
|
757 | + |
|
758 | + $posternom=$myrow['nom']; $posterprenom=$myrow['prenom']; |
|
759 | + $posttime=$myrow['post_time']; $posttext=$myrow_titel['post_text']; |
|
760 | + $posttitle=$myrow_titel['post_title']; |
|
761 | + $posttext = str_replace('"',"'",$posttext); |
|
762 | + |
|
763 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
764 | + if ($icon != 'nolink') |
|
765 | + { |
|
766 | + if ($completed=='completed') { |
|
767 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
768 | + } else { |
|
769 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
770 | + //echo " "; |
|
771 | + } |
|
772 | + } |
|
773 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
774 | + |
|
775 | + if ($myrow_titel["post_title"]=='') |
|
776 | + { |
|
777 | + $type="Forum"; |
|
778 | + echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); |
|
779 | + } |
|
780 | + |
|
781 | + if ($icon == 'nolink') { return(shorten($myrow_titel["post_title"],$length)); } |
|
782 | + if ($icon == 'icon') { echo "<img src='../img/forum.gif' align=\"absmiddle\" alt='forum'>"; } |
|
783 | + if ($builder != 'builder') |
|
784 | + { |
|
785 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Post&origin=$origin&posternom=$posternom&posterprenom=$posterprenom&posttime=$posttime&posttext=$posttext&posttitle=$posttitle#$id_in_path\" class='$completed'>".shorten($myrow_titel["post_title"],($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Post&origin=$origin&posternom=$posternom&posterprenom=$posterprenom&posttime=$posttime&posttext=$posttext&posttitle=$posttitle#$id_in_path"; |
|
786 | + if ($desc != '') |
|
787 | + { |
|
788 | + if ($icon != 'wrap') |
|
789 | + { |
|
790 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
791 | + } |
|
792 | + else |
|
793 | + { |
|
794 | + echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
795 | + } |
|
796 | + } |
|
797 | + } |
|
798 | + else |
|
799 | + { |
|
800 | + echo "<a href=\"../phpbb/viewtopic.php?topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."\" class='$completed' target='_blank'>".shorten($myrow_titel["post_title"],($length-3*$level))."</a>"; |
|
801 | + } |
|
802 | + break; |
|
803 | + |
|
804 | + case "Document": |
|
805 | + $dbTable = Database::get_course_table(TABLE_DOCUMENT); |
|
806 | + $result=Database::query("SELECT * FROM $dbTable WHERE id=$id"); |
|
807 | + $myrow=Database::fetch_array($result); |
|
808 | + |
|
809 | + $pathname=explode("/",$myrow["path"]); // making a correct name for the link |
|
810 | + $last=count($pathname)-1; // making a correct name for the link |
|
811 | + $filename=$pathname[$last]; // making a correct name for the link |
|
812 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
813 | + |
|
814 | + echo str_repeat(" >",$level); |
|
815 | + |
|
816 | + if ($icon != 'nolink') { |
|
817 | + if ($completed=='completed') { |
|
818 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
819 | + } else { |
|
820 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
821 | + //echo " "; |
|
822 | + } |
|
823 | + } |
|
824 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
825 | + $image=choose_image($filename); |
|
826 | + |
|
827 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
828 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
829 | + if ($row['title'] != '') { $filename=$row['title']; } |
|
830 | + $desc=$row['description']; |
|
831 | + |
|
832 | + if (($myrow["path"]=='') and ($filename=='')) { |
|
833 | + echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; |
|
834 | + return(true); |
|
835 | + } |
|
836 | + |
|
837 | + if ($icon == 'nolink') { return(shorten($filename,$length)); } |
|
838 | + if ($icon == 'icon') { echo "<img src='../img/$image' align=\"absmiddle\" alt='$image'>"; } |
|
839 | + if ($builder != 'builder') |
|
840 | + { |
|
841 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Document&origin=$origin&docurl=".$myrow["path"]."#$id_in_path\" class='$completed'>".shorten($filename,($length-3*$level))."</a>"; |
|
842 | + if ($desc != '') |
|
843 | + { |
|
844 | + if ($icon != 'wrap') |
|
845 | + { |
|
846 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
847 | + } |
|
848 | + else |
|
849 | + { |
|
850 | + echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
851 | + } |
|
852 | + } $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Document&origin=$origin&docurl=".$myrow["path"]."#$id_in_path"; |
|
853 | + } |
|
854 | + else |
|
855 | + { |
|
856 | + $enableDocumentParsing='yes'; |
|
857 | + if (!$enableDocumentParsing) |
|
858 | + { //this is the solution for the non-parsing version in the builder |
|
859 | + $file=urlencode($myrow["path"]); |
|
860 | + echo "<a href='../document/showinframes.php?file=$file' class='$completed' $hyperlink_target_parameter>".shorten($filename,($length-3*$level))."</a>"; |
|
861 | + } |
|
862 | + else |
|
863 | + { |
|
864 | + echo "<a href=\"../document/download.php?doc_url=".$myrow["path"]."\" class='$completed' $hyperlink_target_parameter>".shorten($filename,($length-3*$level))."</a>"; |
|
865 | + } |
|
866 | + } |
|
867 | + break; |
|
868 | + |
|
869 | + case "Assignments": |
|
870 | + $name=get_lang('Assignments'); |
|
871 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
872 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
873 | + if ($row['title'] != '') { $name=$row['title']; } |
|
874 | + $desc=$row['description']; |
|
875 | + echo str_repeat(" >",$level); |
|
876 | + |
|
877 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
878 | + if ($icon != 'nolink') |
|
879 | + { |
|
880 | + if ($completed=='completed') { |
|
881 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
882 | + } else { |
|
883 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
884 | + //echo " "; |
|
885 | + } |
|
886 | + } |
|
887 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
888 | + |
|
889 | + if ($name=='') |
|
890 | + { |
|
891 | + echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); |
|
892 | + } |
|
893 | + |
|
894 | + if ($icon == 'nolink') { return(shorten($name,$length)); } |
|
895 | + if ($icon == 'icon') { echo "<img src='../img/works.gif' align=\"absmiddle\">"; } |
|
896 | + if ($builder != 'builder') |
|
897 | + { |
|
898 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Assignments&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Assignments&origin=$origin#$id_in_path"; |
|
899 | + if ($desc != '') |
|
900 | + { |
|
901 | + if ($icon != 'wrap') |
|
902 | + { |
|
903 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
904 | + } |
|
905 | + else |
|
906 | + { |
|
907 | + echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
908 | + } |
|
909 | + } |
|
910 | + } |
|
911 | + else |
|
912 | + { |
|
913 | + echo "<a href=\"../work/work.php\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>"; |
|
914 | + } |
|
915 | + break; |
|
916 | + case "Dropbox": |
|
917 | + $name=get_lang('Dropbox'); |
|
918 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
919 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
920 | + if ($row['title'] != '') { $name=$row['title']; } |
|
921 | + $desc=$row['description']; |
|
922 | + echo str_repeat(" >",$level); |
|
923 | + |
|
924 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
925 | + if ($icon != 'nolink') { |
|
926 | + if ($completed=='completed') { |
|
927 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
928 | + } else { |
|
929 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
930 | + //echo " "; |
|
931 | + } |
|
932 | + } |
|
933 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
934 | + |
|
935 | + if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
936 | + |
|
937 | + if ($icon == 'nolink') { return(shorten($name,$length)); } |
|
938 | + if ($icon == 'icon') { echo "<img src='../img/dropbox.gif' align=\"absmiddle\">"; } |
|
939 | + |
|
940 | + if ($builder != 'builder') |
|
941 | + { |
|
942 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Dropbox&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Dropbox&origin=$origin#$id_in_path"; |
|
943 | + if ($desc != '') { |
|
944 | + if ($icon != 'wrap') { |
|
945 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; } |
|
946 | + else { |
|
947 | + echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; } |
|
948 | + } |
|
949 | + } else { |
|
950 | + echo "<a href=\"../dropbox/index.php\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>"; |
|
951 | + } |
|
952 | + break; |
|
953 | + case "Introduction_text": |
|
954 | + $name=get_lang('IntroductionText'); |
|
955 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
956 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
957 | + if ($row['title'] != '') { $name=$row['title']; } |
|
958 | + $desc=$row['description']; |
|
959 | + echo str_repeat(" >",$level); |
|
960 | + |
|
961 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
962 | + if ($icon != 'nolink') { |
|
963 | + if ($completed=='completed') { |
|
964 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
965 | + } else { |
|
966 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
967 | + //echo " "; |
|
968 | + } |
|
969 | + } |
|
970 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
971 | + |
|
972 | + if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
973 | + |
|
974 | + if ($icon == 'nolink') { return(shorten($name,$length)); } |
|
975 | + if ($icon == 'icon') { echo "<img src='../img/introduction.gif' align=\"absmiddle\" alt='introduction'>"; } |
|
976 | + |
|
977 | + if ($builder != 'builder') |
|
978 | + { |
|
979 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Introduction_text&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; |
|
980 | + $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Introduction_text&origin=$origin#$id_in_path"; |
|
981 | + if ($desc != '') { |
|
982 | + if ($icon != 'wrap') { |
|
983 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; } |
|
984 | + else { |
|
985 | + echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; } |
|
986 | + } |
|
987 | + } else { |
|
988 | + $s = api_get_path(WEB_COURSE_PATH)."$_cid/index.php?intro_cmdEdit=1"; |
|
989 | + echo "<a href=\"$s\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>"; |
|
990 | + } |
|
991 | + break; |
|
992 | + case "Course_description": |
|
993 | + $name=get_lang('CourseDescription'); |
|
994 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
995 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
996 | + if ($row['title'] != '') { $name=$row['title']; } |
|
997 | + $desc=$row['description']; |
|
998 | + echo str_repeat(" >",$level); |
|
999 | + |
|
1000 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
1001 | + if ($icon != 'nolink') { |
|
1002 | + if ($completed=='completed') { |
|
1003 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
1004 | + } else { |
|
1005 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
1006 | + //echo " "; |
|
1007 | + } |
|
1008 | + } |
|
1009 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
1010 | + |
|
1011 | + if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
1012 | + |
|
1013 | + if ($icon == 'nolink') { return(shorten($name,$length)); } |
|
1014 | + if ($icon == 'icon') { echo "<img src='../img/info.gif' align=\"absmiddle\" alt='info'>"; } |
|
1015 | + |
|
1016 | + if ($builder != 'builder') |
|
1017 | + { |
|
1018 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Course_description&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Course_description&origin=$origin#$id_in_path"; |
|
1019 | + if ($desc != '') { |
|
1020 | + if ($icon != 'wrap') { |
|
1021 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; } |
|
1022 | + else { |
|
1023 | + echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; } |
|
1024 | + } |
|
1025 | + } else { |
|
1026 | + $s=api_get_path(WEB_CODE_PATH)."course_description"; |
|
1027 | + echo "<a href=\"$s\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>"; |
|
1028 | + } |
|
1029 | + break; |
|
1030 | + case "Groups": |
|
1031 | + $name=get_lang('Groups'); |
|
1032 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
1033 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
1034 | + if ($row['title'] != '') { $name=$row['title']; } |
|
1035 | + $desc=$row['description']; |
|
1036 | + echo str_repeat(" >",$level); |
|
1037 | + |
|
1038 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
1039 | + if ($icon != 'nolink') { |
|
1040 | + if ($completed=='completed') { |
|
1041 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
1042 | + } else { |
|
1043 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
1044 | + //echo " "; |
|
1045 | + } |
|
1046 | + } |
|
1047 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
1048 | + |
|
1049 | + if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
1050 | + |
|
1051 | + if ($icon == 'nolink') { return(shorten($name,$length)); } |
|
1052 | + if ($icon == 'icon') { echo "<img src='../img/group.gif' align=\"absmiddle\" alt='group'>"; } |
|
1053 | + |
|
1054 | + if ($builder != 'builder') |
|
1055 | + { |
|
1056 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Groups&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Groups&origin=$origin#$id_in_path"; |
|
1057 | + if ($desc != '') { |
|
1058 | + if ($icon != 'wrap') { |
|
1059 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; } |
|
1060 | + else { |
|
1061 | + echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; } |
|
1062 | + } |
|
1063 | + } else { |
|
1064 | + echo "<a href=\"../group/group.php?origin=$origin\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>"; |
|
1065 | + } |
|
1066 | + break; |
|
1067 | + case "Users": |
|
1068 | + $name=get_lang('Users'); |
|
1069 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
1070 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
1071 | + if ($row['title'] != '') { $name=$row['title']; } |
|
1072 | + $desc=$row['description']; |
|
1073 | + echo str_repeat(" >",$level); |
|
1074 | + |
|
1075 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
1076 | + if ($icon != 'nolink') { |
|
1077 | + if ($completed=='completed') { |
|
1078 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
1079 | + } else { |
|
1080 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
1081 | + //echo " "; |
|
1082 | + } |
|
1083 | + } |
|
1084 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
1085 | + |
|
1086 | + if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
1087 | + |
|
1088 | + if ($icon == 'nolink') { return(shorten($name,$length)); } |
|
1089 | + if ($icon == 'icon') { echo "<img src='../img/members.gif' align=\"absmiddle\" alt='members'>"; } |
|
1090 | + |
|
1091 | + if ($builder != 'builder') |
|
1092 | + { |
|
1093 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Users&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Users&origin=$origin#$id_in_path"; |
|
1094 | + if ($desc != '') { |
|
1095 | + if ($icon != 'wrap') { |
|
1096 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; } |
|
1097 | + else { |
|
1098 | + echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; } |
|
1099 | + } |
|
1100 | + } else { |
|
1101 | + echo "<a href=\"../user/user.php?origin=$origin\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>"; |
|
1102 | + } |
|
1103 | + break; |
|
1104 | + }//end huge switch-statement |
|
1105 | 1105 | } |
1106 | 1106 | |
1107 | 1107 | /** |
@@ -1116,168 +1116,168 @@ discard block |
||
1116 | 1116 | */ |
1117 | 1117 | function get_addedresource_link_in_learnpath($type, $id, $id_in_path) |
1118 | 1118 | { |
1119 | - global $_course, $learnpath_id, $tbl_learnpath_item, $items; |
|
1120 | - global $curDirPath, $_configuration, $enableDocumentParsing, $_user , $_cid; |
|
1121 | - |
|
1122 | - $hyperlink_target_parameter = ""; //or e.g. target='_blank' |
|
1123 | - $builder = 'player'; |
|
1124 | - $origin='learnpath'; |
|
1125 | - |
|
1126 | - $linktype=$type; |
|
1127 | - if (($type=="Link _self") or ($type=="Link _blank")) { $type="Link"; } |
|
1128 | - |
|
1129 | - $link = ''; |
|
1130 | - |
|
1131 | - switch ($type) |
|
1132 | - { |
|
1133 | - case "Agenda": |
|
1134 | - $TABLEAGENDA = Database::get_course_table(TABLE_AGENDA);; |
|
1135 | - $result = Database::query("SELECT * FROM $TABLEAGENDA WHERE id=$id"); |
|
1136 | - $myrow=Database::fetch_array($result); |
|
1137 | - |
|
1138 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
1139 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
1140 | - if ($row['title'] != '') { $myrow["title"]=$row['title']; } |
|
1141 | - $desc=$row['description']; |
|
1142 | - $agenda_id=$row['item_id']; |
|
1143 | - |
|
1144 | - if ($builder != 'builder') |
|
1145 | - { |
|
1146 | - $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Agenda&origin=$origin&agenda_id=$agenda_id#$id_in_path"; |
|
1147 | - } |
|
1148 | - else |
|
1149 | - { |
|
1150 | - $link .= "../calendar/agenda.php?origin=$origin&agenda_id=$agenda_id"; |
|
1151 | - } |
|
1152 | - break; |
|
1153 | - |
|
1154 | - case "Ad_Valvas": |
|
1155 | - $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT); |
|
1156 | - $result = Database::query("SELECT * FROM $tbl_announcement WHERE id=$id"); |
|
1157 | - $myrow=Database::fetch_array($result); |
|
1158 | - |
|
1159 | - if ($builder != 'builder') |
|
1160 | - { |
|
1161 | - $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Ad_Valvas&origin=$origin&ann_id=$id#$id_in_path"; |
|
1162 | - } |
|
1163 | - else |
|
1164 | - { |
|
1165 | - $link .= "../announcements/announcements.php?origin=$origin&ann_id=$id"; |
|
1166 | - } |
|
1167 | - break; |
|
1168 | - |
|
1169 | - case "Link" : |
|
1170 | - $TABLETOOLLINK = Database::get_course_table(TABLE_LINK); |
|
1171 | - $result= Database::query("SELECT * FROM $TABLETOOLLINK WHERE id=$id"); |
|
1172 | - $myrow=Database::fetch_array($result); |
|
1173 | - |
|
1174 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
1175 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
1176 | - |
|
1177 | - $thelink=$myrow["url"]; |
|
1178 | - if ($builder != 'builder') |
|
1179 | - { |
|
1180 | - $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=$linktype&origin=$origin&thelink=$thelink#$id_in_path"; |
|
1181 | - } |
|
1182 | - else |
|
1183 | - { |
|
1184 | - $link .= $thelink; |
|
1185 | - } |
|
1186 | - break; |
|
1187 | - |
|
1188 | - case "Exercise": |
|
1189 | - $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST); |
|
1190 | - $result= Database::query("SELECT * FROM $TBL_EXERCICES WHERE id=$id"); |
|
1191 | - $myrow=Database::fetch_array($result); |
|
1192 | - |
|
1193 | - if ($builder=='builder') { $origin='builder'; } |
|
1194 | - //this is needed for the exercise_submit.php can delete the session info about tests |
|
1195 | - |
|
1196 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
1197 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
1198 | - if ($row['title'] != '') { $myrow["title"]=$row['title']; } |
|
1199 | - |
|
1200 | - if ($builder != 'builder') |
|
1201 | - { |
|
1202 | - $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Exercise&origin=$origin&exerciseId=".$myrow["id"]."#$id_in_path"; |
|
1203 | - } |
|
1204 | - else |
|
1205 | - { |
|
1206 | - $link .= "../exercise/exercise_submit.php?origin=$origin&exerciseId=".$myrow["id"]; |
|
1207 | - } |
|
1208 | - break; |
|
1209 | - |
|
1210 | - case "HotPotatoes": |
|
1211 | - $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT); |
|
1212 | - $documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; |
|
1213 | - $result = Database::query("SELECT * FROM ".$TBL_DOCUMENT." WHERE id=$id"); |
|
1214 | - $myrow= Database::fetch_array($result); |
|
1215 | - $path=$myrow["path"]; |
|
1216 | - $name=GetQuizName($path,$documentPath); |
|
1217 | - |
|
1218 | - if ($builder=='builder') { $origin='builder'; } |
|
1219 | - |
|
1220 | - $cid = $_course['official_code']; |
|
1221 | - |
|
1222 | - if ($builder != 'builder') |
|
1223 | - { |
|
1224 | - $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=HotPotatoes&origin=$origin&id=$id#$id_in_path"; |
|
1225 | - } |
|
1226 | - else |
|
1227 | - { |
|
1228 | - $link .= "../exercise/showinframes.php?file=$path&cid=$cid&uid=".$_user['user_id'].""; |
|
1229 | - } |
|
1230 | - break; |
|
1231 | - |
|
1232 | - case "Forum": |
|
1119 | + global $_course, $learnpath_id, $tbl_learnpath_item, $items; |
|
1120 | + global $curDirPath, $_configuration, $enableDocumentParsing, $_user , $_cid; |
|
1121 | + |
|
1122 | + $hyperlink_target_parameter = ""; //or e.g. target='_blank' |
|
1123 | + $builder = 'player'; |
|
1124 | + $origin='learnpath'; |
|
1125 | + |
|
1126 | + $linktype=$type; |
|
1127 | + if (($type=="Link _self") or ($type=="Link _blank")) { $type="Link"; } |
|
1128 | + |
|
1129 | + $link = ''; |
|
1130 | + |
|
1131 | + switch ($type) |
|
1132 | + { |
|
1133 | + case "Agenda": |
|
1134 | + $TABLEAGENDA = Database::get_course_table(TABLE_AGENDA);; |
|
1135 | + $result = Database::query("SELECT * FROM $TABLEAGENDA WHERE id=$id"); |
|
1136 | + $myrow=Database::fetch_array($result); |
|
1137 | + |
|
1138 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
1139 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
1140 | + if ($row['title'] != '') { $myrow["title"]=$row['title']; } |
|
1141 | + $desc=$row['description']; |
|
1142 | + $agenda_id=$row['item_id']; |
|
1143 | + |
|
1144 | + if ($builder != 'builder') |
|
1145 | + { |
|
1146 | + $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Agenda&origin=$origin&agenda_id=$agenda_id#$id_in_path"; |
|
1147 | + } |
|
1148 | + else |
|
1149 | + { |
|
1150 | + $link .= "../calendar/agenda.php?origin=$origin&agenda_id=$agenda_id"; |
|
1151 | + } |
|
1152 | + break; |
|
1153 | + |
|
1154 | + case "Ad_Valvas": |
|
1155 | + $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT); |
|
1156 | + $result = Database::query("SELECT * FROM $tbl_announcement WHERE id=$id"); |
|
1157 | + $myrow=Database::fetch_array($result); |
|
1158 | + |
|
1159 | + if ($builder != 'builder') |
|
1160 | + { |
|
1161 | + $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Ad_Valvas&origin=$origin&ann_id=$id#$id_in_path"; |
|
1162 | + } |
|
1163 | + else |
|
1164 | + { |
|
1165 | + $link .= "../announcements/announcements.php?origin=$origin&ann_id=$id"; |
|
1166 | + } |
|
1167 | + break; |
|
1168 | + |
|
1169 | + case "Link" : |
|
1170 | + $TABLETOOLLINK = Database::get_course_table(TABLE_LINK); |
|
1171 | + $result= Database::query("SELECT * FROM $TABLETOOLLINK WHERE id=$id"); |
|
1172 | + $myrow=Database::fetch_array($result); |
|
1173 | + |
|
1174 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
1175 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
1176 | + |
|
1177 | + $thelink=$myrow["url"]; |
|
1178 | + if ($builder != 'builder') |
|
1179 | + { |
|
1180 | + $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=$linktype&origin=$origin&thelink=$thelink#$id_in_path"; |
|
1181 | + } |
|
1182 | + else |
|
1183 | + { |
|
1184 | + $link .= $thelink; |
|
1185 | + } |
|
1186 | + break; |
|
1187 | + |
|
1188 | + case "Exercise": |
|
1189 | + $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST); |
|
1190 | + $result= Database::query("SELECT * FROM $TBL_EXERCICES WHERE id=$id"); |
|
1191 | + $myrow=Database::fetch_array($result); |
|
1192 | + |
|
1193 | + if ($builder=='builder') { $origin='builder'; } |
|
1194 | + //this is needed for the exercise_submit.php can delete the session info about tests |
|
1195 | + |
|
1196 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
1197 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
1198 | + if ($row['title'] != '') { $myrow["title"]=$row['title']; } |
|
1199 | + |
|
1200 | + if ($builder != 'builder') |
|
1201 | + { |
|
1202 | + $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Exercise&origin=$origin&exerciseId=".$myrow["id"]."#$id_in_path"; |
|
1203 | + } |
|
1204 | + else |
|
1205 | + { |
|
1206 | + $link .= "../exercise/exercise_submit.php?origin=$origin&exerciseId=".$myrow["id"]; |
|
1207 | + } |
|
1208 | + break; |
|
1209 | + |
|
1210 | + case "HotPotatoes": |
|
1211 | + $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT); |
|
1212 | + $documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; |
|
1213 | + $result = Database::query("SELECT * FROM ".$TBL_DOCUMENT." WHERE id=$id"); |
|
1214 | + $myrow= Database::fetch_array($result); |
|
1215 | + $path=$myrow["path"]; |
|
1216 | + $name=GetQuizName($path,$documentPath); |
|
1217 | + |
|
1218 | + if ($builder=='builder') { $origin='builder'; } |
|
1219 | + |
|
1220 | + $cid = $_course['official_code']; |
|
1221 | + |
|
1222 | + if ($builder != 'builder') |
|
1223 | + { |
|
1224 | + $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=HotPotatoes&origin=$origin&id=$id#$id_in_path"; |
|
1225 | + } |
|
1226 | + else |
|
1227 | + { |
|
1228 | + $link .= "../exercise/showinframes.php?file=$path&cid=$cid&uid=".$_user['user_id'].""; |
|
1229 | + } |
|
1230 | + break; |
|
1231 | + |
|
1232 | + case "Forum": |
|
1233 | 1233 | //deprecated |
1234 | - $TBL_FORUMS = Database::get_course_table(TABLE_FORUM); |
|
1235 | - $result= Database::query("SELECT * FROM $TBL_FORUMS WHERE forum_id=$id"); |
|
1236 | - $myrow=Database::fetch_array($result); |
|
1237 | - |
|
1238 | - if ($builder=='builder') { $origin='builder'; } |
|
1239 | - |
|
1240 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
1241 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
1242 | - if ($row['title'] != '') { $myrow["forum_name"]=$row['title']; } |
|
1243 | - |
|
1244 | - if ($myrow["forum_name"]=='') { $type="Forum"; } |
|
1245 | - |
|
1246 | - $forumparameters="forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]; |
|
1247 | - if ($builder != 'builder') |
|
1248 | - { |
|
1249 | - $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Forum&origin=$origin&forumparameters=$forumparameters#$id_in_path"; |
|
1250 | - } |
|
1251 | - else |
|
1252 | - { |
|
1253 | - $link .= "../phpbb/viewforum.php?$forumparameters"; |
|
1254 | - } |
|
1255 | - break; |
|
1256 | - |
|
1257 | - case "Thread": //forum post |
|
1234 | + $TBL_FORUMS = Database::get_course_table(TABLE_FORUM); |
|
1235 | + $result= Database::query("SELECT * FROM $TBL_FORUMS WHERE forum_id=$id"); |
|
1236 | + $myrow=Database::fetch_array($result); |
|
1237 | + |
|
1238 | + if ($builder=='builder') { $origin='builder'; } |
|
1239 | + |
|
1240 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
1241 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
1242 | + if ($row['title'] != '') { $myrow["forum_name"]=$row['title']; } |
|
1243 | + |
|
1244 | + if ($myrow["forum_name"]=='') { $type="Forum"; } |
|
1245 | + |
|
1246 | + $forumparameters="forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]; |
|
1247 | + if ($builder != 'builder') |
|
1248 | + { |
|
1249 | + $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Forum&origin=$origin&forumparameters=$forumparameters#$id_in_path"; |
|
1250 | + } |
|
1251 | + else |
|
1252 | + { |
|
1253 | + $link .= "../phpbb/viewforum.php?$forumparameters"; |
|
1254 | + } |
|
1255 | + break; |
|
1256 | + |
|
1257 | + case "Thread": //forum post |
|
1258 | 1258 | //deprecated |
1259 | - $tbl_topics = $_course['dbNameGlu'].'bb_topics'; |
|
1260 | - $tbl_posts = $_course['dbNameGlu'].'bb_posts'; |
|
1261 | - $TBL_FORUMS = $_course['dbNameGlu']."bb_forums"; |
|
1262 | - $sql="SELECT * FROM $tbl_topics where topic_id=$id"; |
|
1263 | - $result= Database::query($sql); |
|
1264 | - $myrow=Database::fetch_array($result); |
|
1265 | - |
|
1266 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
1267 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
1268 | - |
|
1269 | - if ($builder != 'builder') |
|
1270 | - { |
|
1271 | - $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Thread&origin=$origin&topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."#$id_in_path"; |
|
1272 | - } |
|
1273 | - else |
|
1274 | - { |
|
1275 | - $link .= "../phpbb/viewtopic.php?topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]; |
|
1276 | - } |
|
1277 | - break; |
|
1278 | - |
|
1279 | - case "Post": |
|
1280 | - /* todo REVIEW THIS SECTION - NOT USING VALID TABLES ANYMORE |
|
1259 | + $tbl_topics = $_course['dbNameGlu'].'bb_topics'; |
|
1260 | + $tbl_posts = $_course['dbNameGlu'].'bb_posts'; |
|
1261 | + $TBL_FORUMS = $_course['dbNameGlu']."bb_forums"; |
|
1262 | + $sql="SELECT * FROM $tbl_topics where topic_id=$id"; |
|
1263 | + $result= Database::query($sql); |
|
1264 | + $myrow=Database::fetch_array($result); |
|
1265 | + |
|
1266 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
1267 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
1268 | + |
|
1269 | + if ($builder != 'builder') |
|
1270 | + { |
|
1271 | + $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Thread&origin=$origin&topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."#$id_in_path"; |
|
1272 | + } |
|
1273 | + else |
|
1274 | + { |
|
1275 | + $link .= "../phpbb/viewtopic.php?topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]; |
|
1276 | + } |
|
1277 | + break; |
|
1278 | + |
|
1279 | + case "Post": |
|
1280 | + /* todo REVIEW THIS SECTION - NOT USING VALID TABLES ANYMORE |
|
1281 | 1281 | $tbl_posts = $_course['dbNameGlu'].'bb_posts'; |
1282 | 1282 | $tbl_posts_text = $_course['dbNameGlu'].'bb_posts_text'; |
1283 | 1283 | $TBL_FORUMS = $_course['dbNameGlu']."bb_forums"; |
@@ -1308,94 +1308,94 @@ discard block |
||
1308 | 1308 | $link .= "../phpbb/viewtopic.php?topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]; |
1309 | 1309 | } |
1310 | 1310 | */ |
1311 | - break; |
|
1312 | - |
|
1313 | - case "Document": |
|
1314 | - $dbTable = Database::get_course_table(TABLE_DOCUMENT); |
|
1315 | - $result=Database::query("SELECT * FROM $dbTable WHERE id=$id",__FILE__,__LINE); |
|
1316 | - $myrow=Database::fetch_array($result); |
|
1317 | - |
|
1318 | - $pathname=explode("/",$myrow["path"]); // making a correct name for the link |
|
1319 | - $last=count($pathname)-1; // making a correct name for the link |
|
1320 | - $filename=$pathname[$last]; // making a correct name for the link |
|
1321 | - |
|
1322 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
1323 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
1324 | - |
|
1325 | - if ($builder != 'builder') |
|
1326 | - { |
|
1327 | - $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Document&origin=$origin&docurl=".$myrow["path"]."#$id_in_path"; |
|
1328 | - |
|
1329 | - } |
|
1330 | - else |
|
1331 | - { |
|
1332 | - $enableDocumentParsing='yes'; |
|
1333 | - if (!$enableDocumentParsing) |
|
1334 | - { //this is the solution for the non-parsing version in the builder |
|
1335 | - $file=urlencode($myrow["path"]); |
|
1336 | - $link .= "../document/showinframes.php?file=$file"; |
|
1337 | - } |
|
1338 | - else |
|
1339 | - { |
|
1340 | - $link .= "../document/download.php?doc_url=".$myrow["path"]; |
|
1341 | - } |
|
1342 | - } |
|
1343 | - break; |
|
1344 | - |
|
1345 | - case "Assignments": |
|
1346 | - if ($builder != 'builder') |
|
1347 | - { |
|
1348 | - $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Assignments&origin=$origin#$id_in_path"; |
|
1349 | - } |
|
1350 | - else |
|
1351 | - { |
|
1352 | - $link .= "../work/work.php"; |
|
1353 | - } |
|
1354 | - break; |
|
1355 | - case "Dropbox": |
|
1356 | - if ($builder != 'builder') |
|
1357 | - { |
|
1358 | - $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Dropbox&origin=$origin#$id_in_path"; |
|
1359 | - } else { |
|
1360 | - $link .= "../dropbox/index.php"; |
|
1361 | - } |
|
1362 | - break; |
|
1363 | - case "Introduction_text": |
|
1364 | - if ($builder != 'builder') |
|
1365 | - { |
|
1366 | - $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Introduction_text&origin=$origin#$id_in_path"; |
|
1367 | - } else { |
|
1368 | - $s = api_get_path(WEB_COURSE_PATH)."$_cid/index.php?intro_cmdEdit=1"; |
|
1369 | - $link .= $s; |
|
1370 | - } |
|
1371 | - break; |
|
1372 | - case "Course_description": |
|
1373 | - if ($builder != 'builder') |
|
1374 | - { |
|
1375 | - $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Course_description&origin=$origin#$id_in_path"; |
|
1376 | - } else { |
|
1377 | - $s=api_get_path(WEB_CODE_PATH)."course_description"; |
|
1378 | - $link .= $s; |
|
1379 | - } |
|
1380 | - break; |
|
1381 | - case "Groups": |
|
1382 | - |
|
1383 | - if ($builder != 'builder') |
|
1384 | - { |
|
1385 | - $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Groups&origin=$origin#$id_in_path"; |
|
1386 | - } else { |
|
1387 | - $link .= "../group/group.php?origin=$origin"; |
|
1388 | - } |
|
1389 | - break; |
|
1390 | - case "Users": |
|
1391 | - if ($builder != 'builder') |
|
1392 | - { |
|
1393 | - $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Users&origin=$origin#$id_in_path"; |
|
1394 | - } else { |
|
1395 | - $link .= "../user/user.php?origin=$origin"; |
|
1396 | - } |
|
1397 | - break; |
|
1398 | - }//end huge switch-statement |
|
1311 | + break; |
|
1312 | + |
|
1313 | + case "Document": |
|
1314 | + $dbTable = Database::get_course_table(TABLE_DOCUMENT); |
|
1315 | + $result=Database::query("SELECT * FROM $dbTable WHERE id=$id",__FILE__,__LINE); |
|
1316 | + $myrow=Database::fetch_array($result); |
|
1317 | + |
|
1318 | + $pathname=explode("/",$myrow["path"]); // making a correct name for the link |
|
1319 | + $last=count($pathname)-1; // making a correct name for the link |
|
1320 | + $filename=$pathname[$last]; // making a correct name for the link |
|
1321 | + |
|
1322 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
1323 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
1324 | + |
|
1325 | + if ($builder != 'builder') |
|
1326 | + { |
|
1327 | + $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Document&origin=$origin&docurl=".$myrow["path"]."#$id_in_path"; |
|
1328 | + |
|
1329 | + } |
|
1330 | + else |
|
1331 | + { |
|
1332 | + $enableDocumentParsing='yes'; |
|
1333 | + if (!$enableDocumentParsing) |
|
1334 | + { //this is the solution for the non-parsing version in the builder |
|
1335 | + $file=urlencode($myrow["path"]); |
|
1336 | + $link .= "../document/showinframes.php?file=$file"; |
|
1337 | + } |
|
1338 | + else |
|
1339 | + { |
|
1340 | + $link .= "../document/download.php?doc_url=".$myrow["path"]; |
|
1341 | + } |
|
1342 | + } |
|
1343 | + break; |
|
1344 | + |
|
1345 | + case "Assignments": |
|
1346 | + if ($builder != 'builder') |
|
1347 | + { |
|
1348 | + $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Assignments&origin=$origin#$id_in_path"; |
|
1349 | + } |
|
1350 | + else |
|
1351 | + { |
|
1352 | + $link .= "../work/work.php"; |
|
1353 | + } |
|
1354 | + break; |
|
1355 | + case "Dropbox": |
|
1356 | + if ($builder != 'builder') |
|
1357 | + { |
|
1358 | + $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Dropbox&origin=$origin#$id_in_path"; |
|
1359 | + } else { |
|
1360 | + $link .= "../dropbox/index.php"; |
|
1361 | + } |
|
1362 | + break; |
|
1363 | + case "Introduction_text": |
|
1364 | + if ($builder != 'builder') |
|
1365 | + { |
|
1366 | + $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Introduction_text&origin=$origin#$id_in_path"; |
|
1367 | + } else { |
|
1368 | + $s = api_get_path(WEB_COURSE_PATH)."$_cid/index.php?intro_cmdEdit=1"; |
|
1369 | + $link .= $s; |
|
1370 | + } |
|
1371 | + break; |
|
1372 | + case "Course_description": |
|
1373 | + if ($builder != 'builder') |
|
1374 | + { |
|
1375 | + $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Course_description&origin=$origin#$id_in_path"; |
|
1376 | + } else { |
|
1377 | + $s=api_get_path(WEB_CODE_PATH)."course_description"; |
|
1378 | + $link .= $s; |
|
1379 | + } |
|
1380 | + break; |
|
1381 | + case "Groups": |
|
1382 | + |
|
1383 | + if ($builder != 'builder') |
|
1384 | + { |
|
1385 | + $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Groups&origin=$origin#$id_in_path"; |
|
1386 | + } else { |
|
1387 | + $link .= "../group/group.php?origin=$origin"; |
|
1388 | + } |
|
1389 | + break; |
|
1390 | + case "Users": |
|
1391 | + if ($builder != 'builder') |
|
1392 | + { |
|
1393 | + $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Users&origin=$origin#$id_in_path"; |
|
1394 | + } else { |
|
1395 | + $link .= "../user/user.php?origin=$origin"; |
|
1396 | + } |
|
1397 | + break; |
|
1398 | + }//end huge switch-statement |
|
1399 | 1399 | return $link; |
1400 | 1400 | } |
1401 | 1401 | |
@@ -1404,12 +1404,12 @@ discard block |
||
1404 | 1404 | */ |
1405 | 1405 | function remove_resource($resource_key) |
1406 | 1406 | { |
1407 | - $addedresource = $_SESSION['addedresource']; |
|
1408 | - $addedresourceid = $_SESSION['addedresourceid']; |
|
1409 | - unset($addedresource[$resource_key]); |
|
1410 | - unset($addedresourceid[$resource_key]); |
|
1411 | - $_SESSION['addedresource']=$addedresource; |
|
1412 | - $_SESSION['addedresourceid']=$addedresourceid ; |
|
1407 | + $addedresource = $_SESSION['addedresource']; |
|
1408 | + $addedresourceid = $_SESSION['addedresourceid']; |
|
1409 | + unset($addedresource[$resource_key]); |
|
1410 | + unset($addedresourceid[$resource_key]); |
|
1411 | + $_SESSION['addedresource']=$addedresource; |
|
1412 | + $_SESSION['addedresourceid']=$addedresourceid ; |
|
1413 | 1413 | } |
1414 | 1414 | |
1415 | 1415 | /** |
@@ -1418,8 +1418,8 @@ discard block |
||
1418 | 1418 | */ |
1419 | 1419 | function show_addresource_button($additionalparameters = '') |
1420 | 1420 | { |
1421 | - global $charset; |
|
1422 | - echo '<label for="addresources"><img src="../img/attachment.gif" /></label><input class="link_alike" type="submit" name="addresources" id="addresources" value="'.api_htmlentities(get_lang('Attachment'), ENT_QUOTES, $charset).'" '.$additionalparameters.' />'; |
|
1421 | + global $charset; |
|
1422 | + echo '<label for="addresources"><img src="../img/attachment.gif" /></label><input class="link_alike" type="submit" name="addresources" id="addresources" value="'.api_htmlentities(get_lang('Attachment'), ENT_QUOTES, $charset).'" '.$additionalparameters.' />'; |
|
1423 | 1423 | } |
1424 | 1424 | |
1425 | 1425 | /** |
@@ -1441,11 +1441,11 @@ discard block |
||
1441 | 1441 | */ |
1442 | 1442 | function delete_added_resource($type, $id) |
1443 | 1443 | { |
1444 | - global $_course; |
|
1445 | - $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES); |
|
1444 | + global $_course; |
|
1445 | + $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES); |
|
1446 | 1446 | |
1447 | - $sql="DELETE FROM $TABLERESOURCE WHERE source_type='$type' and source_id='$id'"; |
|
1448 | - Database::query($sql); |
|
1447 | + $sql="DELETE FROM $TABLERESOURCE WHERE source_type='$type' and source_id='$id'"; |
|
1448 | + Database::query($sql); |
|
1449 | 1449 | } |
1450 | 1450 | |
1451 | 1451 | /** |
@@ -1454,12 +1454,12 @@ discard block |
||
1454 | 1454 | */ |
1455 | 1455 | function delete_all_resources_type($type) |
1456 | 1456 | { |
1457 | - global $_course; |
|
1458 | - $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES); |
|
1457 | + global $_course; |
|
1458 | + $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES); |
|
1459 | 1459 | |
1460 | - $sql="DELETE FROM $TABLERESOURCE WHERE source_type='$type'"; |
|
1460 | + $sql="DELETE FROM $TABLERESOURCE WHERE source_type='$type'"; |
|
1461 | 1461 | |
1462 | - Database::query($sql); |
|
1462 | + Database::query($sql); |
|
1463 | 1463 | } |
1464 | 1464 | |
1465 | 1465 | /** |
@@ -1467,15 +1467,15 @@ discard block |
||
1467 | 1467 | */ |
1468 | 1468 | function check_added_resources($type, $id) |
1469 | 1469 | { |
1470 | - global $_course, $origin; |
|
1471 | - $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES); |
|
1472 | - $sql="SELECT * FROM $TABLERESOURCE WHERE source_type='$type' and source_id='$id'"; |
|
1473 | - $result=Database::query($sql); |
|
1474 | - $number_added=Database::num_rows($result); |
|
1475 | - if ($number_added<>0) |
|
1476 | - return true; |
|
1477 | - else |
|
1478 | - return false; |
|
1470 | + global $_course, $origin; |
|
1471 | + $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES); |
|
1472 | + $sql="SELECT * FROM $TABLERESOURCE WHERE source_type='$type' and source_id='$id'"; |
|
1473 | + $result=Database::query($sql); |
|
1474 | + $number_added=Database::num_rows($result); |
|
1475 | + if ($number_added<>0) |
|
1476 | + return true; |
|
1477 | + else |
|
1478 | + return false; |
|
1479 | 1479 | } |
1480 | 1480 | |
1481 | 1481 | |
@@ -1485,18 +1485,18 @@ discard block |
||
1485 | 1485 | */ |
1486 | 1486 | function edit_added_resources($type, $id) |
1487 | 1487 | { |
1488 | - $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES); |
|
1488 | + $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES); |
|
1489 | 1489 | $course_id = api_get_course_int_id(); |
1490 | 1490 | $id = intval($id); |
1491 | 1491 | $type = Database::escape_string($type); |
1492 | - $sql="SELECT * FROM $TABLERESOURCE WHERE c_id = $course_id AND source_type='$type' and source_id=$id"; |
|
1493 | - $result=Database::query($sql); |
|
1494 | - while ($row=Database::fetch_array($result)) { |
|
1495 | - $addedresource[]=$row["resource_type"]; |
|
1496 | - $addedresourceid[]=$row["resource_id"]; |
|
1497 | - } |
|
1498 | - $_SESSION['addedresource']=$addedresource; |
|
1499 | - $_SESSION['addedresourceid']=$addedresourceid; |
|
1492 | + $sql="SELECT * FROM $TABLERESOURCE WHERE c_id = $course_id AND source_type='$type' and source_id=$id"; |
|
1493 | + $result=Database::query($sql); |
|
1494 | + while ($row=Database::fetch_array($result)) { |
|
1495 | + $addedresource[]=$row["resource_type"]; |
|
1496 | + $addedresourceid[]=$row["resource_id"]; |
|
1497 | + } |
|
1498 | + $_SESSION['addedresource']=$addedresource; |
|
1499 | + $_SESSION['addedresourceid']=$addedresourceid; |
|
1500 | 1500 | } |
1501 | 1501 | |
1502 | 1502 | /** |
@@ -1506,20 +1506,20 @@ discard block |
||
1506 | 1506 | */ |
1507 | 1507 | function update_added_resources($type, $id) |
1508 | 1508 | { |
1509 | - $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES); |
|
1509 | + $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES); |
|
1510 | 1510 | $course_id = api_get_course_int_id(); |
1511 | 1511 | $id = intval($id); |
1512 | 1512 | $type = Database::escape_string($type); |
1513 | - // delete all the added resources for this item in the database; |
|
1514 | - $sql="DELETE FROM $TABLERESOURCE WHERE c_id = $course_id AND source_type='$type' AND source_id='$id'"; |
|
1515 | - //echo $sql; |
|
1516 | - Database::query($sql); |
|
1513 | + // delete all the added resources for this item in the database; |
|
1514 | + $sql="DELETE FROM $TABLERESOURCE WHERE c_id = $course_id AND source_type='$type' AND source_id='$id'"; |
|
1515 | + //echo $sql; |
|
1516 | + Database::query($sql); |
|
1517 | 1517 | |
1518 | - // store the resources from the session into the database |
|
1519 | - store_resources($type, $id); |
|
1518 | + // store the resources from the session into the database |
|
1519 | + store_resources($type, $id); |
|
1520 | 1520 | |
1521 | - //delete_added_resource_($type, $id); |
|
1522 | - unset_session_resources(); |
|
1521 | + //delete_added_resource_($type, $id); |
|
1522 | + unset_session_resources(); |
|
1523 | 1523 | } |
1524 | 1524 | |
1525 | 1525 | /** |
@@ -1527,25 +1527,25 @@ discard block |
||
1527 | 1527 | */ |
1528 | 1528 | function display_added_resources($type, $id, $style='') |
1529 | 1529 | { |
1530 | - // the array containing the icons |
|
1531 | - $arr_icons=array('Agenda'=>'../img/agenda.gif', 'Ad Valvas'=>'../img/valves.gif', 'Link'=>'../img/links.gif', 'Exercise'=>'../img/quiz.gif' ); |
|
1532 | - |
|
1533 | - global $_course, $origin; |
|
1534 | - $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES); |
|
1535 | - |
|
1536 | - $sql="SELECT * FROM $TABLERESOURCE WHERE source_type='$type' and source_id='$id'"; |
|
1537 | - $result=Database::query($sql); |
|
1538 | - while ($row=Database::fetch_array($result)) |
|
1539 | - { |
|
1540 | - if ($origin != 'learnpath') |
|
1541 | - { |
|
1542 | - display_addedresource_link($row['resource_type'], $row['resource_id'], $style) ; |
|
1543 | - } |
|
1544 | - else |
|
1545 | - { |
|
1546 | - display_addedresource_link_in_learnpath($row['resource_type'], $row['resource_id'],'agendaitems','','builder','icon') ; echo "<br>"; |
|
1547 | - } |
|
1548 | - } |
|
1530 | + // the array containing the icons |
|
1531 | + $arr_icons=array('Agenda'=>'../img/agenda.gif', 'Ad Valvas'=>'../img/valves.gif', 'Link'=>'../img/links.gif', 'Exercise'=>'../img/quiz.gif' ); |
|
1532 | + |
|
1533 | + global $_course, $origin; |
|
1534 | + $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES); |
|
1535 | + |
|
1536 | + $sql="SELECT * FROM $TABLERESOURCE WHERE source_type='$type' and source_id='$id'"; |
|
1537 | + $result=Database::query($sql); |
|
1538 | + while ($row=Database::fetch_array($result)) |
|
1539 | + { |
|
1540 | + if ($origin != 'learnpath') |
|
1541 | + { |
|
1542 | + display_addedresource_link($row['resource_type'], $row['resource_id'], $style) ; |
|
1543 | + } |
|
1544 | + else |
|
1545 | + { |
|
1546 | + display_addedresource_link_in_learnpath($row['resource_type'], $row['resource_id'],'agendaitems','','builder','icon') ; echo "<br>"; |
|
1547 | + } |
|
1548 | + } |
|
1549 | 1549 | } |
1550 | 1550 | |
1551 | 1551 | |
@@ -1556,15 +1556,15 @@ discard block |
||
1556 | 1556 | */ |
1557 | 1557 | function display_resources($showdeleteimg) |
1558 | 1558 | { |
1559 | - global $action; |
|
1560 | - global $resourceaction; |
|
1561 | - global $id; |
|
1562 | - global $locationkey; |
|
1563 | - global $source_id, $action, $learnpath_id, $chapter_id, $originalresource; |
|
1564 | - |
|
1565 | - if ($resourceaction=="removeresource") |
|
1566 | - { |
|
1567 | - /* unneccessary because when editing we delete all the added resources from the |
|
1559 | + global $action; |
|
1560 | + global $resourceaction; |
|
1561 | + global $id; |
|
1562 | + global $locationkey; |
|
1563 | + global $source_id, $action, $learnpath_id, $chapter_id, $originalresource; |
|
1564 | + |
|
1565 | + if ($resourceaction=="removeresource") |
|
1566 | + { |
|
1567 | + /* unneccessary because when editing we delete all the added resources from the |
|
1568 | 1568 | database and add all these from the session |
1569 | 1569 | if ($action=="edit") // we have an edit and thus we delete from the database and from the session |
1570 | 1570 | { |
@@ -1580,41 +1580,41 @@ discard block |
||
1580 | 1580 | } |
1581 | 1581 | else // we remove from the session |
1582 | 1582 | {*/ |
1583 | - //echo "remove from session"; |
|
1584 | - remove_resource($locationkey); |
|
1585 | - } |
|
1586 | - $addedresource=$_SESSION['addedresource']; |
|
1587 | - $addedresourceid=$_SESSION['addedresourceid']; |
|
1588 | - if (is_array($addedresource)) |
|
1589 | - { |
|
1590 | - echo '<table>'; |
|
1591 | - foreach ($addedresource as $resource) |
|
1592 | - { |
|
1593 | - //echo $resource.":".$addedresourceid[key($addedresource)]; |
|
1594 | - echo '<tr><td>'; |
|
1595 | - display_addedresource_link($resource,$addedresourceid[key($addedresource)]); |
|
1596 | - echo '</td><td width="30">'; |
|
1597 | - |
|
1598 | - // if $_SERVER['REQUEST_URI'] contains and ?id=xx we have an edit and the url for deleting a session added resource |
|
1599 | - // should also contain this id. |
|
1600 | - $test=parse_url($_SERVER['REQUEST_URI']); |
|
1601 | - $output = array(); |
|
1602 | - parse_str($test['query'],$output); |
|
1603 | - |
|
1604 | - if ($showdeleteimg==1) |
|
1605 | - { |
|
1606 | - echo "<a href=".api_get_self()."?showresources=true&source_forum=".$_GET['source_forum']."&resourceaction=removeresource&locationkey=".key($addedresource)."&source_id=$source_id&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no><img src='../img/delete.gif' border='0' alt='resource ".get_lang('Delete')."' /></a><br />"; |
|
1607 | - } |
|
1608 | - echo '</td></tr>'; |
|
1609 | - next($addedresource); |
|
1610 | - //$_SESSION['edit']==''; |
|
1611 | - } |
|
1612 | - echo '</table>'; |
|
1613 | - } |
|
1614 | - else // it is a string |
|
1615 | - { |
|
1616 | - echo ''; |
|
1617 | - } |
|
1583 | + //echo "remove from session"; |
|
1584 | + remove_resource($locationkey); |
|
1585 | + } |
|
1586 | + $addedresource=$_SESSION['addedresource']; |
|
1587 | + $addedresourceid=$_SESSION['addedresourceid']; |
|
1588 | + if (is_array($addedresource)) |
|
1589 | + { |
|
1590 | + echo '<table>'; |
|
1591 | + foreach ($addedresource as $resource) |
|
1592 | + { |
|
1593 | + //echo $resource.":".$addedresourceid[key($addedresource)]; |
|
1594 | + echo '<tr><td>'; |
|
1595 | + display_addedresource_link($resource,$addedresourceid[key($addedresource)]); |
|
1596 | + echo '</td><td width="30">'; |
|
1597 | + |
|
1598 | + // if $_SERVER['REQUEST_URI'] contains and ?id=xx we have an edit and the url for deleting a session added resource |
|
1599 | + // should also contain this id. |
|
1600 | + $test=parse_url($_SERVER['REQUEST_URI']); |
|
1601 | + $output = array(); |
|
1602 | + parse_str($test['query'],$output); |
|
1603 | + |
|
1604 | + if ($showdeleteimg==1) |
|
1605 | + { |
|
1606 | + echo "<a href=".api_get_self()."?showresources=true&source_forum=".$_GET['source_forum']."&resourceaction=removeresource&locationkey=".key($addedresource)."&source_id=$source_id&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no><img src='../img/delete.gif' border='0' alt='resource ".get_lang('Delete')."' /></a><br />"; |
|
1607 | + } |
|
1608 | + echo '</td></tr>'; |
|
1609 | + next($addedresource); |
|
1610 | + //$_SESSION['edit']==''; |
|
1611 | + } |
|
1612 | + echo '</table>'; |
|
1613 | + } |
|
1614 | + else // it is a string |
|
1615 | + { |
|
1616 | + echo ''; |
|
1617 | + } |
|
1618 | 1618 | } // end of the display_resources function |
1619 | 1619 | |
1620 | 1620 | |
@@ -1626,49 +1626,49 @@ discard block |
||
1626 | 1626 | */ |
1627 | 1627 | function showorhide_addresourcelink($type, $id) |
1628 | 1628 | { |
1629 | - global $from_learnpath, $source_id, $action, $learnpath_id, $chapter_id, $originalresource, $folder, $content, $target; |
|
1630 | - //global $_SESSION['addresource']; |
|
1631 | - //global $_SESSION['addresourceid']; |
|
1632 | - $addedresource=$_SESSION['addedresource']; |
|
1633 | - $addedresourceid=$_SESSION['addedresourceid']; |
|
1634 | - |
|
1635 | - if (is_array($_SESSION['addedresource'])) |
|
1636 | - { |
|
1637 | - foreach ($addedresource as $toolcompare) |
|
1638 | - { |
|
1639 | - //echo $toolcompare; |
|
1640 | - //echo "/".$type."/".$id."****"; |
|
1641 | - //$key=key($addedresource); |
|
1642 | - //echo $addedresourceid[$key]; |
|
1643 | - //print_r($addedresourceid); |
|
1644 | - //echo "<br>"; |
|
1645 | - |
|
1646 | - if ($toolcompare==$type and $addedresourceid[key($addedresource)]==$id) |
|
1647 | - { |
|
1648 | - $show=0; |
|
1649 | - } |
|
1650 | - next($addedresource); |
|
1651 | - } |
|
1652 | - if ($from_learnpath) { $lang_add_it_or_resource=get_lang('AddIt'); } else { $lang_add_it_or_resource=get_lang('AddResource'); } |
|
1653 | - if ($show!==0) |
|
1654 | - { |
|
1655 | - if ($type=="Document") |
|
1656 | - { |
|
1657 | - echo "<a href=".api_get_self()."?content=".$type."&folder=".$folder."&source_forum=".$_GET['source_forum']."&add=".$id."&source_id=$source_id&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no>".$lang_add_it_or_resource."</a>"; |
|
1658 | - } |
|
1659 | - else |
|
1660 | - { |
|
1661 | - echo "<a href='".api_get_self()."?content=".$type."&source_forum=".$_GET['source_forum']."&add=".$id."&source_id=$source_id&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no&target=$target'>".$lang_add_it_or_resource."</a>"; |
|
1662 | - } |
|
1663 | - } |
|
1664 | - } |
|
1665 | - else // if it is not an array, it is a string |
|
1666 | - { |
|
1667 | - if ($_SESSION['addedresource']!==$type or $_SESSION['addedresourceid']!==$id) |
|
1668 | - { |
|
1669 | - if ($from_learnpath) { $lang_add_it_or_resource=get_lang('AddIt'); } else { $lang_add_it_or_resource=get_lang('AddResource'); } |
|
1670 | - echo "<a href='".api_get_self()."?content=".$type."&folder=".$folder."&source_forum=".$_GET['source_forum']."&add=".$id."&source_id=$source_id&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no&target=$target'>".$lang_add_it_or_resource."</a>"; |
|
1671 | - } |
|
1672 | - } |
|
1629 | + global $from_learnpath, $source_id, $action, $learnpath_id, $chapter_id, $originalresource, $folder, $content, $target; |
|
1630 | + //global $_SESSION['addresource']; |
|
1631 | + //global $_SESSION['addresourceid']; |
|
1632 | + $addedresource=$_SESSION['addedresource']; |
|
1633 | + $addedresourceid=$_SESSION['addedresourceid']; |
|
1634 | + |
|
1635 | + if (is_array($_SESSION['addedresource'])) |
|
1636 | + { |
|
1637 | + foreach ($addedresource as $toolcompare) |
|
1638 | + { |
|
1639 | + //echo $toolcompare; |
|
1640 | + //echo "/".$type."/".$id."****"; |
|
1641 | + //$key=key($addedresource); |
|
1642 | + //echo $addedresourceid[$key]; |
|
1643 | + //print_r($addedresourceid); |
|
1644 | + //echo "<br>"; |
|
1645 | + |
|
1646 | + if ($toolcompare==$type and $addedresourceid[key($addedresource)]==$id) |
|
1647 | + { |
|
1648 | + $show=0; |
|
1649 | + } |
|
1650 | + next($addedresource); |
|
1651 | + } |
|
1652 | + if ($from_learnpath) { $lang_add_it_or_resource=get_lang('AddIt'); } else { $lang_add_it_or_resource=get_lang('AddResource'); } |
|
1653 | + if ($show!==0) |
|
1654 | + { |
|
1655 | + if ($type=="Document") |
|
1656 | + { |
|
1657 | + echo "<a href=".api_get_self()."?content=".$type."&folder=".$folder."&source_forum=".$_GET['source_forum']."&add=".$id."&source_id=$source_id&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no>".$lang_add_it_or_resource."</a>"; |
|
1658 | + } |
|
1659 | + else |
|
1660 | + { |
|
1661 | + echo "<a href='".api_get_self()."?content=".$type."&source_forum=".$_GET['source_forum']."&add=".$id."&source_id=$source_id&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no&target=$target'>".$lang_add_it_or_resource."</a>"; |
|
1662 | + } |
|
1663 | + } |
|
1664 | + } |
|
1665 | + else // if it is not an array, it is a string |
|
1666 | + { |
|
1667 | + if ($_SESSION['addedresource']!==$type or $_SESSION['addedresourceid']!==$id) |
|
1668 | + { |
|
1669 | + if ($from_learnpath) { $lang_add_it_or_resource=get_lang('AddIt'); } else { $lang_add_it_or_resource=get_lang('AddResource'); } |
|
1670 | + echo "<a href='".api_get_self()."?content=".$type."&folder=".$folder."&source_forum=".$_GET['source_forum']."&add=".$id."&source_id=$source_id&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no&target=$target'>".$lang_add_it_or_resource."</a>"; |
|
1671 | + } |
|
1672 | + } |
|
1673 | 1673 | } |
1674 | 1674 | ?> |
@@ -17,7 +17,7 @@ |
||
17 | 17 | $result = $objExercise->read($exercise_id); |
18 | 18 | |
19 | 19 | if (!$result) { |
20 | - api_not_allowed(true); |
|
20 | + api_not_allowed(true); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | $interbreadcrumb[] = array( |
@@ -178,9 +178,9 @@ discard block |
||
178 | 178 | } |
179 | 179 | |
180 | 180 | /** |
181 | - * abstract function which creates the form to create/edit the answers of the question |
|
182 | - * @param FormValidator $form |
|
183 | - */ |
|
181 | + * abstract function which creates the form to create/edit the answers of the question |
|
182 | + * @param FormValidator $form |
|
183 | + */ |
|
184 | 184 | public function processAnswersCreation($form) |
185 | 185 | { |
186 | 186 | $questionWeighting = $nbrGoodAnswers = 0; |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | // sets the total weighting of the question |
222 | 222 | $this->updateWeighting($questionWeighting); |
223 | 223 | $this->save(); |
224 | - } |
|
224 | + } |
|
225 | 225 | |
226 | 226 | function return_header($feedback_type = null, $counter = null, $score = null) |
227 | 227 | { |