@@ -108,24 +108,24 @@ |
||
108 | 108 | */ |
109 | 109 | function utf8_sort($array) |
110 | 110 | { |
111 | - $old_locale = setlocale(LC_ALL, null); |
|
112 | - $code = api_get_language_isocode(); |
|
113 | - $locale_list = array($code.'.utf8', 'en.utf8','en_US.utf8','en_GB.utf8'); |
|
114 | - $try_sort = false; |
|
111 | + $old_locale = setlocale(LC_ALL, null); |
|
112 | + $code = api_get_language_isocode(); |
|
113 | + $locale_list = array($code.'.utf8', 'en.utf8','en_US.utf8','en_GB.utf8'); |
|
114 | + $try_sort = false; |
|
115 | 115 | |
116 | - foreach($locale_list as $locale) { |
|
117 | - $my_local = setlocale(LC_COLLATE, $locale); |
|
118 | - if ($my_local) { |
|
119 | - $try_sort = true; |
|
120 | - break; |
|
121 | - } |
|
122 | - } |
|
116 | + foreach($locale_list as $locale) { |
|
117 | + $my_local = setlocale(LC_COLLATE, $locale); |
|
118 | + if ($my_local) { |
|
119 | + $try_sort = true; |
|
120 | + break; |
|
121 | + } |
|
122 | + } |
|
123 | 123 | |
124 | - if ($try_sort) { |
|
125 | - uasort($array, 'strcoll'); |
|
126 | - } |
|
127 | - setlocale(LC_COLLATE, $old_locale); |
|
128 | - return $array; |
|
124 | + if ($try_sort) { |
|
125 | + uasort($array, 'strcoll'); |
|
126 | + } |
|
127 | + setlocale(LC_COLLATE, $old_locale); |
|
128 | + return $array; |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -15,15 +15,15 @@ discard block |
||
15 | 15 | { |
16 | 16 | } |
17 | 17 | |
18 | - /** |
|
19 | - * Add a new Term and Condition |
|
20 | - * @param int $language language id |
|
21 | - * @param string $content content |
|
22 | - * @param int $type term and condition type (0 or 1) |
|
23 | - * @param string $changes explain changes |
|
24 | - * @return boolean success |
|
25 | - */ |
|
26 | - public static function add($language, $content, $type, $changes) |
|
18 | + /** |
|
19 | + * Add a new Term and Condition |
|
20 | + * @param int $language language id |
|
21 | + * @param string $content content |
|
22 | + * @param int $type term and condition type (0 or 1) |
|
23 | + * @param string $changes explain changes |
|
24 | + * @return boolean success |
|
25 | + */ |
|
26 | + public static function add($language, $content, $type, $changes) |
|
27 | 27 | { |
28 | 28 | $legal_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
29 | 29 | $last = self::get_last_condition($language); |
@@ -60,62 +60,62 @@ discard block |
||
60 | 60 | } |
61 | 61 | } |
62 | 62 | |
63 | - public static function delete($id) |
|
63 | + public static function delete($id) |
|
64 | 64 | { |
65 | - /* |
|
65 | + /* |
|
66 | 66 | $legal_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
67 | 67 | $id = intval($id); |
68 | 68 | $sql = "DELETE FROM $legal_table WHERE legal_id = '".$id."'"; |
69 | 69 | */ |
70 | - } |
|
71 | - |
|
72 | - /** |
|
73 | - * Gets the last version of a Term and condition by language |
|
74 | - * @param int $language language id |
|
75 | - * @return array all the info of a Term and condition |
|
76 | - */ |
|
77 | - public static function get_last_condition_version($language) |
|
70 | + } |
|
71 | + |
|
72 | + /** |
|
73 | + * Gets the last version of a Term and condition by language |
|
74 | + * @param int $language language id |
|
75 | + * @return array all the info of a Term and condition |
|
76 | + */ |
|
77 | + public static function get_last_condition_version($language) |
|
78 | 78 | { |
79 | - $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
|
80 | - $language= Database::escape_string($language); |
|
81 | - $sql = "SELECT version FROM $legal_conditions_table |
|
79 | + $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
|
80 | + $language= Database::escape_string($language); |
|
81 | + $sql = "SELECT version FROM $legal_conditions_table |
|
82 | 82 | WHERE language_id = '".$language."' |
83 | 83 | ORDER BY legal_id DESC LIMIT 1 "; |
84 | - $result = Database::query($sql); |
|
85 | - $row = Database::fetch_array($result); |
|
84 | + $result = Database::query($sql); |
|
85 | + $row = Database::fetch_array($result); |
|
86 | 86 | if (Database::num_rows($result) > 0) { |
87 | 87 | |
88 | - return $row['version']; |
|
89 | - } else { |
|
88 | + return $row['version']; |
|
89 | + } else { |
|
90 | 90 | |
91 | - return 0; |
|
92 | - } |
|
93 | - } |
|
91 | + return 0; |
|
92 | + } |
|
93 | + } |
|
94 | 94 | |
95 | - /** |
|
96 | - * Gets the data of a Term and condition by language |
|
97 | - * @param int $language language id |
|
98 | - * @return array all the info of a Term and condition |
|
99 | - */ |
|
100 | - public static function get_last_condition ($language) |
|
95 | + /** |
|
96 | + * Gets the data of a Term and condition by language |
|
97 | + * @param int $language language id |
|
98 | + * @return array all the info of a Term and condition |
|
99 | + */ |
|
100 | + public static function get_last_condition ($language) |
|
101 | 101 | { |
102 | - $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
|
103 | - $language= Database::escape_string($language); |
|
104 | - $sql = "SELECT * FROM $legal_conditions_table |
|
102 | + $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
|
103 | + $language= Database::escape_string($language); |
|
104 | + $sql = "SELECT * FROM $legal_conditions_table |
|
105 | 105 | WHERE language_id = '".$language."' |
106 | 106 | ORDER BY version DESC |
107 | 107 | LIMIT 1 "; |
108 | - $result = Database::query($sql); |
|
108 | + $result = Database::query($sql); |
|
109 | 109 | |
110 | - return Database::fetch_array($result); |
|
111 | - } |
|
110 | + return Database::fetch_array($result); |
|
111 | + } |
|
112 | 112 | |
113 | - /** |
|
114 | - * Gets the last version of a Term and condition by language |
|
115 | - * @param int $language language id |
|
116 | - * @return boolean | int the version or false if does not exist |
|
117 | - */ |
|
118 | - public static function get_last_version($language) |
|
113 | + /** |
|
114 | + * Gets the last version of a Term and condition by language |
|
115 | + * @param int $language language id |
|
116 | + * @return boolean | int the version or false if does not exist |
|
117 | + */ |
|
118 | + public static function get_last_version($language) |
|
119 | 119 | { |
120 | 120 | $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
121 | 121 | $language = intval($language); |
@@ -133,15 +133,15 @@ discard block |
||
133 | 133 | |
134 | 134 | return false; |
135 | 135 | } |
136 | - } |
|
136 | + } |
|
137 | 137 | |
138 | - /** |
|
139 | - * Show the last condition |
|
140 | - * @param array with type and content i.e array('type'=>'1', 'content'=>'hola'); |
|
138 | + /** |
|
139 | + * Show the last condition |
|
140 | + * @param array with type and content i.e array('type'=>'1', 'content'=>'hola'); |
|
141 | 141 | * |
142 | - * @return string html preview |
|
143 | - */ |
|
144 | - public static function show_last_condition($term_preview) |
|
142 | + * @return string html preview |
|
143 | + */ |
|
144 | + public static function show_last_condition($term_preview) |
|
145 | 145 | { |
146 | 146 | $preview = ''; |
147 | 147 | switch ($term_preview['type']) { |
@@ -167,80 +167,80 @@ discard block |
||
167 | 167 | default: |
168 | 168 | break; |
169 | 169 | } |
170 | - return $preview; |
|
171 | - } |
|
172 | - |
|
173 | - /** |
|
174 | - * Get the terms and condition table (only for maintenance) |
|
175 | - * @param int offset |
|
176 | - * @param int number of items |
|
177 | - * @param int column |
|
178 | - * @return array |
|
179 | - */ |
|
180 | - public static function get_legal_data($from, $number_of_items, $column) |
|
170 | + return $preview; |
|
171 | + } |
|
172 | + |
|
173 | + /** |
|
174 | + * Get the terms and condition table (only for maintenance) |
|
175 | + * @param int offset |
|
176 | + * @param int number of items |
|
177 | + * @param int column |
|
178 | + * @return array |
|
179 | + */ |
|
180 | + public static function get_legal_data($from, $number_of_items, $column) |
|
181 | 181 | { |
182 | - $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
|
183 | - $lang_table = Database::get_main_table(TABLE_MAIN_LANGUAGE); |
|
184 | - $from = intval($from); |
|
185 | - $number_of_items = intval($number_of_items); |
|
186 | - $column = intval($column); |
|
182 | + $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
|
183 | + $lang_table = Database::get_main_table(TABLE_MAIN_LANGUAGE); |
|
184 | + $from = intval($from); |
|
185 | + $number_of_items = intval($number_of_items); |
|
186 | + $column = intval($column); |
|
187 | 187 | |
188 | - $sql = "SELECT version, original_name as language, content, changes, type, FROM_UNIXTIME(date) |
|
188 | + $sql = "SELECT version, original_name as language, content, changes, type, FROM_UNIXTIME(date) |
|
189 | 189 | FROM $legal_conditions_table inner join $lang_table l on(language_id = l.id) "; |
190 | - $sql .= "ORDER BY language, version ASC "; |
|
191 | - $sql .= "LIMIT $from, $number_of_items "; |
|
192 | - |
|
193 | - $result = Database::query($sql); |
|
194 | - $legals = array (); |
|
195 | - $versions = array (); |
|
196 | - while ($legal = Database::fetch_array($result)) { |
|
197 | - // max 2000 chars |
|
198 | - //echo strlen($legal[1]); echo '<br>'; |
|
199 | - $versions[]=$legal[0]; |
|
200 | - $languages[]=$legal[1]; |
|
201 | - if (strlen($legal[2])>2000) |
|
202 | - $legal[2]= substr($legal[2],0,2000).' ... '; |
|
203 | - if ($legal[4]==0) |
|
204 | - $legal[4]= get_lang('HTMLText'); |
|
205 | - elseif($legal[4]==1) |
|
206 | - $legal[4]=get_lang('PageLink'); |
|
207 | - $legals[] = $legal; |
|
208 | - } |
|
209 | - return $legals; |
|
210 | - } |
|
211 | - |
|
212 | - /** |
|
213 | - * Gets the number of terms and conditions available |
|
214 | - * @return int |
|
215 | - */ |
|
216 | - public static function count() |
|
190 | + $sql .= "ORDER BY language, version ASC "; |
|
191 | + $sql .= "LIMIT $from, $number_of_items "; |
|
192 | + |
|
193 | + $result = Database::query($sql); |
|
194 | + $legals = array (); |
|
195 | + $versions = array (); |
|
196 | + while ($legal = Database::fetch_array($result)) { |
|
197 | + // max 2000 chars |
|
198 | + //echo strlen($legal[1]); echo '<br>'; |
|
199 | + $versions[]=$legal[0]; |
|
200 | + $languages[]=$legal[1]; |
|
201 | + if (strlen($legal[2])>2000) |
|
202 | + $legal[2]= substr($legal[2],0,2000).' ... '; |
|
203 | + if ($legal[4]==0) |
|
204 | + $legal[4]= get_lang('HTMLText'); |
|
205 | + elseif($legal[4]==1) |
|
206 | + $legal[4]=get_lang('PageLink'); |
|
207 | + $legals[] = $legal; |
|
208 | + } |
|
209 | + return $legals; |
|
210 | + } |
|
211 | + |
|
212 | + /** |
|
213 | + * Gets the number of terms and conditions available |
|
214 | + * @return int |
|
215 | + */ |
|
216 | + public static function count() |
|
217 | 217 | { |
218 | - $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
|
219 | - $sql = "SELECT count(*) as count_result |
|
218 | + $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
|
219 | + $sql = "SELECT count(*) as count_result |
|
220 | 220 | FROM $legal_conditions_table |
221 | 221 | ORDER BY legal_id DESC "; |
222 | - $result = Database::query($sql); |
|
223 | - $url = Database::fetch_array($result,'ASSOC'); |
|
224 | - $result = $url['count_result']; |
|
225 | - |
|
226 | - return $result; |
|
227 | - } |
|
228 | - |
|
229 | - /** |
|
230 | - * Get type of terms and conditions |
|
231 | - * @param int The legal id |
|
232 | - * @param int The language id |
|
233 | - * @return int The current type of terms and conditions |
|
234 | - */ |
|
235 | - public static function get_type_of_terms_and_conditions($legal_id, $language_id) |
|
222 | + $result = Database::query($sql); |
|
223 | + $url = Database::fetch_array($result,'ASSOC'); |
|
224 | + $result = $url['count_result']; |
|
225 | + |
|
226 | + return $result; |
|
227 | + } |
|
228 | + |
|
229 | + /** |
|
230 | + * Get type of terms and conditions |
|
231 | + * @param int The legal id |
|
232 | + * @param int The language id |
|
233 | + * @return int The current type of terms and conditions |
|
234 | + */ |
|
235 | + public static function get_type_of_terms_and_conditions($legal_id, $language_id) |
|
236 | 236 | { |
237 | - $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
|
238 | - $legal_id = intval($legal_id); |
|
239 | - $language_id = intval($language_id); |
|
240 | - $sql = 'SELECT type FROM '.$legal_conditions_table.' |
|
237 | + $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
|
238 | + $legal_id = intval($legal_id); |
|
239 | + $language_id = intval($language_id); |
|
240 | + $sql = 'SELECT type FROM '.$legal_conditions_table.' |
|
241 | 241 | WHERE legal_id="'.$legal_id.'" AND language_id="'.$language_id.'"'; |
242 | - $rs = Database::query($sql); |
|
242 | + $rs = Database::query($sql); |
|
243 | 243 | |
244 | - return Database::result($rs,0,'type'); |
|
245 | - } |
|
244 | + return Database::result($rs,0,'type'); |
|
245 | + } |
|
246 | 246 | } |
@@ -49,12 +49,12 @@ discard block |
||
49 | 49 | ); |
50 | 50 | } |
51 | 51 | |
52 | - /** |
|
53 | - * Displays the page header |
|
54 | - * @param string The name of the page (will be showed in the page title) |
|
55 | - * @param string Optional help file name |
|
56 | - * @param string $page_header |
|
57 | - */ |
|
52 | + /** |
|
53 | + * Displays the page header |
|
54 | + * @param string The name of the page (will be showed in the page title) |
|
55 | + * @param string Optional help file name |
|
56 | + * @param string $page_header |
|
57 | + */ |
|
58 | 58 | public static function display_header($tool_name ='', $help = null, $page_header = null) |
59 | 59 | { |
60 | 60 | $origin = api_get_origin(); |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | */ |
449 | 449 | public static function display_normal_message($message, $filter = true, $returnValue = false) |
450 | 450 | { |
451 | - $message = self::return_message($message, 'normal', $filter); |
|
451 | + $message = self::return_message($message, 'normal', $filter); |
|
452 | 452 | if ($returnValue) { |
453 | 453 | return $message; |
454 | 454 | } else { |
@@ -524,22 +524,22 @@ discard block |
||
524 | 524 | public static function return_message($message, $type = 'normal', $filter = true) |
525 | 525 | { |
526 | 526 | if ($filter) { |
527 | - $message = api_htmlentities($message, ENT_QUOTES, api_is_xml_http_request() ? 'UTF-8' : api_get_system_encoding()); |
|
527 | + $message = api_htmlentities($message, ENT_QUOTES, api_is_xml_http_request() ? 'UTF-8' : api_get_system_encoding()); |
|
528 | 528 | } |
529 | 529 | |
530 | 530 | $class = ""; |
531 | 531 | switch($type) { |
532 | 532 | case 'warning': |
533 | 533 | $class .= 'alert alert-warning'; |
534 | - break; |
|
534 | + break; |
|
535 | 535 | case 'error': |
536 | 536 | $class .= 'alert alert-danger'; |
537 | - break; |
|
537 | + break; |
|
538 | 538 | case 'confirmation': |
539 | 539 | case 'confirm': |
540 | 540 | case 'success': |
541 | 541 | $class .= 'alert alert-success'; |
542 | - break; |
|
542 | + break; |
|
543 | 543 | case 'normal': |
544 | 544 | default: |
545 | 545 | $class .= 'alert alert-info'; |
@@ -682,7 +682,7 @@ discard block |
||
682 | 682 | * @param array additional attributes (for instance height, width, onclick, ...) |
683 | 683 | * @param integer The wanted width of the icon (to be looked for in the corresponding img/icons/ folder) |
684 | 684 | * @return void |
685 | - */ |
|
685 | + */ |
|
686 | 686 | public static function display_icon( |
687 | 687 | $image, |
688 | 688 | $alt_text = '', |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | * @author Julio Montoya 2010 Function improved, adding image constants |
706 | 706 | * @author Yannick Warnier 2011 Added size handler |
707 | 707 | * @version Feb 2011 |
708 | - */ |
|
708 | + */ |
|
709 | 709 | public static function return_icon( |
710 | 710 | $image, |
711 | 711 | $alt_text = '', |
@@ -884,14 +884,14 @@ discard block |
||
884 | 884 | */ |
885 | 885 | public static function input($type, $name, $value, $attributes = array()) |
886 | 886 | { |
887 | - if (isset($type)) { |
|
888 | - $attributes['type']= $type; |
|
889 | - } |
|
890 | - if (isset($name)) { |
|
891 | - $attributes['name']= $name; |
|
892 | - } |
|
893 | - if (isset($value)) { |
|
894 | - $attributes['value']= $value; |
|
887 | + if (isset($type)) { |
|
888 | + $attributes['type']= $type; |
|
889 | + } |
|
890 | + if (isset($name)) { |
|
891 | + $attributes['name']= $name; |
|
892 | + } |
|
893 | + if (isset($value)) { |
|
894 | + $attributes['value']= $value; |
|
895 | 895 | } |
896 | 896 | return self::tag('input', '', $attributes); |
897 | 897 | } |
@@ -904,10 +904,10 @@ discard block |
||
904 | 904 | */ |
905 | 905 | public static function button($name, $value, $attributes = array()) |
906 | 906 | { |
907 | - if (!empty($name)) { |
|
907 | + if (!empty($name)) { |
|
908 | 908 | $attributes['name'] = $name; |
909 | - } |
|
910 | - return self::tag('button', $value, $attributes); |
|
909 | + } |
|
910 | + return self::tag('button', $value, $attributes); |
|
911 | 911 | } |
912 | 912 | |
913 | 913 | /** |
@@ -974,7 +974,7 @@ discard block |
||
974 | 974 | * in the $htmlHeadXtra variable before the display_header |
975 | 975 | * Add this script |
976 | 976 | * @example |
977 | - * <script> |
|
977 | + * <script> |
|
978 | 978 | $(function() { |
979 | 979 | $( "#tabs" ).tabs(); |
980 | 980 | }); |
@@ -1035,20 +1035,20 @@ discard block |
||
1035 | 1035 | */ |
1036 | 1036 | public static function tabsOnlyLink($headers, $selected = null) |
1037 | 1037 | { |
1038 | - $id = uniqid(); |
|
1039 | - $i = 1; |
|
1040 | - $lis = null; |
|
1041 | - foreach ($headers as $item) { |
|
1038 | + $id = uniqid(); |
|
1039 | + $i = 1; |
|
1040 | + $lis = null; |
|
1041 | + foreach ($headers as $item) { |
|
1042 | 1042 | $class = null; |
1043 | 1043 | if ($i == $selected) { |
1044 | 1044 | $class = 'active'; |
1045 | 1045 | } |
1046 | - $item = self::tag( |
|
1047 | - 'a', |
|
1048 | - $item['content'], |
|
1049 | - array('id' => $id.'-'.$i, 'href' => $item['url']) |
|
1050 | - ); |
|
1051 | - $lis .= self::tag('li', $item, array('class' => $class)); |
|
1046 | + $item = self::tag( |
|
1047 | + 'a', |
|
1048 | + $item['content'], |
|
1049 | + array('id' => $id.'-'.$i, 'href' => $item['url']) |
|
1050 | + ); |
|
1051 | + $lis .= self::tag('li', $item, array('class' => $class)); |
|
1052 | 1052 | $i++; |
1053 | 1053 | } |
1054 | 1054 | return self::tag('ul', $lis, array('class' => 'nav nav-tabs tabs-margin')); |
@@ -1260,8 +1260,8 @@ discard block |
||
1260 | 1260 | */ |
1261 | 1261 | public static function table($headers, $rows, $attributes = array()) |
1262 | 1262 | { |
1263 | - if (empty($attributes)) { |
|
1264 | - $attributes['class'] = 'data_table'; |
|
1263 | + if (empty($attributes)) { |
|
1264 | + $attributes['class'] = 'data_table'; |
|
1265 | 1265 | } |
1266 | 1266 | $table = new HTML_Table($attributes); |
1267 | 1267 | $row = 0; |
@@ -1269,17 +1269,17 @@ discard block |
||
1269 | 1269 | |
1270 | 1270 | // Course headers |
1271 | 1271 | if (!empty($headers)) { |
1272 | - foreach ($headers as $item) { |
|
1273 | - $table->setHeaderContents($row, $column, $item); |
|
1274 | - $column++; |
|
1275 | - } |
|
1276 | - $row = 1; |
|
1277 | - $column = 0; |
|
1272 | + foreach ($headers as $item) { |
|
1273 | + $table->setHeaderContents($row, $column, $item); |
|
1274 | + $column++; |
|
1275 | + } |
|
1276 | + $row = 1; |
|
1277 | + $column = 0; |
|
1278 | 1278 | } |
1279 | 1279 | |
1280 | 1280 | if (!empty($rows)) { |
1281 | - foreach($rows as $content) { |
|
1282 | - $table->setCellContents($row, $column, $content); |
|
1281 | + foreach($rows as $content) { |
|
1282 | + $table->setCellContents($row, $column, $content); |
|
1283 | 1283 | $row++; |
1284 | 1284 | } |
1285 | 1285 | } |
@@ -1385,7 +1385,7 @@ discard block |
||
1385 | 1385 | //$item_property['tool'] != TOOL_DROPBOX && |
1386 | 1386 | $item_property['tool'] != TOOL_NOTEBOOK && |
1387 | 1387 | $item_property['tool'] != TOOL_CHAT) |
1388 | - ) |
|
1388 | + ) |
|
1389 | 1389 | ) |
1390 | 1390 | // Take only what's visible or "invisible but where the user is a teacher" or where the visibility is unset. |
1391 | 1391 | && ($item_property['visibility'] == '1' |
@@ -1401,7 +1401,7 @@ discard block |
||
1401 | 1401 | ($item_property['to_user_id'] != $user_id) && |
1402 | 1402 | (!isset($item_property['to_group_id']) || !in_array($item_property['to_group_id'], $group_ids))) |
1403 | 1403 | ) { |
1404 | - continue; |
|
1404 | + continue; |
|
1405 | 1405 | } |
1406 | 1406 | |
1407 | 1407 | // If it's a survey, make sure the user's invited. Otherwise drop it. |
@@ -1620,21 +1620,21 @@ discard block |
||
1620 | 1620 | * |
1621 | 1621 | * @param string id of the rating ul element |
1622 | 1622 | * @param string url that will be added (for jquery see hot_courses.tpl) |
1623 | - * @param string point info array see function CourseManager::get_course_ranking() |
|
1624 | - * @param bool add a div wrapper |
|
1625 | - * @todo use templates |
|
1623 | + * @param string point info array see function CourseManager::get_course_ranking() |
|
1624 | + * @param bool add a div wrapper |
|
1625 | + * @todo use templates |
|
1626 | 1626 | **/ |
1627 | 1627 | public static function return_rating_system($id, $url, $point_info = array(), $add_div_wrapper = true) |
1628 | 1628 | { |
1629 | - $number_of_users_who_voted = isset($point_info['users_who_voted']) ? $point_info['users_who_voted'] : null; |
|
1630 | - $percentage = isset($point_info['point_average']) ? $point_info['point_average'] : 0; |
|
1629 | + $number_of_users_who_voted = isset($point_info['users_who_voted']) ? $point_info['users_who_voted'] : null; |
|
1630 | + $percentage = isset($point_info['point_average']) ? $point_info['point_average'] : 0; |
|
1631 | 1631 | |
1632 | - if (!empty($percentage)) { |
|
1632 | + if (!empty($percentage)) { |
|
1633 | 1633 | $percentage = $percentage*125/100; |
1634 | 1634 | } |
1635 | - $accesses = isset($point_info['accesses']) ? $point_info['accesses'] : 0; |
|
1635 | + $accesses = isset($point_info['accesses']) ? $point_info['accesses'] : 0; |
|
1636 | 1636 | |
1637 | - $star_label = sprintf(get_lang('XStarsOutOf5'), $point_info['point_average_star']); |
|
1637 | + $star_label = sprintf(get_lang('XStarsOutOf5'), $point_info['point_average_star']); |
|
1638 | 1638 | |
1639 | 1639 | $html = '<ul id="'.$id.'" class="star-rating"> |
1640 | 1640 | <li class="current-rating" style="width:'.$percentage.'px;"></li> |
@@ -1645,26 +1645,26 @@ discard block |
||
1645 | 1645 | <li><a href="javascript:void(0);" data-link="'.$url.'&star=5" title="'.$star_label.'" class="five-stars">5</a></li> |
1646 | 1646 | </ul>'; |
1647 | 1647 | |
1648 | - $labels = array(); |
|
1648 | + $labels = array(); |
|
1649 | 1649 | |
1650 | - $labels[]= $number_of_users_who_voted == 1 ? $number_of_users_who_voted.' '.get_lang('Vote') : $number_of_users_who_voted.' '.get_lang('Votes'); |
|
1651 | - $labels[]= $accesses == 1 ? $accesses.' '.get_lang('Visit') : $accesses.' '.get_lang('Visits'); |
|
1652 | - if (!empty($number_of_users_who_voted)) { |
|
1653 | - $labels[]= get_lang('Average').' '.$point_info['point_average_star'].'/5'; |
|
1654 | - } |
|
1650 | + $labels[]= $number_of_users_who_voted == 1 ? $number_of_users_who_voted.' '.get_lang('Vote') : $number_of_users_who_voted.' '.get_lang('Votes'); |
|
1651 | + $labels[]= $accesses == 1 ? $accesses.' '.get_lang('Visit') : $accesses.' '.get_lang('Visits'); |
|
1652 | + if (!empty($number_of_users_who_voted)) { |
|
1653 | + $labels[]= get_lang('Average').' '.$point_info['point_average_star'].'/5'; |
|
1654 | + } |
|
1655 | 1655 | |
1656 | - $labels[]= $point_info['user_vote'] ? get_lang('YourVote').' ['.$point_info['user_vote'].']' : get_lang('YourVote'). ' [?] '; |
|
1656 | + $labels[]= $point_info['user_vote'] ? get_lang('YourVote').' ['.$point_info['user_vote'].']' : get_lang('YourVote'). ' [?] '; |
|
1657 | 1657 | |
1658 | - if (!$add_div_wrapper && api_is_anonymous()) { |
|
1659 | - $labels[]= Display::tag('span', get_lang('LoginToVote'), array('class' => 'error')); |
|
1660 | - } |
|
1658 | + if (!$add_div_wrapper && api_is_anonymous()) { |
|
1659 | + $labels[]= Display::tag('span', get_lang('LoginToVote'), array('class' => 'error')); |
|
1660 | + } |
|
1661 | 1661 | |
1662 | 1662 | $html .= Display::div(implode(' | ', $labels) , array('id' => 'vote_label_'.$id, 'class' => 'vote_label_info')); |
1663 | 1663 | $html .= ' '.Display::span(' ', array('id' => 'vote_label2_'.$id)); |
1664 | 1664 | |
1665 | 1665 | if ($add_div_wrapper) { |
1666 | - $html = Display::div($html, array('id' => 'rating_wrapper_'.$id)); |
|
1667 | - } |
|
1666 | + $html = Display::div($html, array('id' => 'rating_wrapper_'.$id)); |
|
1667 | + } |
|
1668 | 1668 | |
1669 | 1669 | return $html; |
1670 | 1670 | } |
@@ -1702,8 +1702,8 @@ discard block |
||
1702 | 1702 | return self::page_header($title, $second_title); |
1703 | 1703 | } |
1704 | 1704 | |
1705 | - public static function page_subheader_and_translate($title, $second_title = null) |
|
1706 | - { |
|
1705 | + public static function page_subheader_and_translate($title, $second_title = null) |
|
1706 | + { |
|
1707 | 1707 | $title = get_lang($title); |
1708 | 1708 | return self::page_subheader($title, $second_title); |
1709 | 1709 | } |
@@ -6,115 +6,114 @@ 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 | - // init |
|
30 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
31 | - |
|
32 | - $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 | + // init |
|
29 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
30 | + |
|
31 | + $sql = "SELECT blog_name |
|
33 | 32 | FROM " . $tbl_blogs . " |
34 | 33 | WHERE c_id = $course_id AND blog_id = " . intval($blog_id); |
35 | 34 | |
36 | - $result = Database::query($sql); |
|
37 | - $blog = Database::fetch_array($result); |
|
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 |
|
35 | + $result = Database::query($sql); |
|
36 | + $blog = Database::fetch_array($result); |
|
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 Integer $course_id Id |
|
100 | - * @param String $title |
|
101 | - * @param Text $description |
|
102 | - */ |
|
103 | - public static function create_blog($title, $subtitle) |
|
104 | - { |
|
105 | - $_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 Integer $course_id Id |
|
99 | + * @param String $title |
|
100 | + * @param Text $description |
|
101 | + */ |
|
102 | + public static function create_blog($title, $subtitle) |
|
103 | + { |
|
104 | + $_user = api_get_user_info(); |
|
106 | 105 | $course_id = api_get_course_int_id(); |
107 | 106 | |
108 | - $current_date=date('Y-m-d H:i:s',time()); |
|
109 | - $session_id = api_get_session_id(); |
|
110 | - // Tabel definitions |
|
107 | + $current_date=date('Y-m-d H:i:s',time()); |
|
108 | + $session_id = api_get_session_id(); |
|
109 | + // Tabel definitions |
|
111 | 110 | $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
112 | 111 | $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST); |
113 | 112 | $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
114 | 113 | $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
115 | 114 | |
116 | - //verified if exist blog |
|
117 | - $sql = 'SELECT COUNT(*) as count FROM '.$tbl_blogs.' |
|
115 | + //verified if exist blog |
|
116 | + $sql = 'SELECT COUNT(*) as count FROM '.$tbl_blogs.' |
|
118 | 117 | WHERE |
119 | 118 | c_id = '.$course_id.' AND |
120 | 119 | blog_name="'.Database::escape_string($title).'" AND |
@@ -123,9 +122,9 @@ discard block |
||
123 | 122 | $info_count = Database::result($res, 0, 0); |
124 | 123 | |
125 | 124 | if ($info_count == 0) { |
126 | - // Create the blog |
|
125 | + // Create the blog |
|
127 | 126 | $params = [ |
128 | - 'blog_id' => 0, |
|
127 | + 'blog_id' => 0, |
|
129 | 128 | 'c_id' => $course_id, |
130 | 129 | 'blog_name' => $title, |
131 | 130 | 'blog_subtitle' => $subtitle, |
@@ -133,14 +132,14 @@ discard block |
||
133 | 132 | 'visibility' => 1 , |
134 | 133 | 'session_id' => $session_id, |
135 | 134 | ]; |
136 | - $this_blog_id = Database::insert($tbl_blogs, $params); |
|
135 | + $this_blog_id = Database::insert($tbl_blogs, $params); |
|
137 | 136 | |
138 | - if ($this_blog_id > 0) { |
|
137 | + if ($this_blog_id > 0) { |
|
139 | 138 | |
140 | 139 | $sql = "UPDATE $tbl_blogs SET blog_id = iid WHERE iid = $this_blog_id"; |
141 | 140 | Database::query($sql); |
142 | 141 | |
143 | - // insert into item_property |
|
142 | + // insert into item_property |
|
144 | 143 | api_item_property_update( |
145 | 144 | api_get_course_info(), |
146 | 145 | TOOL_BLOGS, |
@@ -148,12 +147,12 @@ discard block |
||
148 | 147 | 'BlogAdded', |
149 | 148 | api_get_user_id() |
150 | 149 | ); |
151 | - } |
|
150 | + } |
|
152 | 151 | |
153 | - // Make first post. :) |
|
152 | + // Make first post. :) |
|
154 | 153 | |
155 | 154 | $params = [ |
156 | - 'post_id' => 0, |
|
155 | + 'post_id' => 0, |
|
157 | 156 | 'c_id' => $course_id, |
158 | 157 | 'title' => get_lang("Welcome"), |
159 | 158 | 'full_text' => get_lang('FirstPostText'), |
@@ -167,10 +166,10 @@ discard block |
||
167 | 166 | Database::query($sql); |
168 | 167 | } |
169 | 168 | |
170 | - // Put it on course homepage |
|
171 | - $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, session_id) |
|
169 | + // Put it on course homepage |
|
170 | + $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, session_id) |
|
172 | 171 | 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')"; |
173 | - Database::query($sql); |
|
172 | + Database::query($sql); |
|
174 | 173 | |
175 | 174 | $toolId = Database::insert_id(); |
176 | 175 | if ($toolId) { |
@@ -178,37 +177,37 @@ discard block |
||
178 | 177 | Database::query($sql); |
179 | 178 | } |
180 | 179 | |
181 | - // Subscribe the teacher to this blog |
|
182 | - Blog::set_user_subscribed($this_blog_id, $_user['user_id']); |
|
183 | - } |
|
184 | - } |
|
185 | - |
|
186 | - /** |
|
187 | - * Update title and subtitle of a blog in the given course |
|
188 | - * @author Toon Keppens |
|
189 | - * @param Integer $course_id Id |
|
190 | - * @param String $title |
|
191 | - * @param Text $description |
|
192 | - */ |
|
193 | - public static function edit_blog($blog_id, $title, $subtitle) |
|
194 | - { |
|
195 | - // Table definitions |
|
196 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
197 | - $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST); |
|
180 | + // Subscribe the teacher to this blog |
|
181 | + Blog::set_user_subscribed($this_blog_id, $_user['user_id']); |
|
182 | + } |
|
183 | + } |
|
184 | + |
|
185 | + /** |
|
186 | + * Update title and subtitle of a blog in the given course |
|
187 | + * @author Toon Keppens |
|
188 | + * @param Integer $course_id Id |
|
189 | + * @param String $title |
|
190 | + * @param Text $description |
|
191 | + */ |
|
192 | + public static function edit_blog($blog_id, $title, $subtitle) |
|
193 | + { |
|
194 | + // Table definitions |
|
195 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
196 | + $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST); |
|
198 | 197 | |
199 | 198 | $course_id = api_get_course_int_id(); |
200 | 199 | |
201 | - // Update the blog |
|
202 | - $sql = "UPDATE $tbl_blogs SET |
|
200 | + // Update the blog |
|
201 | + $sql = "UPDATE $tbl_blogs SET |
|
203 | 202 | blog_name = '".Database::escape_string($title)."', |
204 | 203 | blog_subtitle = '".Database::escape_string($subtitle)."' |
205 | 204 | WHERE |
206 | 205 | c_id = $course_id AND |
207 | 206 | blog_id ='".Database::escape_string((int)$blog_id)."' |
208 | 207 | LIMIT 1"; |
209 | - Database::query($sql); |
|
208 | + Database::query($sql); |
|
210 | 209 | |
211 | - //update item_property (update) |
|
210 | + //update item_property (update) |
|
212 | 211 | api_item_property_update( |
213 | 212 | api_get_course_info(), |
214 | 213 | TOOL_BLOGS, |
@@ -217,60 +216,60 @@ discard block |
||
217 | 216 | api_get_user_id() |
218 | 217 | ); |
219 | 218 | |
220 | - // Update course homepage link |
|
221 | - $sql = "UPDATE $tbl_tool SET |
|
219 | + // Update course homepage link |
|
220 | + $sql = "UPDATE $tbl_tool SET |
|
222 | 221 | name = '".Database::escape_string($title)."' |
223 | 222 | WHERE c_id = $course_id AND link = 'blog/blog.php?blog_id=".(int)$blog_id."' LIMIT 1"; |
224 | - Database::query($sql); |
|
225 | - } |
|
226 | - |
|
227 | - /** |
|
228 | - * Deletes a blog and it's posts from the course database |
|
229 | - * @author Toon Keppens |
|
230 | - * @param Integer $blog_id |
|
231 | - */ |
|
232 | - public static function delete_blog($blog_id) |
|
233 | - { |
|
234 | - // Init |
|
223 | + Database::query($sql); |
|
224 | + } |
|
225 | + |
|
226 | + /** |
|
227 | + * Deletes a blog and it's posts from the course database |
|
228 | + * @author Toon Keppens |
|
229 | + * @param Integer $blog_id |
|
230 | + */ |
|
231 | + public static function delete_blog($blog_id) |
|
232 | + { |
|
233 | + // Init |
|
235 | 234 | $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
236 | 235 | $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
237 | 236 | $tbl_blogs_comment = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
238 | 237 | $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
239 | 238 | $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST); |
240 | 239 | $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
241 | - $tbl_blogs_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
240 | + $tbl_blogs_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
242 | 241 | |
243 | 242 | $course_id = api_get_course_int_id(); |
244 | 243 | $blog_id = intval($blog_id); |
245 | 244 | |
246 | - // Delete posts from DB and the attachments |
|
247 | - delete_all_blog_attachment($blog_id); |
|
245 | + // Delete posts from DB and the attachments |
|
246 | + delete_all_blog_attachment($blog_id); |
|
248 | 247 | |
249 | - //Delete comments |
|
250 | - $sql = "DELETE FROM $tbl_blogs_comment WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
251 | - Database::query($sql); |
|
248 | + //Delete comments |
|
249 | + $sql = "DELETE FROM $tbl_blogs_comment WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
250 | + Database::query($sql); |
|
252 | 251 | |
253 | - // Delete posts |
|
254 | - $sql = "DELETE FROM $tbl_blogs_posts WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
255 | - Database::query($sql); |
|
252 | + // Delete posts |
|
253 | + $sql = "DELETE FROM $tbl_blogs_posts WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
254 | + Database::query($sql); |
|
256 | 255 | |
257 | - // Delete tasks |
|
258 | - $sql = "DELETE FROM $tbl_blogs_tasks WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
259 | - Database::query($sql); |
|
256 | + // Delete tasks |
|
257 | + $sql = "DELETE FROM $tbl_blogs_tasks WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
258 | + Database::query($sql); |
|
260 | 259 | |
261 | - // Delete ratings |
|
262 | - $sql = "DELETE FROM $tbl_blogs_rating WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
263 | - Database::query($sql); |
|
260 | + // Delete ratings |
|
261 | + $sql = "DELETE FROM $tbl_blogs_rating WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
262 | + Database::query($sql); |
|
264 | 263 | |
265 | - // Delete blog |
|
266 | - $sql ="DELETE FROM $tbl_blogs WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
267 | - Database::query($sql); |
|
264 | + // Delete blog |
|
265 | + $sql ="DELETE FROM $tbl_blogs WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
266 | + Database::query($sql); |
|
268 | 267 | |
269 | - // Delete from course homepage |
|
270 | - $sql = "DELETE FROM $tbl_tool WHERE c_id = $course_id AND link = 'blog/blog.php?blog_id=".$blog_id."'"; |
|
271 | - Database::query($sql); |
|
268 | + // Delete from course homepage |
|
269 | + $sql = "DELETE FROM $tbl_tool WHERE c_id = $course_id AND link = 'blog/blog.php?blog_id=".$blog_id."'"; |
|
270 | + Database::query($sql); |
|
272 | 271 | |
273 | - //update item_property (delete) |
|
272 | + //update item_property (delete) |
|
274 | 273 | api_item_property_update( |
275 | 274 | api_get_course_info(), |
276 | 275 | TOOL_BLOGS, |
@@ -278,152 +277,152 @@ discard block |
||
278 | 277 | 'delete', |
279 | 278 | api_get_user_id() |
280 | 279 | ); |
281 | - } |
|
282 | - |
|
283 | - /** |
|
284 | - * Creates a new post in a given blog |
|
285 | - * @author Toon Keppens |
|
286 | - * @param String $title |
|
287 | - * @param String $full_text |
|
288 | - * @param Integer $blog_id |
|
289 | - */ |
|
290 | - public static function create_post($title, $full_text, $file_comment, $blog_id) |
|
291 | - { |
|
292 | - $_user = api_get_user_info(); |
|
293 | - $_course = api_get_course_info(); |
|
294 | - $course_id = $_course['real_id']; |
|
295 | - |
|
296 | - $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
297 | - $upload_ok=true; |
|
298 | - $has_attachment=false; |
|
299 | - $current_date = api_get_utc_datetime(); |
|
300 | - |
|
301 | - if (!empty($_FILES['user_upload']['name'])) { |
|
302 | - $upload_ok = process_uploaded_file($_FILES['user_upload']); |
|
303 | - $has_attachment=true; |
|
304 | - } |
|
305 | - |
|
306 | - if ($upload_ok) { |
|
307 | - // Table Definitions |
|
308 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
309 | - |
|
310 | - // Create the post |
|
311 | - $sql = "INSERT INTO $tbl_blogs_posts (c_id, title, full_text, date_creation, blog_id, author_id ) |
|
280 | + } |
|
281 | + |
|
282 | + /** |
|
283 | + * Creates a new post in a given blog |
|
284 | + * @author Toon Keppens |
|
285 | + * @param String $title |
|
286 | + * @param String $full_text |
|
287 | + * @param Integer $blog_id |
|
288 | + */ |
|
289 | + public static function create_post($title, $full_text, $file_comment, $blog_id) |
|
290 | + { |
|
291 | + $_user = api_get_user_info(); |
|
292 | + $_course = api_get_course_info(); |
|
293 | + $course_id = $_course['real_id']; |
|
294 | + |
|
295 | + $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
296 | + $upload_ok=true; |
|
297 | + $has_attachment=false; |
|
298 | + $current_date = api_get_utc_datetime(); |
|
299 | + |
|
300 | + if (!empty($_FILES['user_upload']['name'])) { |
|
301 | + $upload_ok = process_uploaded_file($_FILES['user_upload']); |
|
302 | + $has_attachment=true; |
|
303 | + } |
|
304 | + |
|
305 | + if ($upload_ok) { |
|
306 | + // Table Definitions |
|
307 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
308 | + |
|
309 | + // Create the post |
|
310 | + $sql = "INSERT INTO $tbl_blogs_posts (c_id, title, full_text, date_creation, blog_id, author_id ) |
|
312 | 311 | VALUES ($course_id, '".Database::escape_string($title)."', '".Database::escape_string($full_text)."','".$current_date."', '".(int)$blog_id."', '".(int)$_user['user_id']."');"; |
313 | 312 | |
314 | - Database::query($sql); |
|
315 | - $last_post_id = Database::insert_id(); |
|
313 | + Database::query($sql); |
|
314 | + $last_post_id = Database::insert_id(); |
|
316 | 315 | |
317 | 316 | if ($last_post_id) { |
318 | 317 | $sql = "UPDATE $tbl_blogs_posts SET post_id = iid WHERE iid = $last_post_id"; |
319 | 318 | Database::query($sql); |
320 | 319 | } |
321 | 320 | |
322 | - if ($has_attachment) { |
|
323 | - $courseDir = $_course['path'].'/upload/blog'; |
|
324 | - $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
325 | - $updir = $sys_course_path.$courseDir; |
|
326 | - |
|
327 | - // Try to add an extension to the file if it hasn't one |
|
328 | - $new_file_name = add_ext_on_mime(stripslashes($_FILES['user_upload']['name']), $_FILES['user_upload']['type']); |
|
329 | - |
|
330 | - // user's file name |
|
331 | - $file_name = $_FILES['user_upload']['name']; |
|
332 | - |
|
333 | - if (!filter_extension($new_file_name)) { |
|
334 | - Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); |
|
335 | - } else { |
|
336 | - $new_file_name = uniqid(''); |
|
337 | - $new_path = $updir.'/'.$new_file_name; |
|
338 | - $result = @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path); |
|
339 | - $comment = Database::escape_string($file_comment); |
|
340 | - |
|
341 | - // Storing the attachments if any |
|
342 | - if ($result) { |
|
343 | - $sql = 'INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size, blog_id,comment_id) '. |
|
344 | - "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' )"; |
|
345 | - Database::query($sql); |
|
321 | + if ($has_attachment) { |
|
322 | + $courseDir = $_course['path'].'/upload/blog'; |
|
323 | + $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
324 | + $updir = $sys_course_path.$courseDir; |
|
325 | + |
|
326 | + // Try to add an extension to the file if it hasn't one |
|
327 | + $new_file_name = add_ext_on_mime(stripslashes($_FILES['user_upload']['name']), $_FILES['user_upload']['type']); |
|
328 | + |
|
329 | + // user's file name |
|
330 | + $file_name = $_FILES['user_upload']['name']; |
|
331 | + |
|
332 | + if (!filter_extension($new_file_name)) { |
|
333 | + Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); |
|
334 | + } else { |
|
335 | + $new_file_name = uniqid(''); |
|
336 | + $new_path = $updir.'/'.$new_file_name; |
|
337 | + $result = @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path); |
|
338 | + $comment = Database::escape_string($file_comment); |
|
339 | + |
|
340 | + // Storing the attachments if any |
|
341 | + if ($result) { |
|
342 | + $sql = 'INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size, blog_id,comment_id) '. |
|
343 | + "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' )"; |
|
344 | + Database::query($sql); |
|
346 | 345 | $id = Database::insert_id(); |
347 | 346 | if ($id) { |
348 | 347 | $sql = "UPDATE $blog_table_attachment SET id = iid WHERE iid = $id"; |
349 | 348 | Database::query($sql); |
350 | 349 | } |
351 | - } |
|
352 | - } |
|
353 | - } |
|
354 | - } else { |
|
355 | - Display::display_error_message(get_lang('UplNoFileUploaded')); |
|
356 | - } |
|
357 | - } |
|
358 | - |
|
359 | - /** |
|
360 | - * Edits a post in a given blog |
|
361 | - * @author Toon Keppens |
|
362 | - * @param Integer $blog_id |
|
363 | - * @param String $title |
|
364 | - * @param String $full_text |
|
365 | - * @param Integer $blog_id |
|
366 | - */ |
|
367 | - public static function edit_post($post_id, $title, $full_text, $blog_id) |
|
368 | - { |
|
369 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
350 | + } |
|
351 | + } |
|
352 | + } |
|
353 | + } else { |
|
354 | + Display::display_error_message(get_lang('UplNoFileUploaded')); |
|
355 | + } |
|
356 | + } |
|
357 | + |
|
358 | + /** |
|
359 | + * Edits a post in a given blog |
|
360 | + * @author Toon Keppens |
|
361 | + * @param Integer $blog_id |
|
362 | + * @param String $title |
|
363 | + * @param String $full_text |
|
364 | + * @param Integer $blog_id |
|
365 | + */ |
|
366 | + public static function edit_post($post_id, $title, $full_text, $blog_id) |
|
367 | + { |
|
368 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
370 | 369 | $course_id = api_get_course_int_id(); |
371 | 370 | |
372 | - // Create the post |
|
373 | - $sql = "UPDATE $tbl_blogs_posts SET |
|
371 | + // Create the post |
|
372 | + $sql = "UPDATE $tbl_blogs_posts SET |
|
374 | 373 | title = '" . Database::escape_string($title)."', |
375 | 374 | full_text = '" . Database::escape_string($full_text)."' |
376 | 375 | WHERE c_id = $course_id AND post_id ='".(int)$post_id."' AND blog_id ='".(int)$blog_id."' |
377 | 376 | LIMIT 1 "; |
378 | - Database::query($sql); |
|
379 | - } |
|
380 | - |
|
381 | - /** |
|
382 | - * Deletes an article and it's comments |
|
383 | - * @author Toon Keppens |
|
384 | - * @param int $blog_id |
|
385 | - * @param int $post_id |
|
386 | - */ |
|
387 | - public static function delete_post($blog_id, $post_id) |
|
388 | - { |
|
389 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
390 | - $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
391 | - $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
377 | + Database::query($sql); |
|
378 | + } |
|
379 | + |
|
380 | + /** |
|
381 | + * Deletes an article and it's comments |
|
382 | + * @author Toon Keppens |
|
383 | + * @param int $blog_id |
|
384 | + * @param int $post_id |
|
385 | + */ |
|
386 | + public static function delete_post($blog_id, $post_id) |
|
387 | + { |
|
388 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
389 | + $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
390 | + $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
392 | 391 | |
393 | 392 | $course_id = api_get_course_int_id(); |
394 | 393 | |
395 | - // Delete ratings on this comment |
|
396 | - $sql = "DELETE FROM $tbl_blogs_rating |
|
394 | + // Delete ratings on this comment |
|
395 | + $sql = "DELETE FROM $tbl_blogs_rating |
|
397 | 396 | WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND item_id = '".(int)$post_id."' AND rating_type = 'post'"; |
398 | - Database::query($sql); |
|
397 | + Database::query($sql); |
|
399 | 398 | |
400 | - // Delete the post |
|
401 | - $sql = "DELETE FROM $tbl_blogs_posts |
|
399 | + // Delete the post |
|
400 | + $sql = "DELETE FROM $tbl_blogs_posts |
|
402 | 401 | WHERE c_id = $course_id AND post_id = '".(int)$post_id."'"; |
403 | - Database::query($sql); |
|
402 | + Database::query($sql); |
|
404 | 403 | |
405 | - // Delete the comments |
|
406 | - $sql = "DELETE FROM $tbl_blogs_comments |
|
404 | + // Delete the comments |
|
405 | + $sql = "DELETE FROM $tbl_blogs_comments |
|
407 | 406 | WHERE c_id = $course_id AND post_id = '".(int)$post_id."' AND blog_id = '".(int)$blog_id."'"; |
408 | - Database::query($sql); |
|
409 | - |
|
410 | - // Delete posts and attachments |
|
411 | - delete_all_blog_attachment($blog_id,$post_id); |
|
412 | - } |
|
413 | - |
|
414 | - /** |
|
415 | - * Creates a comment on a post in a given blog |
|
416 | - * @author Toon Keppens |
|
417 | - * @param String $title |
|
418 | - * @param String $full_text |
|
419 | - * @param Integer $blog_id |
|
420 | - * @param Integer $post_id |
|
421 | - * @param Integer $parent_id |
|
422 | - */ |
|
423 | - public static function create_comment($title, $full_text, $file_comment, $blog_id, $post_id, $parent_id, $task_id = 'NULL') |
|
424 | - { |
|
425 | - $_user = api_get_user_info(); |
|
426 | - $_course = api_get_course_info(); |
|
407 | + Database::query($sql); |
|
408 | + |
|
409 | + // Delete posts and attachments |
|
410 | + delete_all_blog_attachment($blog_id,$post_id); |
|
411 | + } |
|
412 | + |
|
413 | + /** |
|
414 | + * Creates a comment on a post in a given blog |
|
415 | + * @author Toon Keppens |
|
416 | + * @param String $title |
|
417 | + * @param String $full_text |
|
418 | + * @param Integer $blog_id |
|
419 | + * @param Integer $post_id |
|
420 | + * @param Integer $parent_id |
|
421 | + */ |
|
422 | + public static function create_comment($title, $full_text, $file_comment, $blog_id, $post_id, $parent_id, $task_id = 'NULL') |
|
423 | + { |
|
424 | + $_user = api_get_user_info(); |
|
425 | + $_course = api_get_course_info(); |
|
427 | 426 | $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
428 | 427 | |
429 | 428 | $upload_ok = true; |
@@ -431,55 +430,55 @@ discard block |
||
431 | 430 | $current_date = api_get_utc_datetime(); |
432 | 431 | $course_id = api_get_course_int_id(); |
433 | 432 | |
434 | - if (!empty($_FILES['user_upload']['name'])) { |
|
435 | - $upload_ok = process_uploaded_file($_FILES['user_upload']); |
|
436 | - $has_attachment=true; |
|
437 | - } |
|
433 | + if (!empty($_FILES['user_upload']['name'])) { |
|
434 | + $upload_ok = process_uploaded_file($_FILES['user_upload']); |
|
435 | + $has_attachment=true; |
|
436 | + } |
|
438 | 437 | |
439 | - if ($upload_ok) { |
|
440 | - // Table Definition |
|
441 | - $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
438 | + if ($upload_ok) { |
|
439 | + // Table Definition |
|
440 | + $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
442 | 441 | |
443 | - // Create the comment |
|
444 | - $sql = "INSERT INTO $tbl_blogs_comments (c_id, title, comment, author_id, date_creation, blog_id, post_id, parent_comment_id, task_id ) |
|
442 | + // Create the comment |
|
443 | + $sql = "INSERT INTO $tbl_blogs_comments (c_id, title, comment, author_id, date_creation, blog_id, post_id, parent_comment_id, task_id ) |
|
445 | 444 | 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."')"; |
446 | - Database::query($sql); |
|
445 | + Database::query($sql); |
|
447 | 446 | |
448 | - // Empty post values, or they are shown on the page again |
|
449 | - $last_id = Database::insert_id(); |
|
447 | + // Empty post values, or they are shown on the page again |
|
448 | + $last_id = Database::insert_id(); |
|
450 | 449 | |
451 | 450 | if ($last_id) { |
452 | 451 | $sql = "UPDATE $tbl_blogs_comments SET comment_id = iid WHERE iid = $last_id"; |
453 | 452 | Database::query($sql); |
454 | 453 | } |
455 | 454 | |
456 | - if ($has_attachment) { |
|
457 | - $courseDir = $_course['path'].'/upload/blog'; |
|
458 | - $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
459 | - $updir = $sys_course_path.$courseDir; |
|
460 | - |
|
461 | - // Try to add an extension to the file if it hasn't one |
|
462 | - $new_file_name = add_ext_on_mime( |
|
463 | - stripslashes($_FILES['user_upload']['name']), |
|
464 | - $_FILES['user_upload']['type'] |
|
465 | - ); |
|
466 | - |
|
467 | - // user's file name |
|
468 | - $file_name =$_FILES['user_upload']['name']; |
|
469 | - |
|
470 | - if (!filter_extension($new_file_name)) { |
|
471 | - Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); |
|
472 | - } else { |
|
473 | - $new_file_name = uniqid(''); |
|
474 | - $new_path=$updir.'/'.$new_file_name; |
|
475 | - $result= @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path); |
|
476 | - $comment = Database::escape_string($file_comment); |
|
477 | - |
|
478 | - // Storing the attachments if any |
|
479 | - if ($result) { |
|
480 | - $sql='INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size,blog_id,comment_id) '. |
|
481 | - "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."' )"; |
|
482 | - Database::query($sql); |
|
455 | + if ($has_attachment) { |
|
456 | + $courseDir = $_course['path'].'/upload/blog'; |
|
457 | + $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
458 | + $updir = $sys_course_path.$courseDir; |
|
459 | + |
|
460 | + // Try to add an extension to the file if it hasn't one |
|
461 | + $new_file_name = add_ext_on_mime( |
|
462 | + stripslashes($_FILES['user_upload']['name']), |
|
463 | + $_FILES['user_upload']['type'] |
|
464 | + ); |
|
465 | + |
|
466 | + // user's file name |
|
467 | + $file_name =$_FILES['user_upload']['name']; |
|
468 | + |
|
469 | + if (!filter_extension($new_file_name)) { |
|
470 | + Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); |
|
471 | + } else { |
|
472 | + $new_file_name = uniqid(''); |
|
473 | + $new_path=$updir.'/'.$new_file_name; |
|
474 | + $result= @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path); |
|
475 | + $comment = Database::escape_string($file_comment); |
|
476 | + |
|
477 | + // Storing the attachments if any |
|
478 | + if ($result) { |
|
479 | + $sql='INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size,blog_id,comment_id) '. |
|
480 | + "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."' )"; |
|
481 | + Database::query($sql); |
|
483 | 482 | |
484 | 483 | $id = Database::insert_id(); |
485 | 484 | |
@@ -487,92 +486,92 @@ discard block |
||
487 | 486 | $sql = "UPDATE $blog_table_attachment SET id = iid WHERE iid = $id"; |
488 | 487 | Database::query($sql); |
489 | 488 | } |
490 | - } |
|
491 | - } |
|
492 | - } |
|
493 | - } |
|
494 | - } |
|
495 | - |
|
496 | - /** |
|
497 | - * Deletes a comment from a blogpost |
|
498 | - * @author Toon Keppens |
|
499 | - * @param int $blog_id |
|
500 | - * @param int $comment_id |
|
501 | - */ |
|
502 | - public static function delete_comment($blog_id, $post_id, $comment_id) |
|
503 | - { |
|
504 | - $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
505 | - $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
506 | - $blog_id = intval($blog_id); |
|
507 | - $post_id = intval($post_id); |
|
508 | - $comment_id = intval($comment_id); |
|
489 | + } |
|
490 | + } |
|
491 | + } |
|
492 | + } |
|
493 | + } |
|
494 | + |
|
495 | + /** |
|
496 | + * Deletes a comment from a blogpost |
|
497 | + * @author Toon Keppens |
|
498 | + * @param int $blog_id |
|
499 | + * @param int $comment_id |
|
500 | + */ |
|
501 | + public static function delete_comment($blog_id, $post_id, $comment_id) |
|
502 | + { |
|
503 | + $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
504 | + $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
505 | + $blog_id = intval($blog_id); |
|
506 | + $post_id = intval($post_id); |
|
507 | + $comment_id = intval($comment_id); |
|
509 | 508 | $course_id = api_get_course_int_id(); |
510 | 509 | |
511 | - delete_all_blog_attachment($blog_id, $post_id, $comment_id); |
|
510 | + delete_all_blog_attachment($blog_id, $post_id, $comment_id); |
|
512 | 511 | |
513 | - // Delete ratings on this comment |
|
514 | - $sql = "DELETE FROM $tbl_blogs_rating |
|
512 | + // Delete ratings on this comment |
|
513 | + $sql = "DELETE FROM $tbl_blogs_rating |
|
515 | 514 | WHERE |
516 | 515 | c_id = $course_id AND |
517 | 516 | blog_id = '".$blog_id."' AND |
518 | 517 | item_id = '".$comment_id."' AND |
519 | 518 | rating_type = 'comment'"; |
520 | - Database::query($sql); |
|
519 | + Database::query($sql); |
|
521 | 520 | |
522 | - // select comments that have the selected comment as their parent |
|
523 | - $sql = "SELECT comment_id FROM $tbl_blogs_comments |
|
521 | + // select comments that have the selected comment as their parent |
|
522 | + $sql = "SELECT comment_id FROM $tbl_blogs_comments |
|
524 | 523 | WHERE c_id = $course_id AND parent_comment_id = '".$comment_id."'"; |
525 | - $result = Database::query($sql); |
|
524 | + $result = Database::query($sql); |
|
526 | 525 | |
527 | - // Delete them recursively |
|
528 | - while ($comment = Database::fetch_array($result)) { |
|
529 | - Blog::delete_comment($blog_id,$post_id,$comment['comment_id']); |
|
530 | - } |
|
526 | + // Delete them recursively |
|
527 | + while ($comment = Database::fetch_array($result)) { |
|
528 | + Blog::delete_comment($blog_id,$post_id,$comment['comment_id']); |
|
529 | + } |
|
531 | 530 | |
532 | - // Finally, delete the selected comment to |
|
533 | - $sql = "DELETE FROM $tbl_blogs_comments |
|
531 | + // Finally, delete the selected comment to |
|
532 | + $sql = "DELETE FROM $tbl_blogs_comments |
|
534 | 533 | WHERE c_id = $course_id AND comment_id = '".$comment_id."'"; |
535 | - Database::query($sql); |
|
536 | - } |
|
537 | - |
|
538 | - /** |
|
539 | - * Creates a new task in a blog |
|
540 | - * @author Toon Keppens |
|
541 | - * @param Integer $blog_id |
|
542 | - * @param String $title |
|
543 | - * @param String $description |
|
544 | - * @param String $color |
|
545 | - */ |
|
546 | - public static function create_task($blog_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color) |
|
547 | - { |
|
548 | - // Init |
|
549 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
550 | - $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
551 | - |
|
552 | - $course_id = api_get_course_int_id(); |
|
553 | - |
|
554 | - // Create the task |
|
555 | - $sql = "INSERT INTO $tbl_blogs_tasks (c_id, blog_id, title, description, color, system_task) |
|
534 | + Database::query($sql); |
|
535 | + } |
|
536 | + |
|
537 | + /** |
|
538 | + * Creates a new task in a blog |
|
539 | + * @author Toon Keppens |
|
540 | + * @param Integer $blog_id |
|
541 | + * @param String $title |
|
542 | + * @param String $description |
|
543 | + * @param String $color |
|
544 | + */ |
|
545 | + public static function create_task($blog_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color) |
|
546 | + { |
|
547 | + // Init |
|
548 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
549 | + $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
550 | + |
|
551 | + $course_id = api_get_course_int_id(); |
|
552 | + |
|
553 | + // Create the task |
|
554 | + $sql = "INSERT INTO $tbl_blogs_tasks (c_id, blog_id, title, description, color, system_task) |
|
556 | 555 | VALUES ($course_id , '".(int)$blog_id."', '" . Database::escape_string($title)."', '" . Database::escape_string($description)."', '" . Database::escape_string($color)."', '0');"; |
557 | - Database::query($sql); |
|
556 | + Database::query($sql); |
|
558 | 557 | |
559 | - $task_id = Database::insert_id(); |
|
558 | + $task_id = Database::insert_id(); |
|
560 | 559 | |
561 | 560 | if ($task_id) { |
562 | 561 | $sql = "UPDATE $tbl_blogs_tasks SET task_id = iid WHERE iid = $task_id"; |
563 | 562 | Database::query($sql); |
564 | 563 | } |
565 | 564 | |
566 | - $tool = 'BLOG_' . $blog_id; |
|
565 | + $tool = 'BLOG_' . $blog_id; |
|
567 | 566 | |
568 | - if ($articleDelete == 'on') { |
|
569 | - $sql = " INSERT INTO " . $tbl_tasks_permissions . " ( c_id, task_id, tool, action) VALUES ( |
|
567 | + if ($articleDelete == 'on') { |
|
568 | + $sql = " INSERT INTO " . $tbl_tasks_permissions . " ( c_id, task_id, tool, action) VALUES ( |
|
570 | 569 | '" . (int)$course_id . "', |
571 | 570 | '" . (int)$task_id . "', |
572 | 571 | '" . Database::escape_string($tool) . "', |
573 | 572 | 'article_delete' |
574 | 573 | )"; |
575 | - Database::query($sql); |
|
574 | + Database::query($sql); |
|
576 | 575 | |
577 | 576 | $id = Database::insert_id(); |
578 | 577 | |
@@ -582,172 +581,172 @@ discard block |
||
582 | 581 | } |
583 | 582 | } |
584 | 583 | |
585 | - if ($articleEdit == 'on') { |
|
586 | - $sql = " |
|
584 | + if ($articleEdit == 'on') { |
|
585 | + $sql = " |
|
587 | 586 | INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action ) VALUES ( |
588 | 587 | '" . (int)$course_id . "', |
589 | 588 | '" . (int)$task_id . "', |
590 | 589 | '" . Database::escape_string($tool) . "', |
591 | 590 | 'article_edit' |
592 | 591 | )"; |
593 | - Database::query($sql); |
|
592 | + Database::query($sql); |
|
594 | 593 | $id = Database::insert_id(); |
595 | 594 | |
596 | 595 | if ($id) { |
597 | 596 | $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id"; |
598 | 597 | Database::query($sql); |
599 | 598 | } |
600 | - } |
|
599 | + } |
|
601 | 600 | |
602 | - if ($commentsDelete == 'on') { |
|
603 | - $sql = " |
|
601 | + if ($commentsDelete == 'on') { |
|
602 | + $sql = " |
|
604 | 603 | INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action ) VALUES ( |
605 | 604 | '" . (int)$course_id . "', |
606 | 605 | '" . (int)$task_id . "', |
607 | 606 | '" . Database::escape_string($tool) . "', |
608 | 607 | 'article_comments_delete' |
609 | 608 | )"; |
610 | - Database::query($sql); |
|
609 | + Database::query($sql); |
|
611 | 610 | $id = Database::insert_id(); |
612 | 611 | |
613 | 612 | if ($id) { |
614 | 613 | $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id"; |
615 | 614 | Database::query($sql); |
616 | 615 | } |
617 | - } |
|
618 | - } |
|
619 | - |
|
620 | - /** |
|
621 | - * Edit a task in a blog |
|
622 | - * @author Toon Keppens |
|
623 | - * @param Integer $task_id |
|
624 | - * @param String $title |
|
625 | - * @param String $description |
|
626 | - * @param String $color |
|
627 | - */ |
|
628 | - public static function edit_task($blog_id, $task_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color) |
|
629 | - { |
|
630 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
631 | - $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
616 | + } |
|
617 | + } |
|
618 | + |
|
619 | + /** |
|
620 | + * Edit a task in a blog |
|
621 | + * @author Toon Keppens |
|
622 | + * @param Integer $task_id |
|
623 | + * @param String $title |
|
624 | + * @param String $description |
|
625 | + * @param String $color |
|
626 | + */ |
|
627 | + public static function edit_task($blog_id, $task_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color) |
|
628 | + { |
|
629 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
630 | + $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
632 | 631 | |
633 | 632 | $course_id = api_get_course_int_id(); |
634 | 633 | |
635 | - // Create the task |
|
636 | - $sql = "UPDATE $tbl_blogs_tasks SET |
|
634 | + // Create the task |
|
635 | + $sql = "UPDATE $tbl_blogs_tasks SET |
|
637 | 636 | title = '".Database::escape_string($title)."', |
638 | 637 | description = '".Database::escape_string($description)."', |
639 | 638 | color = '".Database::escape_string($color)."' |
640 | 639 | WHERE c_id = $course_id AND task_id ='".(int)$task_id."' LIMIT 1"; |
641 | - Database::query($sql); |
|
640 | + Database::query($sql); |
|
642 | 641 | |
643 | - $tool = 'BLOG_' . $blog_id; |
|
642 | + $tool = 'BLOG_' . $blog_id; |
|
644 | 643 | |
645 | - $sql = "DELETE FROM " . $tbl_tasks_permissions . " |
|
644 | + $sql = "DELETE FROM " . $tbl_tasks_permissions . " |
|
646 | 645 | WHERE c_id = $course_id AND task_id = '" . (int)$task_id."'"; |
647 | - Database::query($sql); |
|
646 | + Database::query($sql); |
|
648 | 647 | |
649 | - if ($articleDelete == 'on') { |
|
650 | - $sql = "INSERT INTO " . $tbl_tasks_permissions . " ( c_id, task_id, tool, action) VALUES ( |
|
648 | + if ($articleDelete == 'on') { |
|
649 | + $sql = "INSERT INTO " . $tbl_tasks_permissions . " ( c_id, task_id, tool, action) VALUES ( |
|
651 | 650 | '" . (int)$course_id . "', |
652 | 651 | '" . (int)$task_id . "', |
653 | 652 | '" . Database::escape_string($tool) . "', |
654 | 653 | 'article_delete' |
655 | 654 | )"; |
656 | - Database::query($sql); |
|
655 | + Database::query($sql); |
|
657 | 656 | $id = Database::insert_id(); |
658 | 657 | |
659 | 658 | if ($id) { |
660 | 659 | $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id"; |
661 | 660 | Database::query($sql); |
662 | 661 | } |
663 | - } |
|
662 | + } |
|
664 | 663 | |
665 | - if ($articleEdit == 'on') { |
|
666 | - $sql = "INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES ( |
|
664 | + if ($articleEdit == 'on') { |
|
665 | + $sql = "INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES ( |
|
667 | 666 | '" . (int)$course_id . "', |
668 | 667 | '" . (int)$task_id . "', |
669 | 668 | '" . Database::escape_string($tool) . "', |
670 | 669 | 'article_edit' |
671 | 670 | )"; |
672 | - Database::query($sql); |
|
671 | + Database::query($sql); |
|
673 | 672 | $id = Database::insert_id(); |
674 | 673 | |
675 | 674 | if ($id) { |
676 | 675 | $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id"; |
677 | 676 | Database::query($sql); |
678 | 677 | } |
679 | - } |
|
678 | + } |
|
680 | 679 | |
681 | - if ($commentsDelete == 'on') { |
|
682 | - $sql = " INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES ( |
|
680 | + if ($commentsDelete == 'on') { |
|
681 | + $sql = " INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES ( |
|
683 | 682 | '" . (int)$course_id . "', |
684 | 683 | '" . (int)$task_id . "', |
685 | 684 | '" . Database::escape_string($tool) . "', |
686 | 685 | 'article_comments_delete' |
687 | 686 | )"; |
688 | - Database::query($sql); |
|
687 | + Database::query($sql); |
|
689 | 688 | $id = Database::insert_id(); |
690 | 689 | |
691 | 690 | if ($id) { |
692 | 691 | $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id"; |
693 | 692 | Database::query($sql); |
694 | 693 | } |
695 | - } |
|
696 | - } |
|
697 | - |
|
698 | - /** |
|
699 | - * Deletes a task from a blog |
|
700 | - * @param Integer $blog_id |
|
701 | - * @param Integer $task_id |
|
702 | - */ |
|
703 | - public static function delete_task($blog_id, $task_id) |
|
704 | - { |
|
705 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
706 | - $course_id = api_get_course_int_id(); |
|
707 | - |
|
708 | - // Delete posts |
|
709 | - $sql = "DELETE FROM $tbl_blogs_tasks |
|
694 | + } |
|
695 | + } |
|
696 | + |
|
697 | + /** |
|
698 | + * Deletes a task from a blog |
|
699 | + * @param Integer $blog_id |
|
700 | + * @param Integer $task_id |
|
701 | + */ |
|
702 | + public static function delete_task($blog_id, $task_id) |
|
703 | + { |
|
704 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
705 | + $course_id = api_get_course_int_id(); |
|
706 | + |
|
707 | + // Delete posts |
|
708 | + $sql = "DELETE FROM $tbl_blogs_tasks |
|
710 | 709 | WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND task_id = '".(int)$task_id."'"; |
711 | - Database::query($sql); |
|
712 | - } |
|
713 | - |
|
714 | - /** |
|
715 | - * Deletes an assigned task from a blog |
|
716 | - * @param Integer $blog_id |
|
717 | - * @param Integer $assignment_id |
|
718 | - */ |
|
719 | - public static function delete_assigned_task($blog_id, $task_id, $user_id) |
|
720 | - { |
|
721 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
710 | + Database::query($sql); |
|
711 | + } |
|
712 | + |
|
713 | + /** |
|
714 | + * Deletes an assigned task from a blog |
|
715 | + * @param Integer $blog_id |
|
716 | + * @param Integer $assignment_id |
|
717 | + */ |
|
718 | + public static function delete_assigned_task($blog_id, $task_id, $user_id) |
|
719 | + { |
|
720 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
722 | 721 | $course_id = api_get_course_int_id(); |
723 | 722 | |
724 | - // Delete posts |
|
725 | - $sql = "DELETE FROM $tbl_blogs_tasks_rel_user |
|
723 | + // Delete posts |
|
724 | + $sql = "DELETE FROM $tbl_blogs_tasks_rel_user |
|
726 | 725 | WHERE |
727 | 726 | c_id = $course_id AND |
728 | 727 | blog_id = '".(int)$blog_id."' AND |
729 | 728 | task_id = '".(int)$task_id."' AND |
730 | 729 | user_id = '".(int)$user_id."'"; |
731 | - Database::query($sql); |
|
732 | - } |
|
733 | - |
|
734 | - /** |
|
735 | - * Get personal task list |
|
736 | - * @author Toon Keppens |
|
737 | - * @return Returns an unsorted list (<ul></ul>) with the users' tasks |
|
738 | - */ |
|
739 | - public static function get_personal_task_list() |
|
740 | - { |
|
741 | - $_user = api_get_user_info(); |
|
742 | - |
|
743 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
744 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
745 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
746 | - |
|
747 | - $course_id = api_get_course_int_id(); |
|
748 | - |
|
749 | - if ($_user['user_id']) { |
|
750 | - $sql = "SELECT task_rel_user.*, task.title, blog.blog_name |
|
730 | + Database::query($sql); |
|
731 | + } |
|
732 | + |
|
733 | + /** |
|
734 | + * Get personal task list |
|
735 | + * @author Toon Keppens |
|
736 | + * @return Returns an unsorted list (<ul></ul>) with the users' tasks |
|
737 | + */ |
|
738 | + public static function get_personal_task_list() |
|
739 | + { |
|
740 | + $_user = api_get_user_info(); |
|
741 | + |
|
742 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
743 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
744 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
745 | + |
|
746 | + $course_id = api_get_course_int_id(); |
|
747 | + |
|
748 | + if ($_user['user_id']) { |
|
749 | + $sql = "SELECT task_rel_user.*, task.title, blog.blog_name |
|
751 | 750 | FROM $tbl_blogs_tasks_rel_user task_rel_user |
752 | 751 | INNER JOIN $tbl_blogs_tasks task |
753 | 752 | ON task_rel_user.task_id = task.task_id |
@@ -761,85 +760,85 @@ discard block |
||
761 | 760 | task_rel_user.user_id = ".(int)$_user['user_id']." |
762 | 761 | ORDER BY target_date ASC"; |
763 | 762 | |
764 | - $result = Database::query($sql); |
|
765 | - |
|
766 | - if (Database::num_rows($result) > 0) { |
|
767 | - echo '<ul>'; |
|
768 | - while ($mytask = Database::fetch_array($result)) { |
|
769 | - 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>'; |
|
770 | - } |
|
771 | - echo '<ul>'; |
|
772 | - } else { |
|
773 | - echo get_lang('NoTasks'); |
|
774 | - } |
|
775 | - } else { |
|
776 | - echo get_lang('NoTasks'); |
|
777 | - } |
|
778 | - } |
|
779 | - |
|
780 | - /** |
|
781 | - * Changes the visibility of a blog |
|
782 | - * @author Toon Keppens |
|
783 | - * @param Integer $blog_id |
|
784 | - */ |
|
785 | - public static function change_blog_visibility($blog_id) |
|
786 | - { |
|
787 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
788 | - $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST); |
|
789 | - $course_id = api_get_course_int_id(); |
|
790 | - |
|
791 | - // Get blog properties |
|
792 | - $sql = "SELECT blog_name, visibility FROM $tbl_blogs |
|
763 | + $result = Database::query($sql); |
|
764 | + |
|
765 | + if (Database::num_rows($result) > 0) { |
|
766 | + echo '<ul>'; |
|
767 | + while ($mytask = Database::fetch_array($result)) { |
|
768 | + 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>'; |
|
769 | + } |
|
770 | + echo '<ul>'; |
|
771 | + } else { |
|
772 | + echo get_lang('NoTasks'); |
|
773 | + } |
|
774 | + } else { |
|
775 | + echo get_lang('NoTasks'); |
|
776 | + } |
|
777 | + } |
|
778 | + |
|
779 | + /** |
|
780 | + * Changes the visibility of a blog |
|
781 | + * @author Toon Keppens |
|
782 | + * @param Integer $blog_id |
|
783 | + */ |
|
784 | + public static function change_blog_visibility($blog_id) |
|
785 | + { |
|
786 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
787 | + $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST); |
|
788 | + $course_id = api_get_course_int_id(); |
|
789 | + |
|
790 | + // Get blog properties |
|
791 | + $sql = "SELECT blog_name, visibility FROM $tbl_blogs |
|
793 | 792 | WHERE c_id = $course_id AND blog_id='".(int)$blog_id."'"; |
794 | - $result = Database::query($sql); |
|
795 | - $blog = Database::fetch_array($result); |
|
796 | - $visibility = $blog['visibility']; |
|
797 | - $title = $blog['blog_name']; |
|
798 | - |
|
799 | - if ($visibility == 1) { |
|
800 | - // Change visibility state, remove from course home. |
|
801 | - $sql = "UPDATE $tbl_blogs SET visibility = '0' |
|
793 | + $result = Database::query($sql); |
|
794 | + $blog = Database::fetch_array($result); |
|
795 | + $visibility = $blog['visibility']; |
|
796 | + $title = $blog['blog_name']; |
|
797 | + |
|
798 | + if ($visibility == 1) { |
|
799 | + // Change visibility state, remove from course home. |
|
800 | + $sql = "UPDATE $tbl_blogs SET visibility = '0' |
|
802 | 801 | WHERE c_id = $course_id AND blog_id ='".(int)$blog_id."' LIMIT 1"; |
803 | - Database::query($sql); |
|
802 | + Database::query($sql); |
|
804 | 803 | |
805 | - $sql = "DELETE FROM $tbl_tool |
|
804 | + $sql = "DELETE FROM $tbl_tool |
|
806 | 805 | WHERE c_id = $course_id AND name = '".Database::escape_string($title)."' LIMIT 1"; |
807 | - Database::query($sql); |
|
808 | - } else { |
|
809 | - // Change visibility state, add to course home. |
|
810 | - $sql = "UPDATE $tbl_blogs SET visibility = '1' |
|
806 | + Database::query($sql); |
|
807 | + } else { |
|
808 | + // Change visibility state, add to course home. |
|
809 | + $sql = "UPDATE $tbl_blogs SET visibility = '1' |
|
811 | 810 | WHERE c_id = $course_id AND blog_id ='".(int)$blog_id."' LIMIT 1"; |
812 | - Database::query($sql); |
|
811 | + Database::query($sql); |
|
813 | 812 | |
814 | - $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, target ) |
|
813 | + $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, target ) |
|
815 | 814 | VALUES ($course_id, '".Database::escape_string($title)."', 'blog/blog.php?blog_id=".(int)$blog_id."', 'blog.gif', '1', '0', 'pastillegris.gif', '0', '_self')"; |
816 | - Database::query($sql); |
|
815 | + Database::query($sql); |
|
817 | 816 | $id = Database::insert_id(); |
818 | 817 | |
819 | 818 | if ($id) { |
820 | 819 | $sql = "UPDATE $tbl_tool SET id = iid WHERE iid = $id"; |
821 | 820 | Database::query($sql); |
822 | 821 | } |
823 | - } |
|
824 | - } |
|
825 | - |
|
826 | - /** |
|
827 | - * Shows the posts of a blog |
|
828 | - * @author Toon Keppens |
|
829 | - * |
|
830 | - * @param Integer $blog_id |
|
831 | - */ |
|
832 | - public static function display_blog_posts($blog_id, $filter = '1=1', $max_number_of_posts = 20) |
|
822 | + } |
|
823 | + } |
|
824 | + |
|
825 | + /** |
|
826 | + * Shows the posts of a blog |
|
827 | + * @author Toon Keppens |
|
828 | + * |
|
829 | + * @param Integer $blog_id |
|
830 | + */ |
|
831 | + public static function display_blog_posts($blog_id, $filter = '1=1', $max_number_of_posts = 20) |
|
833 | 832 | { |
834 | - // Init |
|
835 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
836 | - $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
837 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
833 | + // Init |
|
834 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
835 | + $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
836 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
838 | 837 | |
839 | - $course_id = api_get_course_int_id(); |
|
838 | + $course_id = api_get_course_int_id(); |
|
840 | 839 | |
841 | - // Get posts and authors |
|
842 | - $sql = "SELECT post.*, user.lastname, user.firstname, user.username |
|
840 | + // Get posts and authors |
|
841 | + $sql = "SELECT post.*, user.lastname, user.firstname, user.username |
|
843 | 842 | FROM $tbl_blogs_posts post |
844 | 843 | INNER JOIN $tbl_users user |
845 | 844 | ON post.author_id = user.user_id |
@@ -847,131 +846,131 @@ discard block |
||
847 | 846 | post.c_id = $course_id AND |
848 | 847 | $filter |
849 | 848 | ORDER BY post_id DESC LIMIT 0,".(int)$max_number_of_posts; |
850 | - $result = Database::query($sql); |
|
851 | - |
|
852 | - // Display |
|
853 | - if(Database::num_rows($result) > 0) { |
|
854 | - $limit = 200; |
|
855 | - while ($blog_post = Database::fetch_array($result)) { |
|
856 | - // Get number of comments |
|
857 | - $sql = "SELECT COUNT(1) as number_of_comments |
|
849 | + $result = Database::query($sql); |
|
850 | + |
|
851 | + // Display |
|
852 | + if(Database::num_rows($result) > 0) { |
|
853 | + $limit = 200; |
|
854 | + while ($blog_post = Database::fetch_array($result)) { |
|
855 | + // Get number of comments |
|
856 | + $sql = "SELECT COUNT(1) as number_of_comments |
|
858 | 857 | FROM $tbl_blogs_comments |
859 | 858 | WHERE |
860 | 859 | c_id = $course_id AND |
861 | 860 | blog_id = '".(int)$blog_id."' AND |
862 | 861 | post_id = '" . (int)$blog_post['post_id']."'"; |
863 | - $tmp = Database::query($sql); |
|
864 | - $blog_post_comments = Database::fetch_array($tmp); |
|
865 | - |
|
866 | - // Prepare data |
|
867 | - $blog_post_id = $blog_post['post_id']; |
|
868 | - $blog_post_text = make_clickable(stripslashes($blog_post['full_text'])); |
|
869 | - $blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get()); |
|
870 | - |
|
871 | - // Create an introduction text (but keep FULL sentences) |
|
872 | - $words = 0; |
|
873 | - $blog_post_text_cut = cut($blog_post_text, $limit) ; |
|
874 | - $words = strlen($blog_post_text); |
|
875 | - |
|
876 | - if ($words >= $limit) { |
|
877 | - $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>'; |
|
878 | - $introduction_text = $blog_post_text_cut; |
|
879 | - } else { |
|
880 | - $introduction_text = $blog_post_text; |
|
881 | - $readMoreLink = ''; |
|
882 | - } |
|
883 | - |
|
884 | - $introduction_text = stripslashes($introduction_text); |
|
885 | - |
|
886 | - echo '<div class="blogpost">'; |
|
887 | - 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>'; |
|
888 | - 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>'; |
|
889 | - echo '<div class="blogpost_introduction" id="blogpost_introduction_'.$blog_post_id.'">' . $introduction_text.$readMoreLink.'</div>'; |
|
890 | - echo '<div class="blogpost_text" id="blogpost_text_' . $blog_post_id . '" style="display: none">' . $blog_post_text . '</div>'; |
|
891 | - |
|
892 | - $file_name_array = get_blog_attachment($blog_id,$blog_post_id,0); |
|
893 | - |
|
894 | - if (!empty($file_name_array)) { |
|
895 | - echo '<br /><br />'; |
|
896 | - echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
897 | - echo '<a href="download.php?file='; |
|
898 | - echo $file_name_array['path']; |
|
899 | - echo ' "> '.$file_name_array['filename'].' </a><br />'; |
|
900 | - echo '</span>'; |
|
901 | - } |
|
902 | - $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES); |
|
903 | - 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>'; |
|
904 | - echo '</div>'; |
|
905 | - } |
|
906 | - } else { |
|
907 | - if($filter == '1=1') { |
|
908 | - echo get_lang('NoArticles'); |
|
909 | - } else { |
|
910 | - echo get_lang('NoArticleMatches'); |
|
911 | - } |
|
912 | - } |
|
862 | + $tmp = Database::query($sql); |
|
863 | + $blog_post_comments = Database::fetch_array($tmp); |
|
864 | + |
|
865 | + // Prepare data |
|
866 | + $blog_post_id = $blog_post['post_id']; |
|
867 | + $blog_post_text = make_clickable(stripslashes($blog_post['full_text'])); |
|
868 | + $blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get()); |
|
869 | + |
|
870 | + // Create an introduction text (but keep FULL sentences) |
|
871 | + $words = 0; |
|
872 | + $blog_post_text_cut = cut($blog_post_text, $limit) ; |
|
873 | + $words = strlen($blog_post_text); |
|
874 | + |
|
875 | + if ($words >= $limit) { |
|
876 | + $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>'; |
|
877 | + $introduction_text = $blog_post_text_cut; |
|
878 | + } else { |
|
879 | + $introduction_text = $blog_post_text; |
|
880 | + $readMoreLink = ''; |
|
881 | + } |
|
882 | + |
|
883 | + $introduction_text = stripslashes($introduction_text); |
|
884 | + |
|
885 | + echo '<div class="blogpost">'; |
|
886 | + 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>'; |
|
887 | + 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>'; |
|
888 | + echo '<div class="blogpost_introduction" id="blogpost_introduction_'.$blog_post_id.'">' . $introduction_text.$readMoreLink.'</div>'; |
|
889 | + echo '<div class="blogpost_text" id="blogpost_text_' . $blog_post_id . '" style="display: none">' . $blog_post_text . '</div>'; |
|
890 | + |
|
891 | + $file_name_array = get_blog_attachment($blog_id,$blog_post_id,0); |
|
892 | + |
|
893 | + if (!empty($file_name_array)) { |
|
894 | + echo '<br /><br />'; |
|
895 | + echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
896 | + echo '<a href="download.php?file='; |
|
897 | + echo $file_name_array['path']; |
|
898 | + echo ' "> '.$file_name_array['filename'].' </a><br />'; |
|
899 | + echo '</span>'; |
|
900 | + } |
|
901 | + $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES); |
|
902 | + 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>'; |
|
903 | + echo '</div>'; |
|
904 | + } |
|
905 | + } else { |
|
906 | + if($filter == '1=1') { |
|
907 | + echo get_lang('NoArticles'); |
|
908 | + } else { |
|
909 | + echo get_lang('NoArticleMatches'); |
|
910 | + } |
|
911 | + } |
|
913 | 912 | } |
914 | 913 | |
915 | - /** |
|
916 | - * Display the search results |
|
917 | - * |
|
918 | - * @param Integer $blog_id |
|
919 | - * @param String $query_string |
|
920 | - */ |
|
921 | - public static function display_search_results ($blog_id, $query_string) |
|
922 | - { |
|
923 | - // Init |
|
924 | - $query_string = Database::escape_string($query_string); |
|
925 | - $query_string_parts = explode(' ',$query_string); |
|
926 | - $query_string = array(); |
|
927 | - foreach ($query_string_parts as $query_part) { |
|
928 | - $query_string[] = " full_text LIKE '%" . $query_part."%' OR title LIKE '%" . $query_part."%' "; |
|
929 | - } |
|
930 | - $query_string = '('.implode('OR',$query_string) . ')'; |
|
931 | - |
|
932 | - // Display the posts |
|
933 | - echo '<span class="blogpost_title">' . get_lang('SearchResults') . '</span>'; |
|
934 | - Blog::display_blog_posts($blog_id, $query_string); |
|
935 | - } |
|
936 | - |
|
937 | - /** |
|
938 | - * Display posts from a certain date |
|
939 | - * |
|
940 | - * @param Integer $blog_id |
|
941 | - * @param String $query_string |
|
942 | - */ |
|
943 | - public static function display_day_results($blog_id, $query_string) |
|
944 | - { |
|
945 | - $date_output = $query_string; |
|
946 | - $date = explode('-',$query_string); |
|
947 | - $query_string = ' DAYOFMONTH(date_creation) =' . intval($date[2]) . ' AND MONTH(date_creation) =' . intval($date[1]) . ' AND YEAR(date_creation) =' . intval($date[0]); |
|
948 | - |
|
949 | - // Put date in correct output format |
|
950 | - $date_output = api_format_date($date_output, DATE_FORMAT_LONG); |
|
951 | - |
|
952 | - // Display the posts |
|
953 | - echo '<span class="blogpost_title">' . get_lang('PostsOf') . ': ' . $date_output . '</span>'; |
|
954 | - Blog::display_blog_posts($blog_id, $query_string); |
|
955 | - } |
|
956 | - |
|
957 | - /** |
|
958 | - * Displays a post and his comments |
|
959 | - * |
|
960 | - * @param Integer $blog_id |
|
961 | - * @param Integer $post_id |
|
962 | - */ |
|
963 | - public static function display_post($blog_id, $post_id) |
|
964 | - { |
|
965 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
966 | - $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
967 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
968 | - |
|
969 | - global $charset, $dateFormatLong; |
|
970 | - |
|
971 | - $course_id = api_get_course_int_id(); |
|
972 | - |
|
973 | - // Get posts and author |
|
974 | - $sql = "SELECT post.*, user.lastname, user.firstname, user.username |
|
914 | + /** |
|
915 | + * Display the search results |
|
916 | + * |
|
917 | + * @param Integer $blog_id |
|
918 | + * @param String $query_string |
|
919 | + */ |
|
920 | + public static function display_search_results ($blog_id, $query_string) |
|
921 | + { |
|
922 | + // Init |
|
923 | + $query_string = Database::escape_string($query_string); |
|
924 | + $query_string_parts = explode(' ',$query_string); |
|
925 | + $query_string = array(); |
|
926 | + foreach ($query_string_parts as $query_part) { |
|
927 | + $query_string[] = " full_text LIKE '%" . $query_part."%' OR title LIKE '%" . $query_part."%' "; |
|
928 | + } |
|
929 | + $query_string = '('.implode('OR',$query_string) . ')'; |
|
930 | + |
|
931 | + // Display the posts |
|
932 | + echo '<span class="blogpost_title">' . get_lang('SearchResults') . '</span>'; |
|
933 | + Blog::display_blog_posts($blog_id, $query_string); |
|
934 | + } |
|
935 | + |
|
936 | + /** |
|
937 | + * Display posts from a certain date |
|
938 | + * |
|
939 | + * @param Integer $blog_id |
|
940 | + * @param String $query_string |
|
941 | + */ |
|
942 | + public static function display_day_results($blog_id, $query_string) |
|
943 | + { |
|
944 | + $date_output = $query_string; |
|
945 | + $date = explode('-',$query_string); |
|
946 | + $query_string = ' DAYOFMONTH(date_creation) =' . intval($date[2]) . ' AND MONTH(date_creation) =' . intval($date[1]) . ' AND YEAR(date_creation) =' . intval($date[0]); |
|
947 | + |
|
948 | + // Put date in correct output format |
|
949 | + $date_output = api_format_date($date_output, DATE_FORMAT_LONG); |
|
950 | + |
|
951 | + // Display the posts |
|
952 | + echo '<span class="blogpost_title">' . get_lang('PostsOf') . ': ' . $date_output . '</span>'; |
|
953 | + Blog::display_blog_posts($blog_id, $query_string); |
|
954 | + } |
|
955 | + |
|
956 | + /** |
|
957 | + * Displays a post and his comments |
|
958 | + * |
|
959 | + * @param Integer $blog_id |
|
960 | + * @param Integer $post_id |
|
961 | + */ |
|
962 | + public static function display_post($blog_id, $post_id) |
|
963 | + { |
|
964 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
965 | + $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
966 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
967 | + |
|
968 | + global $charset, $dateFormatLong; |
|
969 | + |
|
970 | + $course_id = api_get_course_int_id(); |
|
971 | + |
|
972 | + // Get posts and author |
|
973 | + $sql = "SELECT post.*, user.lastname, user.firstname, user.username |
|
975 | 974 | FROM $tbl_blogs_posts post |
976 | 975 | INNER JOIN $tbl_users user |
977 | 976 | ON post.author_id = user.user_id |
@@ -980,107 +979,107 @@ discard block |
||
980 | 979 | post.blog_id = '".(int)$blog_id."' AND |
981 | 980 | post.post_id = '".(int)$post_id."' |
982 | 981 | ORDER BY post_id DESC"; |
983 | - $result = Database::query($sql); |
|
984 | - $blog_post = Database::fetch_array($result); |
|
982 | + $result = Database::query($sql); |
|
983 | + $blog_post = Database::fetch_array($result); |
|
985 | 984 | |
986 | - // Get number of comments |
|
987 | - $sql = "SELECT COUNT(1) as number_of_comments |
|
985 | + // Get number of comments |
|
986 | + $sql = "SELECT COUNT(1) as number_of_comments |
|
988 | 987 | FROM $tbl_blogs_comments |
989 | 988 | WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND post_id = '".(int)$post_id."'"; |
990 | - $result = Database::query($sql); |
|
991 | - $blog_post_comments = Database::fetch_array($result); |
|
989 | + $result = Database::query($sql); |
|
990 | + $blog_post_comments = Database::fetch_array($result); |
|
992 | 991 | |
993 | - // Prepare data |
|
994 | - $blog_post_text = make_clickable(stripslashes($blog_post['full_text'])); |
|
995 | - $blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get()); |
|
996 | - $blog_post_actions = ""; |
|
992 | + // Prepare data |
|
993 | + $blog_post_text = make_clickable(stripslashes($blog_post['full_text'])); |
|
994 | + $blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get()); |
|
995 | + $blog_post_actions = ""; |
|
997 | 996 | |
998 | - $task_id = (isset($_GET['task_id']) && is_numeric($_GET['task_id'])) ? intval($_GET['task_id']) : 0; |
|
997 | + $task_id = (isset($_GET['task_id']) && is_numeric($_GET['task_id'])) ? intval($_GET['task_id']) : 0; |
|
999 | 998 | |
1000 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_edit', $task_id)) |
|
1001 | - $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') . '"><img src="../img/edit.gif" /></a>'; |
|
999 | + if (api_is_allowed('BLOG_' . $blog_id, 'article_edit', $task_id)) |
|
1000 | + $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') . '"><img src="../img/edit.gif" /></a>'; |
|
1002 | 1001 | |
1003 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_delete', $task_id)) |
|
1004 | - $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;"><img src="../img/delete.gif" border="0" /></a>'; |
|
1002 | + if (api_is_allowed('BLOG_' . $blog_id, 'article_delete', $task_id)) |
|
1003 | + $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;"><img src="../img/delete.gif" border="0" /></a>'; |
|
1005 | 1004 | |
1006 | - if(api_is_allowed('BLOG_' . $blog_id, 'article_rate')) |
|
1007 | - $rating_select = Blog::display_rating_form('post',$blog_id,$post_id); |
|
1005 | + if(api_is_allowed('BLOG_' . $blog_id, 'article_rate')) |
|
1006 | + $rating_select = Blog::display_rating_form('post',$blog_id,$post_id); |
|
1008 | 1007 | |
1009 | - $blog_post_text=stripslashes($blog_post_text); |
|
1008 | + $blog_post_text=stripslashes($blog_post_text); |
|
1010 | 1009 | |
1011 | - // Display post |
|
1012 | - echo '<div class="blogpost">'; |
|
1013 | - 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>'; |
|
1014 | - echo '<span class="blogpost_date">' . $blog_post_date . '</span>'; |
|
1015 | - echo '<span class="blogpost_text">' . $blog_post_text . '</span><br />'; |
|
1010 | + // Display post |
|
1011 | + echo '<div class="blogpost">'; |
|
1012 | + 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>'; |
|
1013 | + echo '<span class="blogpost_date">' . $blog_post_date . '</span>'; |
|
1014 | + echo '<span class="blogpost_text">' . $blog_post_text . '</span><br />'; |
|
1016 | 1015 | |
1017 | - $file_name_array = get_blog_attachment($blog_id, $post_id); |
|
1016 | + $file_name_array = get_blog_attachment($blog_id, $post_id); |
|
1018 | 1017 | |
1019 | 1018 | if (!empty($file_name_array)) { |
1020 | - echo ' <br />'; |
|
1021 | - echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
1022 | - echo '<a href="download.php?file='; |
|
1023 | - echo $file_name_array['path']; |
|
1024 | - echo ' "> '.$file_name_array['filename'].' </a>'; |
|
1025 | - echo '</span>'; |
|
1026 | - echo '<span class="attachment_comment">'; |
|
1027 | - echo $file_name_array['comment']; |
|
1028 | - echo '</span>'; |
|
1029 | - echo '<br />'; |
|
1030 | - } |
|
1019 | + echo ' <br />'; |
|
1020 | + echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
1021 | + echo '<a href="download.php?file='; |
|
1022 | + echo $file_name_array['path']; |
|
1023 | + echo ' "> '.$file_name_array['filename'].' </a>'; |
|
1024 | + echo '</span>'; |
|
1025 | + echo '<span class="attachment_comment">'; |
|
1026 | + echo $file_name_array['comment']; |
|
1027 | + echo '</span>'; |
|
1028 | + echo '<br />'; |
|
1029 | + } |
|
1031 | 1030 | $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES); |
1032 | - 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>'; |
|
1033 | - echo '<span class="blogpost_actions">' . $blog_post_actions . '</span>'; |
|
1034 | - echo '</div>'; |
|
1035 | - |
|
1036 | - // Display comments if there are any |
|
1037 | - if($blog_post_comments['number_of_comments'] > 0) { |
|
1038 | - echo '<div class="comments">'; |
|
1039 | - echo '<span class="blogpost_title">' . get_lang('Comments') . '</span><br />'; |
|
1040 | - Blog::get_threaded_comments(0, 0, $blog_id, $post_id, $task_id); |
|
1041 | - echo '</div>'; |
|
1042 | - } |
|
1043 | - |
|
1044 | - // Display comment form |
|
1045 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_comments_add')) { |
|
1046 | - Blog::display_new_comment_form($blog_id, $post_id, $blog_post['title']); |
|
1047 | - } |
|
1048 | - } |
|
1049 | - |
|
1050 | - /** |
|
1051 | - * Adds rating to a certain post or comment |
|
1052 | - * @author Toon Keppens |
|
1053 | - * |
|
1054 | - * @param String $type |
|
1055 | - * @param Integer $blog_id |
|
1056 | - * @param Integer $item_id |
|
1057 | - * @param Integer $rating |
|
1058 | - * |
|
1059 | - * @return Boolean success |
|
1060 | - */ |
|
1061 | - public static function add_rating($type, $blog_id, $item_id, $rating) |
|
1062 | - { |
|
1063 | - $_user = api_get_user_info(); |
|
1064 | - |
|
1065 | - // Init |
|
1066 | - $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
1067 | - $course_id = api_get_course_int_id(); |
|
1068 | - |
|
1069 | - // Check if the user has already rated this post/comment |
|
1070 | - $sql = "SELECT rating_id FROM $tbl_blogs_rating |
|
1031 | + 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>'; |
|
1032 | + echo '<span class="blogpost_actions">' . $blog_post_actions . '</span>'; |
|
1033 | + echo '</div>'; |
|
1034 | + |
|
1035 | + // Display comments if there are any |
|
1036 | + if($blog_post_comments['number_of_comments'] > 0) { |
|
1037 | + echo '<div class="comments">'; |
|
1038 | + echo '<span class="blogpost_title">' . get_lang('Comments') . '</span><br />'; |
|
1039 | + Blog::get_threaded_comments(0, 0, $blog_id, $post_id, $task_id); |
|
1040 | + echo '</div>'; |
|
1041 | + } |
|
1042 | + |
|
1043 | + // Display comment form |
|
1044 | + if (api_is_allowed('BLOG_' . $blog_id, 'article_comments_add')) { |
|
1045 | + Blog::display_new_comment_form($blog_id, $post_id, $blog_post['title']); |
|
1046 | + } |
|
1047 | + } |
|
1048 | + |
|
1049 | + /** |
|
1050 | + * Adds rating to a certain post or comment |
|
1051 | + * @author Toon Keppens |
|
1052 | + * |
|
1053 | + * @param String $type |
|
1054 | + * @param Integer $blog_id |
|
1055 | + * @param Integer $item_id |
|
1056 | + * @param Integer $rating |
|
1057 | + * |
|
1058 | + * @return Boolean success |
|
1059 | + */ |
|
1060 | + public static function add_rating($type, $blog_id, $item_id, $rating) |
|
1061 | + { |
|
1062 | + $_user = api_get_user_info(); |
|
1063 | + |
|
1064 | + // Init |
|
1065 | + $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
1066 | + $course_id = api_get_course_int_id(); |
|
1067 | + |
|
1068 | + // Check if the user has already rated this post/comment |
|
1069 | + $sql = "SELECT rating_id FROM $tbl_blogs_rating |
|
1071 | 1070 | WHERE |
1072 | 1071 | c_id = $course_id AND |
1073 | 1072 | blog_id = '".(int)$blog_id."' AND |
1074 | 1073 | item_id = '".(int)$item_id."' AND |
1075 | 1074 | rating_type = '".Database::escape_string($type)."' AND |
1076 | 1075 | user_id = '".(int)$_user['user_id']."'"; |
1077 | - $result = Database::query($sql); |
|
1076 | + $result = Database::query($sql); |
|
1078 | 1077 | |
1079 | 1078 | // Add rating |
1080 | - if (Database::num_rows($result) == 0) { |
|
1081 | - $sql = "INSERT INTO $tbl_blogs_rating (c_id, blog_id, rating_type, item_id, user_id, rating ) |
|
1079 | + if (Database::num_rows($result) == 0) { |
|
1080 | + $sql = "INSERT INTO $tbl_blogs_rating (c_id, blog_id, rating_type, item_id, user_id, rating ) |
|
1082 | 1081 | VALUES ($course_id, '".(int)$blog_id."', '".Database::escape_string($type)."', '".(int)$item_id."', '".(int)$_user['user_id']."', '".Database::escape_string($rating)."')"; |
1083 | - Database::query($sql); |
|
1082 | + Database::query($sql); |
|
1084 | 1083 | |
1085 | 1084 | $id = Database::insert_id(); |
1086 | 1085 | if ($id) { |
@@ -1088,107 +1087,107 @@ discard block |
||
1088 | 1087 | Database::query($sql); |
1089 | 1088 | } |
1090 | 1089 | |
1091 | - return true; |
|
1090 | + return true; |
|
1092 | 1091 | } else { |
1093 | - return false; |
|
1094 | - } |
|
1095 | - } |
|
1096 | - |
|
1097 | - /** |
|
1098 | - * Shows the rating of user |
|
1099 | - * |
|
1100 | - * @param String $type |
|
1101 | - * @param Integer $blog_id |
|
1102 | - * @param Integer $item_id |
|
1103 | - * |
|
1104 | - * @return array() |
|
1105 | - */ |
|
1106 | - public static function display_rating($type, $blog_id, $item_id) |
|
1107 | - { |
|
1108 | - $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
1109 | - $course_id = api_get_course_int_id(); |
|
1110 | - |
|
1111 | - // Calculate rating |
|
1112 | - $sql = "SELECT AVG(rating) as rating FROM $tbl_blogs_rating |
|
1092 | + return false; |
|
1093 | + } |
|
1094 | + } |
|
1095 | + |
|
1096 | + /** |
|
1097 | + * Shows the rating of user |
|
1098 | + * |
|
1099 | + * @param String $type |
|
1100 | + * @param Integer $blog_id |
|
1101 | + * @param Integer $item_id |
|
1102 | + * |
|
1103 | + * @return array() |
|
1104 | + */ |
|
1105 | + public static function display_rating($type, $blog_id, $item_id) |
|
1106 | + { |
|
1107 | + $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
1108 | + $course_id = api_get_course_int_id(); |
|
1109 | + |
|
1110 | + // Calculate rating |
|
1111 | + $sql = "SELECT AVG(rating) as rating FROM $tbl_blogs_rating |
|
1113 | 1112 | WHERE |
1114 | 1113 | c_id = $course_id AND |
1115 | 1114 | blog_id = '".(int)$blog_id."' AND |
1116 | 1115 | item_id = '".(int)$item_id."' AND |
1117 | 1116 | rating_type = '".Database::escape_string($type)."' "; |
1118 | - $result = Database::query($sql); |
|
1119 | - $result = Database::fetch_array($result); |
|
1120 | - return round($result['rating'], 2); |
|
1121 | - } |
|
1122 | - |
|
1123 | - /** |
|
1124 | - * Shows the rating form if not already rated by that user |
|
1125 | - * @author Toon Keppens |
|
1126 | - * |
|
1127 | - * @param String $type |
|
1128 | - * @param Integer $blog_id |
|
1129 | - * @param Integer $item_id |
|
1130 | - * |
|
1131 | - *@return String |
|
1132 | - */ |
|
1133 | - public static function display_rating_form ($type, $blog_id, $post_id, $comment_id = NULL) |
|
1134 | - { |
|
1135 | - $_user = api_get_user_info(); |
|
1136 | - $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
1117 | + $result = Database::query($sql); |
|
1118 | + $result = Database::fetch_array($result); |
|
1119 | + return round($result['rating'], 2); |
|
1120 | + } |
|
1121 | + |
|
1122 | + /** |
|
1123 | + * Shows the rating form if not already rated by that user |
|
1124 | + * @author Toon Keppens |
|
1125 | + * |
|
1126 | + * @param String $type |
|
1127 | + * @param Integer $blog_id |
|
1128 | + * @param Integer $item_id |
|
1129 | + * |
|
1130 | + *@return String |
|
1131 | + */ |
|
1132 | + public static function display_rating_form ($type, $blog_id, $post_id, $comment_id = NULL) |
|
1133 | + { |
|
1134 | + $_user = api_get_user_info(); |
|
1135 | + $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
1137 | 1136 | $course_id = api_get_course_int_id(); |
1138 | 1137 | |
1139 | 1138 | if ($type == 'post') { |
1140 | - // Check if the user has already rated this post |
|
1141 | - $sql = "SELECT rating_id FROM $tbl_blogs_rating |
|
1139 | + // Check if the user has already rated this post |
|
1140 | + $sql = "SELECT rating_id FROM $tbl_blogs_rating |
|
1142 | 1141 | WHERE c_id = $course_id AND |
1143 | 1142 | blog_id = '".(int)$blog_id."' |
1144 | 1143 | AND item_id = '".(int)$post_id."' |
1145 | 1144 | AND rating_type = '".Database::escape_string($type)."' |
1146 | 1145 | AND user_id = '".(int)$_user['user_id']."'"; |
1147 | - $result = Database::query($sql); |
|
1146 | + $result = Database::query($sql); |
|
1148 | 1147 | // Add rating |
1149 | 1148 | if (Database::num_rows($result) == 0) { |
1150 | - 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>'; |
|
1149 | + 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>'; |
|
1151 | 1150 | } else { |
1152 | - return ''; |
|
1153 | - } |
|
1154 | - } |
|
1151 | + return ''; |
|
1152 | + } |
|
1153 | + } |
|
1155 | 1154 | |
1156 | 1155 | if ($type = 'comment') { |
1157 | - // Check if the user has already rated this comment |
|
1158 | - $sql = "SELECT rating_id FROM $tbl_blogs_rating |
|
1156 | + // Check if the user has already rated this comment |
|
1157 | + $sql = "SELECT rating_id FROM $tbl_blogs_rating |
|
1159 | 1158 | WHERE c_id = $course_id AND blog_id = '".(int)$blog_id ."' |
1160 | 1159 | AND item_id = '".(int)$comment_id."' |
1161 | 1160 | AND rating_type = '".Database::escape_string($type)."' |
1162 | 1161 | AND user_id = '".(int)$_user['user_id']."'"; |
1163 | - $result = Database::query($sql); |
|
1162 | + $result = Database::query($sql); |
|
1164 | 1163 | |
1165 | 1164 | if (Database::num_rows($result) == 0) { |
1166 | - 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>'; |
|
1165 | + 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>'; |
|
1167 | 1166 | } else { |
1168 | - return ''; |
|
1169 | - } |
|
1170 | - } |
|
1171 | - } |
|
1172 | - |
|
1173 | - /** |
|
1174 | - * This functions gets all replys to a post, threaded. |
|
1175 | - * |
|
1176 | - * @param Integer $current |
|
1177 | - * @param Integer $current_level |
|
1178 | - * @param Integer $blog_id |
|
1179 | - * @param Integer $post_id |
|
1180 | - */ |
|
1181 | - public static function get_threaded_comments($current = 0, $current_level = 0, $blog_id, $post_id, $task_id = 0) |
|
1182 | - { |
|
1183 | - $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
1184 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
1185 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1186 | - global $charset; |
|
1187 | - |
|
1188 | - $course_id = api_get_course_int_id(); |
|
1189 | - |
|
1190 | - // Select top level comments |
|
1191 | - $next_level = $current_level + 1; |
|
1167 | + return ''; |
|
1168 | + } |
|
1169 | + } |
|
1170 | + } |
|
1171 | + |
|
1172 | + /** |
|
1173 | + * This functions gets all replys to a post, threaded. |
|
1174 | + * |
|
1175 | + * @param Integer $current |
|
1176 | + * @param Integer $current_level |
|
1177 | + * @param Integer $blog_id |
|
1178 | + * @param Integer $post_id |
|
1179 | + */ |
|
1180 | + public static function get_threaded_comments($current = 0, $current_level = 0, $blog_id, $post_id, $task_id = 0) |
|
1181 | + { |
|
1182 | + $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
1183 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
1184 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1185 | + global $charset; |
|
1186 | + |
|
1187 | + $course_id = api_get_course_int_id(); |
|
1188 | + |
|
1189 | + // Select top level comments |
|
1190 | + $next_level = $current_level + 1; |
|
1192 | 1191 | $sql = "SELECT comments.*, user.lastname, user.firstname, user.username, task.color |
1193 | 1192 | FROM $tbl_blogs_comments comments |
1194 | 1193 | INNER JOIN $tbl_users user |
@@ -1200,11 +1199,11 @@ discard block |
||
1200 | 1199 | parent_comment_id = $current AND |
1201 | 1200 | comments.blog_id = '".(int)$blog_id."' AND |
1202 | 1201 | comments.post_id = '".(int)$post_id."'"; |
1203 | - $result = Database::query($sql); |
|
1202 | + $result = Database::query($sql); |
|
1204 | 1203 | |
1205 | - while($comment = Database::fetch_array($result)) { |
|
1206 | - // Select the children recursivly |
|
1207 | - $tmp = "SELECT comments.*, user.lastname, user.firstname, user.username |
|
1204 | + while($comment = Database::fetch_array($result)) { |
|
1205 | + // Select the children recursivly |
|
1206 | + $tmp = "SELECT comments.*, user.lastname, user.firstname, user.username |
|
1208 | 1207 | FROM $tbl_blogs_comments comments |
1209 | 1208 | INNER JOIN $tbl_users user |
1210 | 1209 | ON comments.author_id = user.user_id |
@@ -1213,104 +1212,104 @@ discard block |
||
1213 | 1212 | comment_id = $current |
1214 | 1213 | AND blog_id = '".(int)$blog_id."' |
1215 | 1214 | AND post_id = '".(int)$post_id."'"; |
1216 | - $tmp = Database::query($tmp); |
|
1217 | - $tmp = Database::fetch_array($tmp); |
|
1218 | - $parent_cat = $tmp['parent_comment_id']; |
|
1219 | - $border_color = ''; |
|
1220 | - |
|
1221 | - // Prepare data |
|
1222 | - $comment_text = make_clickable(stripslashes($comment['comment'])); |
|
1223 | - $blog_comment_date = api_convert_and_format_date($comment['date_creation'], null, date_default_timezone_get()); |
|
1224 | - $blog_comment_actions = ""; |
|
1225 | - if(api_is_allowed('BLOG_' . $blog_id, 'article_comments_delete', $task_id)) { $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('DeleteThisComment') . '" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"><img src="../img/delete.gif" border="0" /></a>'; } |
|
1226 | - if(api_is_allowed('BLOG_' . $blog_id, 'article_comments_rate')) { $rating_select = Blog::display_rating_form('comment', $blog_id, $post_id, $comment['comment_id']); } |
|
1227 | - |
|
1228 | - if (!is_null($comment['task_id'])) { |
|
1229 | - $border_color = ' border-left: 3px solid #' . $comment['color']; |
|
1230 | - } |
|
1231 | - |
|
1232 | - $comment_text = stripslashes($comment_text); |
|
1233 | - |
|
1234 | - // Output... |
|
1235 | - $margin = $current_level * 30; |
|
1236 | - echo '<div class="blogpost_comment" style="margin-left: ' . $margin . 'px;' . $border_color . '">'; |
|
1237 | - 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>'; |
|
1238 | - echo '<span class="blogpost_comment_date">' . $blog_comment_date . '</span>'; |
|
1239 | - echo '<span class="blogpost_text">' . $comment_text . '</span>'; |
|
1240 | - |
|
1241 | - $file_name_array=get_blog_attachment($blog_id,$post_id, $comment['comment_id']); |
|
1242 | - if (!empty($file_name_array)) { |
|
1243 | - echo '<br /><br />'; |
|
1244 | - echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
1245 | - echo '<a href="download.php?file='; |
|
1246 | - echo $file_name_array['path']; |
|
1247 | - echo ' "> '.$file_name_array['filename'].' </a>'; |
|
1248 | - echo '<span class="attachment_comment">'; |
|
1249 | - echo $file_name_array['comment']; |
|
1250 | - echo '</span><br />'; |
|
1251 | - } |
|
1215 | + $tmp = Database::query($tmp); |
|
1216 | + $tmp = Database::fetch_array($tmp); |
|
1217 | + $parent_cat = $tmp['parent_comment_id']; |
|
1218 | + $border_color = ''; |
|
1219 | + |
|
1220 | + // Prepare data |
|
1221 | + $comment_text = make_clickable(stripslashes($comment['comment'])); |
|
1222 | + $blog_comment_date = api_convert_and_format_date($comment['date_creation'], null, date_default_timezone_get()); |
|
1223 | + $blog_comment_actions = ""; |
|
1224 | + if(api_is_allowed('BLOG_' . $blog_id, 'article_comments_delete', $task_id)) { $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('DeleteThisComment') . '" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"><img src="../img/delete.gif" border="0" /></a>'; } |
|
1225 | + if(api_is_allowed('BLOG_' . $blog_id, 'article_comments_rate')) { $rating_select = Blog::display_rating_form('comment', $blog_id, $post_id, $comment['comment_id']); } |
|
1226 | + |
|
1227 | + if (!is_null($comment['task_id'])) { |
|
1228 | + $border_color = ' border-left: 3px solid #' . $comment['color']; |
|
1229 | + } |
|
1230 | + |
|
1231 | + $comment_text = stripslashes($comment_text); |
|
1232 | + |
|
1233 | + // Output... |
|
1234 | + $margin = $current_level * 30; |
|
1235 | + echo '<div class="blogpost_comment" style="margin-left: ' . $margin . 'px;' . $border_color . '">'; |
|
1236 | + 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>'; |
|
1237 | + echo '<span class="blogpost_comment_date">' . $blog_comment_date . '</span>'; |
|
1238 | + echo '<span class="blogpost_text">' . $comment_text . '</span>'; |
|
1239 | + |
|
1240 | + $file_name_array=get_blog_attachment($blog_id,$post_id, $comment['comment_id']); |
|
1241 | + if (!empty($file_name_array)) { |
|
1242 | + echo '<br /><br />'; |
|
1243 | + echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
1244 | + echo '<a href="download.php?file='; |
|
1245 | + echo $file_name_array['path']; |
|
1246 | + echo ' "> '.$file_name_array['filename'].' </a>'; |
|
1247 | + echo '<span class="attachment_comment">'; |
|
1248 | + echo $file_name_array['comment']; |
|
1249 | + echo '</span><br />'; |
|
1250 | + } |
|
1252 | 1251 | $username = api_htmlentities(sprintf(get_lang('LoginX'), $comment['username']), ENT_QUOTES); |
1253 | - 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>'; |
|
1254 | - echo '<span class="blogpost_actions">' . $blog_comment_actions . '</span>'; |
|
1255 | - echo '</div>'; |
|
1256 | - |
|
1257 | - // Go further down the tree. |
|
1258 | - Blog::get_threaded_comments($comment['comment_id'], $next_level, $blog_id, $post_id); |
|
1259 | - } |
|
1260 | - } |
|
1261 | - |
|
1262 | - /** |
|
1263 | - * Displays the form to create a new post |
|
1264 | - * @author Toon Keppens |
|
1265 | - * |
|
1266 | - * @param Integer $blog_id |
|
1267 | - */ |
|
1268 | - public static function display_form_new_post($blog_id) |
|
1269 | - { |
|
1270 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) { |
|
1271 | - $form = new FormValidator( |
|
1272 | - 'add_post', |
|
1273 | - 'post', |
|
1274 | - api_get_path(WEB_CODE_PATH)."blog/blog.php?action=new_post&blog_id=" . $blog_id . "&" . api_get_cidreq(), |
|
1275 | - null, |
|
1276 | - array('enctype' => 'multipart/form-data') |
|
1277 | - ); |
|
1278 | - $form->addHidden('post_title_edited', 'false'); |
|
1279 | - $form->addHeader(get_lang('NewPost')); |
|
1280 | - $form->addText('title', get_lang('Title')); |
|
1281 | - $config = array(); |
|
1282 | - if (!api_is_allowed_to_edit()) { |
|
1283 | - $config['ToolbarSet'] = 'ProjectStudent'; |
|
1284 | - } else { |
|
1285 | - $config['ToolbarSet'] = 'Project'; |
|
1286 | - } |
|
1287 | - $form->addHtmlEditor('full_text', get_lang('Content'), false, false, $config); |
|
1288 | - $form->addFile('user_upload', get_lang('AddAnAttachment')); |
|
1289 | - $form->addTextarea('post_file_comment', get_lang('FileComment')); |
|
1290 | - $form->addHidden('new_post_submit', 'true'); |
|
1291 | - $form->addButton('save', get_lang('Save')); |
|
1292 | - |
|
1293 | - $form->display(); |
|
1294 | - } else { |
|
1295 | - api_not_allowed(); |
|
1296 | - } |
|
1297 | - } |
|
1298 | - |
|
1299 | - /** |
|
1300 | - * Displays the form to edit a post |
|
1301 | - * @author Toon Keppens |
|
1302 | - * |
|
1303 | - * @param Integer $blog_id |
|
1304 | - */ |
|
1305 | - public static function display_form_edit_post($blog_id, $post_id) |
|
1306 | - { |
|
1307 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
1308 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
1309 | - |
|
1310 | - $course_id = api_get_course_int_id(); |
|
1311 | - |
|
1312 | - // Get posts and author |
|
1313 | - $sql = "SELECT post.*, user.lastname, user.firstname |
|
1252 | + 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>'; |
|
1253 | + echo '<span class="blogpost_actions">' . $blog_comment_actions . '</span>'; |
|
1254 | + echo '</div>'; |
|
1255 | + |
|
1256 | + // Go further down the tree. |
|
1257 | + Blog::get_threaded_comments($comment['comment_id'], $next_level, $blog_id, $post_id); |
|
1258 | + } |
|
1259 | + } |
|
1260 | + |
|
1261 | + /** |
|
1262 | + * Displays the form to create a new post |
|
1263 | + * @author Toon Keppens |
|
1264 | + * |
|
1265 | + * @param Integer $blog_id |
|
1266 | + */ |
|
1267 | + public static function display_form_new_post($blog_id) |
|
1268 | + { |
|
1269 | + if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) { |
|
1270 | + $form = new FormValidator( |
|
1271 | + 'add_post', |
|
1272 | + 'post', |
|
1273 | + api_get_path(WEB_CODE_PATH)."blog/blog.php?action=new_post&blog_id=" . $blog_id . "&" . api_get_cidreq(), |
|
1274 | + null, |
|
1275 | + array('enctype' => 'multipart/form-data') |
|
1276 | + ); |
|
1277 | + $form->addHidden('post_title_edited', 'false'); |
|
1278 | + $form->addHeader(get_lang('NewPost')); |
|
1279 | + $form->addText('title', get_lang('Title')); |
|
1280 | + $config = array(); |
|
1281 | + if (!api_is_allowed_to_edit()) { |
|
1282 | + $config['ToolbarSet'] = 'ProjectStudent'; |
|
1283 | + } else { |
|
1284 | + $config['ToolbarSet'] = 'Project'; |
|
1285 | + } |
|
1286 | + $form->addHtmlEditor('full_text', get_lang('Content'), false, false, $config); |
|
1287 | + $form->addFile('user_upload', get_lang('AddAnAttachment')); |
|
1288 | + $form->addTextarea('post_file_comment', get_lang('FileComment')); |
|
1289 | + $form->addHidden('new_post_submit', 'true'); |
|
1290 | + $form->addButton('save', get_lang('Save')); |
|
1291 | + |
|
1292 | + $form->display(); |
|
1293 | + } else { |
|
1294 | + api_not_allowed(); |
|
1295 | + } |
|
1296 | + } |
|
1297 | + |
|
1298 | + /** |
|
1299 | + * Displays the form to edit a post |
|
1300 | + * @author Toon Keppens |
|
1301 | + * |
|
1302 | + * @param Integer $blog_id |
|
1303 | + */ |
|
1304 | + public static function display_form_edit_post($blog_id, $post_id) |
|
1305 | + { |
|
1306 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
1307 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
1308 | + |
|
1309 | + $course_id = api_get_course_int_id(); |
|
1310 | + |
|
1311 | + // Get posts and author |
|
1312 | + $sql = "SELECT post.*, user.lastname, user.firstname |
|
1314 | 1313 | FROM $tbl_blogs_posts post |
1315 | 1314 | INNER JOIN $tbl_users user ON post.author_id = user.user_id |
1316 | 1315 | WHERE |
@@ -1318,69 +1317,69 @@ discard block |
||
1318 | 1317 | post.blog_id = '".(int)$blog_id ."' |
1319 | 1318 | AND post.post_id = '".(int)$post_id."' |
1320 | 1319 | ORDER BY post_id DESC"; |
1321 | - $result = Database::query($sql); |
|
1322 | - $blog_post = Database::fetch_array($result); |
|
1323 | - |
|
1324 | - // Form |
|
1325 | - $form = new FormValidator( |
|
1326 | - 'edit_post', |
|
1327 | - 'post', |
|
1328 | - 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']) |
|
1329 | - ); |
|
1330 | - |
|
1331 | - $form->addHeader(get_lang('EditPost')); |
|
1332 | - $form->addText('title', get_lang('Title')); |
|
1333 | - |
|
1334 | - if (!api_is_allowed_to_edit()) { |
|
1335 | - $config['ToolbarSet'] = 'ProjectStudent'; |
|
1336 | - } else { |
|
1337 | - $config['ToolbarSet'] = 'Project'; |
|
1338 | - } |
|
1339 | - $form->addHtmlEditor('full_text', get_lang('Content'), false, false, $config); |
|
1340 | - |
|
1341 | - $form->addHidden('action', ''); |
|
1342 | - $form->addHidden('edit_post_submit', 'true'); |
|
1343 | - $form->addHidden('post_id', intval($_GET['post_id'])); |
|
1344 | - $form->addButton('save', get_lang('Save')); |
|
1345 | - $form->setDefaults($blog_post); |
|
1346 | - $form->display(); |
|
1347 | - } |
|
1348 | - |
|
1349 | - /** |
|
1350 | - * Displays a list of tasks in this blog |
|
1351 | - * @author Toon Keppens |
|
1352 | - * |
|
1353 | - * @param Integer $blog_id |
|
1354 | - */ |
|
1355 | - public static function display_task_list($blog_id) |
|
1320 | + $result = Database::query($sql); |
|
1321 | + $blog_post = Database::fetch_array($result); |
|
1322 | + |
|
1323 | + // Form |
|
1324 | + $form = new FormValidator( |
|
1325 | + 'edit_post', |
|
1326 | + 'post', |
|
1327 | + 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']) |
|
1328 | + ); |
|
1329 | + |
|
1330 | + $form->addHeader(get_lang('EditPost')); |
|
1331 | + $form->addText('title', get_lang('Title')); |
|
1332 | + |
|
1333 | + if (!api_is_allowed_to_edit()) { |
|
1334 | + $config['ToolbarSet'] = 'ProjectStudent'; |
|
1335 | + } else { |
|
1336 | + $config['ToolbarSet'] = 'Project'; |
|
1337 | + } |
|
1338 | + $form->addHtmlEditor('full_text', get_lang('Content'), false, false, $config); |
|
1339 | + |
|
1340 | + $form->addHidden('action', ''); |
|
1341 | + $form->addHidden('edit_post_submit', 'true'); |
|
1342 | + $form->addHidden('post_id', intval($_GET['post_id'])); |
|
1343 | + $form->addButton('save', get_lang('Save')); |
|
1344 | + $form->setDefaults($blog_post); |
|
1345 | + $form->display(); |
|
1346 | + } |
|
1347 | + |
|
1348 | + /** |
|
1349 | + * Displays a list of tasks in this blog |
|
1350 | + * @author Toon Keppens |
|
1351 | + * |
|
1352 | + * @param Integer $blog_id |
|
1353 | + */ |
|
1354 | + public static function display_task_list($blog_id) |
|
1356 | 1355 | { |
1357 | - global $charset; |
|
1356 | + global $charset; |
|
1358 | 1357 | $course_id = api_get_course_int_id(); |
1359 | 1358 | |
1360 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) { |
|
1361 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1362 | - $counter = 0; |
|
1363 | - global $color2; |
|
1359 | + if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) { |
|
1360 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1361 | + $counter = 0; |
|
1362 | + global $color2; |
|
1364 | 1363 | |
1365 | - echo '<div class="actions">'; |
|
1366 | - echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=add"><img src="../img/blog_newtasks.gif" border="0" align="middle" alt="'.get_lang('AddTasks').'" />' . get_lang('AddTasks') . '</a> '; |
|
1367 | - echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=assign"><img src="../img/blog_task.gif" border="0" align="middle" alt="'.get_lang('AssignTasks').'" />' . get_lang('AssignTasks') . '</a>'; |
|
1368 | - ?> |
|
1364 | + echo '<div class="actions">'; |
|
1365 | + echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=add"><img src="../img/blog_newtasks.gif" border="0" align="middle" alt="'.get_lang('AddTasks').'" />' . get_lang('AddTasks') . '</a> '; |
|
1366 | + echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=assign"><img src="../img/blog_task.gif" border="0" align="middle" alt="'.get_lang('AssignTasks').'" />' . get_lang('AssignTasks') . '</a>'; |
|
1367 | + ?> |
|
1369 | 1368 | <a href="<?php echo api_get_self(); ?>?action=manage_rights&blog_id=<?php echo $blog_id ?>" title="<?php echo get_lang('ManageRights') ?>"><?php echo Display::return_icon('blog_admin_users.png', get_lang('RightsManager'),'',ICON_SIZE_SMALL). get_lang('RightsManager') ?></a> |
1370 | 1369 | <?php |
1371 | - echo '</div>'; |
|
1370 | + echo '</div>'; |
|
1372 | 1371 | |
1373 | - echo '<span class="blogpost_title">' . get_lang('TaskList') . '</span><br />'; |
|
1374 | - echo "<table class=\"data_table\">"; |
|
1375 | - echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">", |
|
1376 | - "<th width='240'><b>",get_lang('Title'),"</b></th>\n", |
|
1377 | - "<th><b>",get_lang('Description'),"</b></th>\n", |
|
1378 | - "<th><b>",get_lang('Color'),"</b></th>\n", |
|
1379 | - "<th width='50'><b>",get_lang('Modify'),"</b></th>\n", |
|
1380 | - "</tr>\n"; |
|
1372 | + echo '<span class="blogpost_title">' . get_lang('TaskList') . '</span><br />'; |
|
1373 | + echo "<table class=\"data_table\">"; |
|
1374 | + echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">", |
|
1375 | + "<th width='240'><b>",get_lang('Title'),"</b></th>\n", |
|
1376 | + "<th><b>",get_lang('Description'),"</b></th>\n", |
|
1377 | + "<th><b>",get_lang('Color'),"</b></th>\n", |
|
1378 | + "<th width='50'><b>",get_lang('Modify'),"</b></th>\n", |
|
1379 | + "</tr>\n"; |
|
1381 | 1380 | |
1382 | 1381 | |
1383 | - $sql = " SELECT |
|
1382 | + $sql = " SELECT |
|
1384 | 1383 | blog_id, |
1385 | 1384 | task_id, |
1386 | 1385 | blog_id, |
@@ -1391,64 +1390,64 @@ discard block |
||
1391 | 1390 | FROM " . $tbl_blogs_tasks . " |
1392 | 1391 | WHERE c_id = $course_id AND blog_id = " . (int)$blog_id . " |
1393 | 1392 | ORDER BY system_task, title"; |
1394 | - $result = Database::query($sql); |
|
1395 | - |
|
1396 | - |
|
1397 | - while($task = Database::fetch_array($result)) { |
|
1398 | - $counter++; |
|
1399 | - $css_class = (($counter % 2) == 0) ? "row_odd" : "row_even"; |
|
1400 | - $delete_icon = ($task['system_task'] == '1') ? "delete_na.gif" : "delete.gif"; |
|
1401 | - $delete_title = ($task['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask'); |
|
1402 | - $delete_link = ($task['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=delete&task_id=' . $task['task_id']; |
|
1403 | - $delete_confirm = ($task['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"'; |
|
1404 | - |
|
1405 | - echo '<tr class="' . $css_class . '" valign="top">', |
|
1406 | - '<td width="240">' . Security::remove_XSS($task['title']) . '</td>', |
|
1407 | - '<td>' . Security::remove_XSS($task['description']) . '</td>', |
|
1408 | - '<td><span style="background-color: #' . $task['color'] . '"> </span></td>', |
|
1409 | - '<td width="50">', |
|
1410 | - '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=edit&task_id=' . $task['task_id'] . '">', |
|
1411 | - '<img src="../img/edit.gif" border="0" title="' . get_lang('EditTask') . '" />', |
|
1412 | - "</a>\n", |
|
1413 | - '<a href="' . $delete_link . '"', |
|
1414 | - $delete_confirm, |
|
1415 | - '><img src="../img/' . $delete_icon . '" border="0" title="' . $delete_title . '" />', |
|
1416 | - "</a>\n", |
|
1417 | - '</td>', |
|
1418 | - '</tr>'; |
|
1419 | - } |
|
1420 | - echo "</table>"; |
|
1421 | - } |
|
1422 | - } |
|
1423 | - |
|
1424 | - /** |
|
1425 | - * Displays a list of tasks assigned to a user in this blog |
|
1426 | - * @author Toon Keppens |
|
1427 | - * |
|
1428 | - * @param Integer $blog_id |
|
1429 | - */ |
|
1430 | - public static function display_assigned_task_list ($blog_id) |
|
1393 | + $result = Database::query($sql); |
|
1394 | + |
|
1395 | + |
|
1396 | + while($task = Database::fetch_array($result)) { |
|
1397 | + $counter++; |
|
1398 | + $css_class = (($counter % 2) == 0) ? "row_odd" : "row_even"; |
|
1399 | + $delete_icon = ($task['system_task'] == '1') ? "delete_na.gif" : "delete.gif"; |
|
1400 | + $delete_title = ($task['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask'); |
|
1401 | + $delete_link = ($task['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=delete&task_id=' . $task['task_id']; |
|
1402 | + $delete_confirm = ($task['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"'; |
|
1403 | + |
|
1404 | + echo '<tr class="' . $css_class . '" valign="top">', |
|
1405 | + '<td width="240">' . Security::remove_XSS($task['title']) . '</td>', |
|
1406 | + '<td>' . Security::remove_XSS($task['description']) . '</td>', |
|
1407 | + '<td><span style="background-color: #' . $task['color'] . '"> </span></td>', |
|
1408 | + '<td width="50">', |
|
1409 | + '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=edit&task_id=' . $task['task_id'] . '">', |
|
1410 | + '<img src="../img/edit.gif" border="0" title="' . get_lang('EditTask') . '" />', |
|
1411 | + "</a>\n", |
|
1412 | + '<a href="' . $delete_link . '"', |
|
1413 | + $delete_confirm, |
|
1414 | + '><img src="../img/' . $delete_icon . '" border="0" title="' . $delete_title . '" />', |
|
1415 | + "</a>\n", |
|
1416 | + '</td>', |
|
1417 | + '</tr>'; |
|
1418 | + } |
|
1419 | + echo "</table>"; |
|
1420 | + } |
|
1421 | + } |
|
1422 | + |
|
1423 | + /** |
|
1424 | + * Displays a list of tasks assigned to a user in this blog |
|
1425 | + * @author Toon Keppens |
|
1426 | + * |
|
1427 | + * @param Integer $blog_id |
|
1428 | + */ |
|
1429 | + public static function display_assigned_task_list ($blog_id) |
|
1431 | 1430 | { |
1432 | - // Init |
|
1433 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
1434 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1435 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
1436 | - $counter = 0; |
|
1437 | - global $charset,$color2; |
|
1438 | - |
|
1439 | - echo '<span class="blogpost_title">' . get_lang('AssignedTasks') . '</span><br />'; |
|
1440 | - echo "<table class=\"data_table\">"; |
|
1441 | - echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">", |
|
1442 | - "<th width='240'><b>",get_lang('Member'),"</b></th>\n", |
|
1443 | - "<th><b>",get_lang('Task'),"</b></th>\n", |
|
1444 | - "<th><b>",get_lang('Description'),"</b></th>\n", |
|
1445 | - "<th><b>",get_lang('TargetDate'),"</b></th>\n", |
|
1446 | - "<th width='50'><b>",get_lang('Modify'),"</b></th>\n", |
|
1447 | - "</tr>"; |
|
1448 | - |
|
1449 | - $course_id = api_get_course_int_id(); |
|
1450 | - |
|
1451 | - $sql = "SELECT task_rel_user.*, task.title, user.firstname, user.lastname, user.username, task.description, task.system_task, task.blog_id, task.task_id |
|
1431 | + // Init |
|
1432 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
1433 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1434 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
1435 | + $counter = 0; |
|
1436 | + global $charset,$color2; |
|
1437 | + |
|
1438 | + echo '<span class="blogpost_title">' . get_lang('AssignedTasks') . '</span><br />'; |
|
1439 | + echo "<table class=\"data_table\">"; |
|
1440 | + echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">", |
|
1441 | + "<th width='240'><b>",get_lang('Member'),"</b></th>\n", |
|
1442 | + "<th><b>",get_lang('Task'),"</b></th>\n", |
|
1443 | + "<th><b>",get_lang('Description'),"</b></th>\n", |
|
1444 | + "<th><b>",get_lang('TargetDate'),"</b></th>\n", |
|
1445 | + "<th width='50'><b>",get_lang('Modify'),"</b></th>\n", |
|
1446 | + "</tr>"; |
|
1447 | + |
|
1448 | + $course_id = api_get_course_int_id(); |
|
1449 | + |
|
1450 | + $sql = "SELECT task_rel_user.*, task.title, user.firstname, user.lastname, user.username, task.description, task.system_task, task.blog_id, task.task_id |
|
1452 | 1451 | FROM $tbl_blogs_tasks_rel_user task_rel_user |
1453 | 1452 | INNER JOIN $tbl_blogs_tasks task ON task_rel_user.task_id = task.task_id |
1454 | 1453 | INNER JOIN $tbl_users user ON task_rel_user.user_id = user.user_id |
@@ -1457,45 +1456,45 @@ discard block |
||
1457 | 1456 | task.c_id = $course_id AND |
1458 | 1457 | task_rel_user.blog_id = '".(int)$blog_id."' |
1459 | 1458 | ORDER BY target_date ASC"; |
1460 | - $result = Database::query($sql); |
|
1459 | + $result = Database::query($sql); |
|
1461 | 1460 | |
1462 | - while ($assignment = Database::fetch_array($result)) { |
|
1463 | - $counter++; |
|
1464 | - $css_class = (($counter % 2)==0) ? "row_odd" : "row_even"; |
|
1465 | - $delete_icon = ($assignment['system_task'] == '1') ? "delete_na.gif" : "delete.gif"; |
|
1466 | - $delete_title = ($assignment['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask'); |
|
1467 | - $delete_link = ($assignment['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete&task_id=' . $assignment['task_id']; |
|
1468 | - $delete_confirm = ($assignment['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"'; |
|
1461 | + while ($assignment = Database::fetch_array($result)) { |
|
1462 | + $counter++; |
|
1463 | + $css_class = (($counter % 2)==0) ? "row_odd" : "row_even"; |
|
1464 | + $delete_icon = ($assignment['system_task'] == '1') ? "delete_na.gif" : "delete.gif"; |
|
1465 | + $delete_title = ($assignment['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask'); |
|
1466 | + $delete_link = ($assignment['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete&task_id=' . $assignment['task_id']; |
|
1467 | + $delete_confirm = ($assignment['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"'; |
|
1469 | 1468 | |
1470 | 1469 | $username = api_htmlentities(sprintf(get_lang('LoginX'), $assignment['username']), ENT_QUOTES); |
1471 | 1470 | |
1472 | - echo '<tr class="' . $css_class . '" valign="top">', |
|
1473 | - '<td width="240">' . Display::tag('span', api_get_person_name($assignment['firstname'], $assignment['lastname']), array('title'=>$username)) . '</td>', |
|
1474 | - '<td>'.stripslashes($assignment['title']) . '</td>', |
|
1475 | - '<td>'.stripslashes($assignment['description']) . '</td>', |
|
1476 | - '<td>' . $assignment['target_date'] . '</td>', |
|
1477 | - '<td width="50">', |
|
1478 | - '<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'] . '">', |
|
1479 | - '<img src="../img/edit.gif" border="0" title="' . get_lang('EditTask') . '" />', |
|
1480 | - "</a>\n", |
|
1481 | - '<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'] . '" ', |
|
1482 | - 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"', |
|
1483 | - '<img src="../img/' . $delete_icon . '" border="0" title="' . $delete_title . '" />', |
|
1484 | - "</a>\n", |
|
1485 | - '</td>', |
|
1486 | - '</tr>'; |
|
1487 | - } |
|
1488 | - echo "</table>"; |
|
1489 | - } |
|
1490 | - |
|
1491 | - /** |
|
1492 | - * Displays new task form |
|
1493 | - * @author Toon Keppens |
|
1494 | - * |
|
1495 | - */ |
|
1496 | - public static function display_new_task_form ($blog_id) |
|
1497 | - { |
|
1498 | - // Init |
|
1471 | + echo '<tr class="' . $css_class . '" valign="top">', |
|
1472 | + '<td width="240">' . Display::tag('span', api_get_person_name($assignment['firstname'], $assignment['lastname']), array('title'=>$username)) . '</td>', |
|
1473 | + '<td>'.stripslashes($assignment['title']) . '</td>', |
|
1474 | + '<td>'.stripslashes($assignment['description']) . '</td>', |
|
1475 | + '<td>' . $assignment['target_date'] . '</td>', |
|
1476 | + '<td width="50">', |
|
1477 | + '<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'] . '">', |
|
1478 | + '<img src="../img/edit.gif" border="0" title="' . get_lang('EditTask') . '" />', |
|
1479 | + "</a>\n", |
|
1480 | + '<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'] . '" ', |
|
1481 | + 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"', |
|
1482 | + '<img src="../img/' . $delete_icon . '" border="0" title="' . $delete_title . '" />', |
|
1483 | + "</a>\n", |
|
1484 | + '</td>', |
|
1485 | + '</tr>'; |
|
1486 | + } |
|
1487 | + echo "</table>"; |
|
1488 | + } |
|
1489 | + |
|
1490 | + /** |
|
1491 | + * Displays new task form |
|
1492 | + * @author Toon Keppens |
|
1493 | + * |
|
1494 | + */ |
|
1495 | + public static function display_new_task_form ($blog_id) |
|
1496 | + { |
|
1497 | + // Init |
|
1499 | 1498 | $colors = array( |
1500 | 1499 | 'FFFFFF', |
1501 | 1500 | 'FFFF99', |
@@ -1514,14 +1513,14 @@ discard block |
||
1514 | 1513 | '000000' |
1515 | 1514 | ); |
1516 | 1515 | |
1517 | - // form |
|
1518 | - echo '<form name="add_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '">'; |
|
1516 | + // form |
|
1517 | + echo '<form name="add_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '">'; |
|
1519 | 1518 | |
1520 | - // form title |
|
1521 | - echo '<legend>'.get_lang('AddTask').'</legend>'; |
|
1519 | + // form title |
|
1520 | + echo '<legend>'.get_lang('AddTask').'</legend>'; |
|
1522 | 1521 | |
1523 | - // task title |
|
1524 | - echo ' <div class="control-group"> |
|
1522 | + // task title |
|
1523 | + echo ' <div class="control-group"> |
|
1525 | 1524 | <label class="control-label"> |
1526 | 1525 | <span class="form_required">*</span>' . get_lang('Title') . ' |
1527 | 1526 | </label> |
@@ -1530,8 +1529,8 @@ discard block |
||
1530 | 1529 | </div> |
1531 | 1530 | </div>'; |
1532 | 1531 | |
1533 | - // task comment |
|
1534 | - echo ' <div class="control-group"> |
|
1532 | + // task comment |
|
1533 | + echo ' <div class="control-group"> |
|
1535 | 1534 | <label class="control-label"> |
1536 | 1535 | ' . get_lang('Description') . ' |
1537 | 1536 | </label> |
@@ -1540,8 +1539,8 @@ discard block |
||
1540 | 1539 | </div> |
1541 | 1540 | </div>'; |
1542 | 1541 | |
1543 | - // task management |
|
1544 | - echo ' <div class="control-group"> |
|
1542 | + // task management |
|
1543 | + echo ' <div class="control-group"> |
|
1545 | 1544 | <label class="control-label"> |
1546 | 1545 | ' . get_lang('TaskManager') . ' |
1547 | 1546 | </label> |
@@ -1562,12 +1561,12 @@ discard block |
||
1562 | 1561 | echo '<td style="border:1px dotted #808080; text-align:center;"><input id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>'; |
1563 | 1562 | echo '</tr>'; |
1564 | 1563 | echo '</table>'; |
1565 | - echo ' </div> |
|
1564 | + echo ' </div> |
|
1566 | 1565 | </div>'; |
1567 | 1566 | |
1568 | 1567 | |
1569 | - // task color |
|
1570 | - echo ' <div class="control-group"> |
|
1568 | + // task color |
|
1569 | + echo ' <div class="control-group"> |
|
1571 | 1570 | <label class="control-label"> |
1572 | 1571 | ' . get_lang('Color') . ' |
1573 | 1572 | </label> |
@@ -1578,40 +1577,40 @@ discard block |
||
1578 | 1577 | echo '<option value="' . $color . '" ' . $style . '> </option>'; |
1579 | 1578 | } |
1580 | 1579 | echo '</select>'; |
1581 | - echo ' </div> |
|
1580 | + echo ' </div> |
|
1582 | 1581 | </div>'; |
1583 | 1582 | |
1584 | - // submit |
|
1585 | - echo ' <div class="control-group"> |
|
1583 | + // submit |
|
1584 | + echo ' <div class="control-group"> |
|
1586 | 1585 | <div class="controls"> |
1587 | 1586 | <input type="hidden" name="action" value="" /> |
1588 | 1587 | <input type="hidden" name="new_task_submit" value="true" /> |
1589 | 1588 | <button class="save" type="submit" name="Submit">' . get_lang('Save') . '</button> |
1590 | 1589 | </div> |
1591 | 1590 | </div>'; |
1592 | - echo '</form>'; |
|
1591 | + echo '</form>'; |
|
1593 | 1592 | |
1594 | - echo '<div style="clear:both; margin-bottom: 10px;"></div>'; |
|
1595 | - } |
|
1593 | + echo '<div style="clear:both; margin-bottom: 10px;"></div>'; |
|
1594 | + } |
|
1596 | 1595 | |
1597 | 1596 | |
1598 | - /** |
|
1599 | - * Displays edit task form |
|
1600 | - * @author Toon Keppens |
|
1601 | - * |
|
1602 | - */ |
|
1603 | - public static function display_edit_task_form ($blog_id, $task_id) { |
|
1604 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1597 | + /** |
|
1598 | + * Displays edit task form |
|
1599 | + * @author Toon Keppens |
|
1600 | + * |
|
1601 | + */ |
|
1602 | + public static function display_edit_task_form ($blog_id, $task_id) { |
|
1603 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1605 | 1604 | $course_id = api_get_course_int_id(); |
1606 | 1605 | |
1607 | - $colors = array('FFFFFF','FFFF99','FFCC99','FF9933','FF6699','CCFF99','CC9966','66FF00', '9966FF', 'CF3F3F', '990033','669933','0033FF','003366','000000'); |
|
1606 | + $colors = array('FFFFFF','FFFF99','FFCC99','FF9933','FF6699','CCFF99','CC9966','66FF00', '9966FF', 'CF3F3F', '990033','669933','0033FF','003366','000000'); |
|
1608 | 1607 | |
1609 | - $sql = "SELECT blog_id, task_id, title, description, color FROM $tbl_blogs_tasks WHERE c_id = $course_id AND task_id = '".(int)$task_id."'"; |
|
1610 | - $result = Database::query($sql); |
|
1611 | - $task = Database::fetch_array($result); |
|
1608 | + $sql = "SELECT blog_id, task_id, title, description, color FROM $tbl_blogs_tasks WHERE c_id = $course_id AND task_id = '".(int)$task_id."'"; |
|
1609 | + $result = Database::query($sql); |
|
1610 | + $task = Database::fetch_array($result); |
|
1612 | 1611 | |
1613 | - // Display |
|
1614 | - echo '<form name="edit_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '"> |
|
1612 | + // Display |
|
1613 | + echo '<form name="edit_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '"> |
|
1615 | 1614 | <legend>' . get_lang('EditTask') . '</legend> |
1616 | 1615 | <table width="100%" border="0" cellspacing="2"> |
1617 | 1616 | <tr> |
@@ -1623,42 +1622,42 @@ discard block |
||
1623 | 1622 | <td><textarea name="task_description" cols="45">'.Security::remove_XSS($task['description']).'</textarea></td> |
1624 | 1623 | </tr>'; |
1625 | 1624 | |
1626 | - /* edit by Kevin Van Den Haute ([email protected]) */ |
|
1627 | - $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
1625 | + /* edit by Kevin Van Den Haute ([email protected]) */ |
|
1626 | + $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
1628 | 1627 | |
1629 | - $sql = " SELECT id, action FROM " . $tbl_tasks_permissions . " |
|
1628 | + $sql = " SELECT id, action FROM " . $tbl_tasks_permissions . " |
|
1630 | 1629 | WHERE c_id = $course_id AND task_id = '" . (int)$task_id."'"; |
1631 | - $result = Database::query($sql); |
|
1632 | - |
|
1633 | - $arrPermissions = array(); |
|
1634 | - |
|
1635 | - while ($row = Database::fetch_array($result)) |
|
1636 | - $arrPermissions[] = $row['action']; |
|
1637 | - |
|
1638 | - echo '<tr>'; |
|
1639 | - echo '<td style="text-align:right; vertical-align:top;">' . get_lang('TaskManager') . ': </td>'; |
|
1640 | - echo '<td>'; |
|
1641 | - echo '<table class="data_table" cellspacing="0" style="border-collapse:collapse; width:446px;">'; |
|
1642 | - echo '<tr>'; |
|
1643 | - echo '<th colspan="2" style="width:223px;">' . get_lang('ArticleManager') . '</th>'; |
|
1644 | - echo '<th width:223px;>' . get_lang('CommentManager') . '</th>'; |
|
1645 | - echo '</tr>'; |
|
1646 | - echo '<tr>'; |
|
1647 | - echo '<th style="width:111px;"><label for="articleDelete">' . get_lang('Delete') . '</label></th>'; |
|
1648 | - echo '<th style="width:112px;"><label for="articleEdit">' . get_lang('Edit') . '</label></th>'; |
|
1649 | - echo '<th style="width:223px;"><label for="commentsDelete">' . get_lang('Delete') . '</label></th>'; |
|
1650 | - echo '</tr>'; |
|
1651 | - echo '<tr>'; |
|
1652 | - echo '<td style="text-align:center;"><input ' . ((in_array('article_delete', $arrPermissions)) ? 'checked ' : '') . 'id="articleDelete" name="chkArticleDelete" type="checkbox" /></td>'; |
|
1653 | - echo '<td style="text-align:center;"><input ' . ((in_array('article_edit', $arrPermissions)) ? 'checked ' : '') . 'id="articleEdit" name="chkArticleEdit" type="checkbox" /></td>'; |
|
1654 | - echo '<td style="text-align:center;"><input ' . ((in_array('article_comments_delete', $arrPermissions)) ? 'checked ' : '') . 'id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>'; |
|
1655 | - echo '</tr>'; |
|
1656 | - echo '</table>'; |
|
1657 | - echo '</td>'; |
|
1658 | - echo '</tr>'; |
|
1659 | - /* end of edit */ |
|
1660 | - |
|
1661 | - echo '<tr> |
|
1630 | + $result = Database::query($sql); |
|
1631 | + |
|
1632 | + $arrPermissions = array(); |
|
1633 | + |
|
1634 | + while ($row = Database::fetch_array($result)) |
|
1635 | + $arrPermissions[] = $row['action']; |
|
1636 | + |
|
1637 | + echo '<tr>'; |
|
1638 | + echo '<td style="text-align:right; vertical-align:top;">' . get_lang('TaskManager') . ': </td>'; |
|
1639 | + echo '<td>'; |
|
1640 | + echo '<table class="data_table" cellspacing="0" style="border-collapse:collapse; width:446px;">'; |
|
1641 | + echo '<tr>'; |
|
1642 | + echo '<th colspan="2" style="width:223px;">' . get_lang('ArticleManager') . '</th>'; |
|
1643 | + echo '<th width:223px;>' . get_lang('CommentManager') . '</th>'; |
|
1644 | + echo '</tr>'; |
|
1645 | + echo '<tr>'; |
|
1646 | + echo '<th style="width:111px;"><label for="articleDelete">' . get_lang('Delete') . '</label></th>'; |
|
1647 | + echo '<th style="width:112px;"><label for="articleEdit">' . get_lang('Edit') . '</label></th>'; |
|
1648 | + echo '<th style="width:223px;"><label for="commentsDelete">' . get_lang('Delete') . '</label></th>'; |
|
1649 | + echo '</tr>'; |
|
1650 | + echo '<tr>'; |
|
1651 | + echo '<td style="text-align:center;"><input ' . ((in_array('article_delete', $arrPermissions)) ? 'checked ' : '') . 'id="articleDelete" name="chkArticleDelete" type="checkbox" /></td>'; |
|
1652 | + echo '<td style="text-align:center;"><input ' . ((in_array('article_edit', $arrPermissions)) ? 'checked ' : '') . 'id="articleEdit" name="chkArticleEdit" type="checkbox" /></td>'; |
|
1653 | + echo '<td style="text-align:center;"><input ' . ((in_array('article_comments_delete', $arrPermissions)) ? 'checked ' : '') . 'id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>'; |
|
1654 | + echo '</tr>'; |
|
1655 | + echo '</table>'; |
|
1656 | + echo '</td>'; |
|
1657 | + echo '</tr>'; |
|
1658 | + /* end of edit */ |
|
1659 | + |
|
1660 | + echo '<tr> |
|
1662 | 1661 | <td align="right">' . get_lang('Color') . ': </td> |
1663 | 1662 | <td> |
1664 | 1663 | <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">'; |
@@ -1667,7 +1666,7 @@ discard block |
||
1667 | 1666 | $style = 'style="background-color: #' . $color . '"'; |
1668 | 1667 | echo '<option value="' . $color . '" ' . $style . ' ' . $selected . ' > </option>'; |
1669 | 1668 | } |
1670 | - echo ' </select> |
|
1669 | + echo ' </select> |
|
1671 | 1670 | </td> |
1672 | 1671 | </tr> |
1673 | 1672 | <tr> |
@@ -1680,34 +1679,34 @@ discard block |
||
1680 | 1679 | </tr> |
1681 | 1680 | </table> |
1682 | 1681 | </form>'; |
1683 | - } |
|
1684 | - |
|
1685 | - /** |
|
1686 | - * @param $blog_id |
|
1687 | - * @return FormValidator |
|
1688 | - */ |
|
1689 | - public static function getTaskForm($blog_id) |
|
1690 | - { |
|
1691 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
1692 | - $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
1693 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1694 | - $course_id = api_get_course_int_id(); |
|
1695 | - |
|
1696 | - // Get users in this blog / make select list of it |
|
1697 | - $sql = "SELECT user.user_id, user.firstname, user.lastname, user.username |
|
1682 | + } |
|
1683 | + |
|
1684 | + /** |
|
1685 | + * @param $blog_id |
|
1686 | + * @return FormValidator |
|
1687 | + */ |
|
1688 | + public static function getTaskForm($blog_id) |
|
1689 | + { |
|
1690 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
1691 | + $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
1692 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1693 | + $course_id = api_get_course_int_id(); |
|
1694 | + |
|
1695 | + // Get users in this blog / make select list of it |
|
1696 | + $sql = "SELECT user.user_id, user.firstname, user.lastname, user.username |
|
1698 | 1697 | FROM $tbl_users user |
1699 | 1698 | INNER JOIN $tbl_blogs_rel_user blogs_rel_user |
1700 | 1699 | ON user.user_id = blogs_rel_user.user_id |
1701 | 1700 | WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".(int)$blog_id."'"; |
1702 | - $result = Database::query($sql); |
|
1701 | + $result = Database::query($sql); |
|
1703 | 1702 | |
1704 | - $options = array(); |
|
1705 | - while ($user = Database::fetch_array($result)) { |
|
1706 | - $options[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']); |
|
1707 | - } |
|
1703 | + $options = array(); |
|
1704 | + while ($user = Database::fetch_array($result)) { |
|
1705 | + $options[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']); |
|
1706 | + } |
|
1708 | 1707 | |
1709 | - // Get tasks in this blog / make select list of it |
|
1710 | - $sql = " |
|
1708 | + // Get tasks in this blog / make select list of it |
|
1709 | + $sql = " |
|
1711 | 1710 | SELECT |
1712 | 1711 | blog_id, |
1713 | 1712 | task_id, |
@@ -1719,97 +1718,97 @@ discard block |
||
1719 | 1718 | FROM $tbl_blogs_tasks |
1720 | 1719 | WHERE c_id = $course_id AND blog_id = " . (int)$blog_id . " |
1721 | 1720 | ORDER BY system_task, title"; |
1722 | - $result = Database::query($sql); |
|
1723 | - |
|
1724 | - $taskOptions = array(); |
|
1725 | - while ($task = Database::fetch_array($result)) { |
|
1726 | - $taskOptions[$task['task_id']] = stripslashes($task['title']); |
|
1727 | - } |
|
1728 | - |
|
1729 | - $form = new FormValidator( |
|
1730 | - 'assign_task', |
|
1731 | - 'post', |
|
1732 | - api_get_path( |
|
1733 | - WEB_CODE_PATH |
|
1734 | - ).'blog/blog.php?action=manage_tasks&blog_id='.$blog_id |
|
1735 | - ); |
|
1736 | - |
|
1737 | - $form->addHeader(get_lang('AssignTask')); |
|
1738 | - $form->addSelect('task_user_id', get_lang('SelectUser'), $options); |
|
1739 | - $form->addSelect('task_task_id', get_lang('SelectTask'), $taskOptions); |
|
1740 | - $form->addDatePicker('task_day', get_lang('SelectTargetDate')); |
|
1741 | - |
|
1742 | - $form->addHidden('action', ''); |
|
1743 | - $form->addButtonSave(get_lang('Ok')); |
|
1744 | - |
|
1745 | - return $form; |
|
1746 | - } |
|
1747 | - |
|
1748 | - /** |
|
1749 | - * Displays assign task form |
|
1750 | - * @author Toon Keppens |
|
1751 | - * |
|
1752 | - */ |
|
1753 | - public static function display_assign_task_form($blog_id) |
|
1754 | - { |
|
1755 | - $form = self::getTaskForm($blog_id); |
|
1756 | - $form->addHidden('assign_task_submit', 'true'); |
|
1757 | - $form->display(); |
|
1758 | - echo '<div style="clear: both; margin-bottom:10px;"></div>'; |
|
1759 | - } |
|
1760 | - |
|
1761 | - /** |
|
1762 | - * Displays assign task form |
|
1763 | - * @author Toon Keppens |
|
1764 | - * |
|
1765 | - */ |
|
1766 | - public static function display_edit_assigned_task_form($blog_id, $task_id, $user_id) |
|
1767 | - { |
|
1768 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
1769 | - |
|
1770 | - $course_id = api_get_course_int_id(); |
|
1771 | - |
|
1772 | - // Get assignd date; |
|
1773 | - $sql = " |
|
1721 | + $result = Database::query($sql); |
|
1722 | + |
|
1723 | + $taskOptions = array(); |
|
1724 | + while ($task = Database::fetch_array($result)) { |
|
1725 | + $taskOptions[$task['task_id']] = stripslashes($task['title']); |
|
1726 | + } |
|
1727 | + |
|
1728 | + $form = new FormValidator( |
|
1729 | + 'assign_task', |
|
1730 | + 'post', |
|
1731 | + api_get_path( |
|
1732 | + WEB_CODE_PATH |
|
1733 | + ).'blog/blog.php?action=manage_tasks&blog_id='.$blog_id |
|
1734 | + ); |
|
1735 | + |
|
1736 | + $form->addHeader(get_lang('AssignTask')); |
|
1737 | + $form->addSelect('task_user_id', get_lang('SelectUser'), $options); |
|
1738 | + $form->addSelect('task_task_id', get_lang('SelectTask'), $taskOptions); |
|
1739 | + $form->addDatePicker('task_day', get_lang('SelectTargetDate')); |
|
1740 | + |
|
1741 | + $form->addHidden('action', ''); |
|
1742 | + $form->addButtonSave(get_lang('Ok')); |
|
1743 | + |
|
1744 | + return $form; |
|
1745 | + } |
|
1746 | + |
|
1747 | + /** |
|
1748 | + * Displays assign task form |
|
1749 | + * @author Toon Keppens |
|
1750 | + * |
|
1751 | + */ |
|
1752 | + public static function display_assign_task_form($blog_id) |
|
1753 | + { |
|
1754 | + $form = self::getTaskForm($blog_id); |
|
1755 | + $form->addHidden('assign_task_submit', 'true'); |
|
1756 | + $form->display(); |
|
1757 | + echo '<div style="clear: both; margin-bottom:10px;"></div>'; |
|
1758 | + } |
|
1759 | + |
|
1760 | + /** |
|
1761 | + * Displays assign task form |
|
1762 | + * @author Toon Keppens |
|
1763 | + * |
|
1764 | + */ |
|
1765 | + public static function display_edit_assigned_task_form($blog_id, $task_id, $user_id) |
|
1766 | + { |
|
1767 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
1768 | + |
|
1769 | + $course_id = api_get_course_int_id(); |
|
1770 | + |
|
1771 | + // Get assignd date; |
|
1772 | + $sql = " |
|
1774 | 1773 | SELECT target_date |
1775 | 1774 | FROM $tbl_blogs_tasks_rel_user |
1776 | 1775 | WHERE c_id = $course_id AND |
1777 | 1776 | blog_id = '".(int)$blog_id."' AND |
1778 | 1777 | user_id = '".(int)$user_id."' AND |
1779 | 1778 | task_id = '".(int)$task_id."'"; |
1780 | - $result = Database::query($sql); |
|
1781 | - $row = Database::fetch_assoc($result); |
|
1782 | - |
|
1783 | - $date = $row['target_date']; |
|
1784 | - |
|
1785 | - $defaults = [ |
|
1786 | - 'task_user_id' => $user_id, |
|
1787 | - 'task_task_id' => $task_id, |
|
1788 | - 'task_day' => $date |
|
1789 | - ]; |
|
1790 | - $form = self::getTaskForm($blog_id); |
|
1791 | - $form->addHidden('old_task_id', $task_id); |
|
1792 | - $form->addHidden('old_user_id', $user_id); |
|
1793 | - $form->addHidden('old_target_date', $date); |
|
1794 | - $form->addHidden('assign_task_edit_submit', 'true'); |
|
1795 | - $form->setDefaults($defaults); |
|
1796 | - $form->display(); |
|
1797 | - } |
|
1798 | - |
|
1799 | - /** |
|
1800 | - * Assigns a task to a user in a blog |
|
1801 | - * |
|
1802 | - * @param Integer $blog_id |
|
1803 | - * @param Integer $user_id |
|
1804 | - * @param Integer $task_id |
|
1805 | - * @param Date $target_date |
|
1806 | - */ |
|
1807 | - public static function assign_task($blog_id, $user_id, $task_id, $target_date) |
|
1808 | - { |
|
1809 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
1810 | - $course_id = api_get_course_int_id(); |
|
1811 | - |
|
1812 | - $sql = " |
|
1779 | + $result = Database::query($sql); |
|
1780 | + $row = Database::fetch_assoc($result); |
|
1781 | + |
|
1782 | + $date = $row['target_date']; |
|
1783 | + |
|
1784 | + $defaults = [ |
|
1785 | + 'task_user_id' => $user_id, |
|
1786 | + 'task_task_id' => $task_id, |
|
1787 | + 'task_day' => $date |
|
1788 | + ]; |
|
1789 | + $form = self::getTaskForm($blog_id); |
|
1790 | + $form->addHidden('old_task_id', $task_id); |
|
1791 | + $form->addHidden('old_user_id', $user_id); |
|
1792 | + $form->addHidden('old_target_date', $date); |
|
1793 | + $form->addHidden('assign_task_edit_submit', 'true'); |
|
1794 | + $form->setDefaults($defaults); |
|
1795 | + $form->display(); |
|
1796 | + } |
|
1797 | + |
|
1798 | + /** |
|
1799 | + * Assigns a task to a user in a blog |
|
1800 | + * |
|
1801 | + * @param Integer $blog_id |
|
1802 | + * @param Integer $user_id |
|
1803 | + * @param Integer $task_id |
|
1804 | + * @param Date $target_date |
|
1805 | + */ |
|
1806 | + public static function assign_task($blog_id, $user_id, $task_id, $target_date) |
|
1807 | + { |
|
1808 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
1809 | + $course_id = api_get_course_int_id(); |
|
1810 | + |
|
1811 | + $sql = " |
|
1813 | 1812 | SELECT COUNT(*) as 'number' |
1814 | 1813 | FROM " . $tbl_blogs_tasks_rel_user . " |
1815 | 1814 | WHERE c_id = $course_id AND |
@@ -1818,11 +1817,11 @@ discard block |
||
1818 | 1817 | AND task_id = " . (int)$task_id . " |
1819 | 1818 | "; |
1820 | 1819 | |
1821 | - $result = Database::query($sql); |
|
1822 | - $row = Database::fetch_assoc($result); |
|
1820 | + $result = Database::query($sql); |
|
1821 | + $row = Database::fetch_assoc($result); |
|
1823 | 1822 | |
1824 | - if ($row['number'] == 0) { |
|
1825 | - $sql = " |
|
1823 | + if ($row['number'] == 0) { |
|
1824 | + $sql = " |
|
1826 | 1825 | INSERT INTO " . $tbl_blogs_tasks_rel_user . " ( |
1827 | 1826 | c_id, |
1828 | 1827 | blog_id, |
@@ -1837,9 +1836,9 @@ discard block |
||
1837 | 1836 | '" . Database::escape_string($target_date) . "' |
1838 | 1837 | )"; |
1839 | 1838 | |
1840 | - Database::query($sql); |
|
1841 | - } |
|
1842 | - } |
|
1839 | + Database::query($sql); |
|
1840 | + } |
|
1841 | + } |
|
1843 | 1842 | |
1844 | 1843 | /** |
1845 | 1844 | * @param $blog_id |
@@ -1859,11 +1858,11 @@ discard block |
||
1859 | 1858 | $old_task_id, |
1860 | 1859 | $old_target_date |
1861 | 1860 | ) { |
1862 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
1861 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
1863 | 1862 | |
1864 | - $course_id = api_get_course_int_id(); |
|
1863 | + $course_id = api_get_course_int_id(); |
|
1865 | 1864 | |
1866 | - $sql = "SELECT COUNT(*) as 'number' |
|
1865 | + $sql = "SELECT COUNT(*) as 'number' |
|
1867 | 1866 | FROM " . $tbl_blogs_tasks_rel_user . " |
1868 | 1867 | WHERE |
1869 | 1868 | c_id = $course_id AND |
@@ -1872,11 +1871,11 @@ discard block |
||
1872 | 1871 | task_id = " . (int)$task_id . " |
1873 | 1872 | "; |
1874 | 1873 | |
1875 | - $result = Database::query($sql); |
|
1876 | - $row = Database::fetch_assoc($result); |
|
1874 | + $result = Database::query($sql); |
|
1875 | + $row = Database::fetch_assoc($result); |
|
1877 | 1876 | |
1878 | - if ($row['number'] == 0 || ($row['number'] != 0 && $task_id == $old_task_id && $user_id == $old_user_id)) { |
|
1879 | - $sql = " |
|
1877 | + if ($row['number'] == 0 || ($row['number'] != 0 && $task_id == $old_task_id && $user_id == $old_user_id)) { |
|
1878 | + $sql = " |
|
1880 | 1879 | UPDATE " . $tbl_blogs_tasks_rel_user . " |
1881 | 1880 | SET |
1882 | 1881 | user_id = " . (int)$user_id . ", |
@@ -1889,76 +1888,76 @@ discard block |
||
1889 | 1888 | task_id = " . (int)$old_task_id . " AND |
1890 | 1889 | target_date = '" . Database::escape_string($old_target_date) . "' |
1891 | 1890 | "; |
1892 | - Database::query($sql); |
|
1893 | - } |
|
1894 | - } |
|
1895 | - |
|
1896 | - /** |
|
1897 | - * Displays a list with posts a user can select to execute his task. |
|
1898 | - * |
|
1899 | - * @param Integer $blog_id |
|
1900 | - * @param unknown_type $task_id |
|
1901 | - */ |
|
1902 | - public static function display_select_task_post($blog_id, $task_id) |
|
1891 | + Database::query($sql); |
|
1892 | + } |
|
1893 | + } |
|
1894 | + |
|
1895 | + /** |
|
1896 | + * Displays a list with posts a user can select to execute his task. |
|
1897 | + * |
|
1898 | + * @param Integer $blog_id |
|
1899 | + * @param unknown_type $task_id |
|
1900 | + */ |
|
1901 | + public static function display_select_task_post($blog_id, $task_id) |
|
1903 | 1902 | { |
1904 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1905 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
1906 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
1907 | - $course_id = api_get_course_int_id(); |
|
1903 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1904 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
1905 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
1906 | + $course_id = api_get_course_int_id(); |
|
1908 | 1907 | |
1909 | 1908 | |
1910 | - $sql = "SELECT title, description FROM $tbl_blogs_tasks |
|
1909 | + $sql = "SELECT title, description FROM $tbl_blogs_tasks |
|
1911 | 1910 | WHERE task_id = '".(int)$task_id."' |
1912 | 1911 | AND c_id = $course_id"; |
1913 | - $result = Database::query($sql); |
|
1914 | - $row = Database::fetch_assoc($result); |
|
1915 | - // Get posts and authors |
|
1916 | - $sql = "SELECT post.*, user.lastname, user.firstname, user.username |
|
1912 | + $result = Database::query($sql); |
|
1913 | + $row = Database::fetch_assoc($result); |
|
1914 | + // Get posts and authors |
|
1915 | + $sql = "SELECT post.*, user.lastname, user.firstname, user.username |
|
1917 | 1916 | FROM $tbl_blogs_posts post |
1918 | 1917 | INNER JOIN $tbl_users user ON post.author_id = user.user_id |
1919 | 1918 | WHERE post.blog_id = '".(int)$blog_id."' AND post.c_id = $course_id |
1920 | 1919 | ORDER BY post_id DESC |
1921 | 1920 | LIMIT 0, 100"; |
1922 | - $result = Database::query($sql); |
|
1921 | + $result = Database::query($sql); |
|
1923 | 1922 | |
1924 | - // Display |
|
1925 | - echo '<span class="blogpost_title">' . get_lang('SelectTaskArticle') . ' "' . stripslashes($row['title']) . '"</span>'; |
|
1926 | - echo '<span style="font-style: italic;"">'.stripslashes($row['description']) . '</span><br><br>'; |
|
1923 | + // Display |
|
1924 | + echo '<span class="blogpost_title">' . get_lang('SelectTaskArticle') . ' "' . stripslashes($row['title']) . '"</span>'; |
|
1925 | + echo '<span style="font-style: italic;"">'.stripslashes($row['description']) . '</span><br><br>'; |
|
1927 | 1926 | |
1928 | - if (Database::num_rows($result) > 0) { |
|
1929 | - while($blog_post = Database::fetch_array($result)) { |
|
1930 | - $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES); |
|
1931 | - 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 />'; |
|
1932 | - } |
|
1927 | + if (Database::num_rows($result) > 0) { |
|
1928 | + while($blog_post = Database::fetch_array($result)) { |
|
1929 | + $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES); |
|
1930 | + 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 />'; |
|
1931 | + } |
|
1933 | 1932 | } else { |
1934 | 1933 | echo get_lang('NoArticles'); |
1935 | 1934 | } |
1936 | - } |
|
1937 | - |
|
1938 | - /** |
|
1939 | - * Subscribes a user to a given blog |
|
1940 | - * @author Toon Keppens |
|
1941 | - * |
|
1942 | - * @param Integer $blog_id |
|
1943 | - * @param Integer $user_id |
|
1944 | - */ |
|
1945 | - public static function set_user_subscribed($blog_id, $user_id) |
|
1935 | + } |
|
1936 | + |
|
1937 | + /** |
|
1938 | + * Subscribes a user to a given blog |
|
1939 | + * @author Toon Keppens |
|
1940 | + * |
|
1941 | + * @param Integer $blog_id |
|
1942 | + * @param Integer $user_id |
|
1943 | + */ |
|
1944 | + public static function set_user_subscribed($blog_id, $user_id) |
|
1946 | 1945 | { |
1947 | - // Init |
|
1948 | - $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
1949 | - $tbl_user_permissions = Database::get_course_table(TABLE_PERMISSION_USER); |
|
1946 | + // Init |
|
1947 | + $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
1948 | + $tbl_user_permissions = Database::get_course_table(TABLE_PERMISSION_USER); |
|
1950 | 1949 | |
1951 | - $course_id = api_get_course_int_id(); |
|
1950 | + $course_id = api_get_course_int_id(); |
|
1952 | 1951 | |
1953 | - // Subscribe the user |
|
1954 | - $sql = "INSERT INTO $tbl_blogs_rel_user (c_id, blog_id, user_id ) |
|
1952 | + // Subscribe the user |
|
1953 | + $sql = "INSERT INTO $tbl_blogs_rel_user (c_id, blog_id, user_id ) |
|
1955 | 1954 | VALUES ($course_id, '".(int)$blog_id."', '".(int)$user_id."');"; |
1956 | - Database::query($sql); |
|
1955 | + Database::query($sql); |
|
1957 | 1956 | |
1958 | - // Give this user basic rights |
|
1959 | - $sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action) |
|
1957 | + // Give this user basic rights |
|
1958 | + $sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action) |
|
1960 | 1959 | VALUES ($course_id, '".(int)$user_id."','BLOG_" . (int)$blog_id."','article_add')"; |
1961 | - Database::query($sql); |
|
1960 | + Database::query($sql); |
|
1962 | 1961 | |
1963 | 1962 | $id = Database::insert_id(); |
1964 | 1963 | if ($id) { |
@@ -1966,9 +1965,9 @@ discard block |
||
1966 | 1965 | Database::query($sql); |
1967 | 1966 | } |
1968 | 1967 | |
1969 | - $sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action) |
|
1968 | + $sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action) |
|
1970 | 1969 | VALUES ($course_id, '".(int)$user_id."','BLOG_" . (int)$blog_id."','article_comments_add')"; |
1971 | - Database::query($sql); |
|
1970 | + Database::query($sql); |
|
1972 | 1971 | |
1973 | 1972 | $id = Database::insert_id(); |
1974 | 1973 | if ($id) { |
@@ -1976,197 +1975,197 @@ discard block |
||
1976 | 1975 | Database::query($sql); |
1977 | 1976 | } |
1978 | 1977 | |
1979 | - } |
|
1978 | + } |
|
1980 | 1979 | |
1981 | - /** |
|
1982 | - * Unsubscribe a user from a given blog |
|
1983 | - * @author Toon Keppens |
|
1984 | - * |
|
1985 | - * @param Integer $blog_id |
|
1986 | - * @param Integer $user_id |
|
1987 | - */ |
|
1988 | - public static function set_user_unsubscribed($blog_id, $user_id) |
|
1980 | + /** |
|
1981 | + * Unsubscribe a user from a given blog |
|
1982 | + * @author Toon Keppens |
|
1983 | + * |
|
1984 | + * @param Integer $blog_id |
|
1985 | + * @param Integer $user_id |
|
1986 | + */ |
|
1987 | + public static function set_user_unsubscribed($blog_id, $user_id) |
|
1989 | 1988 | { |
1990 | - // Init |
|
1989 | + // Init |
|
1991 | 1990 | $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
1992 | 1991 | $tbl_user_permissions = Database::get_course_table(TABLE_PERMISSION_USER); |
1993 | 1992 | |
1994 | - // Unsubscribe the user |
|
1995 | - $sql = "DELETE FROM $tbl_blogs_rel_user |
|
1993 | + // Unsubscribe the user |
|
1994 | + $sql = "DELETE FROM $tbl_blogs_rel_user |
|
1996 | 1995 | WHERE blog_id = '".(int)$blog_id."' AND user_id = '".(int)$user_id."'"; |
1997 | - Database::query($sql); |
|
1996 | + Database::query($sql); |
|
1998 | 1997 | |
1999 | - // Remove this user's permissions. |
|
2000 | - $sql = "DELETE FROM $tbl_user_permissions |
|
1998 | + // Remove this user's permissions. |
|
1999 | + $sql = "DELETE FROM $tbl_user_permissions |
|
2001 | 2000 | WHERE user_id = '".(int)$user_id."'"; |
2002 | - Database::query($sql); |
|
2003 | - } |
|
2004 | - |
|
2005 | - /** |
|
2006 | - * Displays the form to register users in a blog (in a course) |
|
2007 | - * The listed users are users subcribed in the course. |
|
2008 | - * @author Toon Keppens |
|
2009 | - * |
|
2010 | - * @param Integer $blog_id |
|
2011 | - * |
|
2012 | - * @return Html Form with sortable table with users to subcribe in a blog, in a course. |
|
2013 | - */ |
|
2014 | - public static function display_form_user_subscribe($blog_id) |
|
2015 | - { |
|
2016 | - $_course = api_get_course_info(); |
|
2017 | - $is_western_name_order = api_is_western_name_order(); |
|
2018 | - $session_id = api_get_session_id(); |
|
2019 | - $course_id = $_course['real_id']; |
|
2020 | - |
|
2021 | - $currentCourse = $_course['code']; |
|
2022 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
2023 | - $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
2024 | - |
|
2025 | - echo '<legend>'.get_lang('SubscribeMembers').'</legend>'; |
|
2026 | - |
|
2027 | - $properties["width"] = "100%"; |
|
2028 | - |
|
2029 | - // Get blog members' id. |
|
2030 | - $sql = "SELECT user.user_id FROM $tbl_users user |
|
2001 | + Database::query($sql); |
|
2002 | + } |
|
2003 | + |
|
2004 | + /** |
|
2005 | + * Displays the form to register users in a blog (in a course) |
|
2006 | + * The listed users are users subcribed in the course. |
|
2007 | + * @author Toon Keppens |
|
2008 | + * |
|
2009 | + * @param Integer $blog_id |
|
2010 | + * |
|
2011 | + * @return Html Form with sortable table with users to subcribe in a blog, in a course. |
|
2012 | + */ |
|
2013 | + public static function display_form_user_subscribe($blog_id) |
|
2014 | + { |
|
2015 | + $_course = api_get_course_info(); |
|
2016 | + $is_western_name_order = api_is_western_name_order(); |
|
2017 | + $session_id = api_get_session_id(); |
|
2018 | + $course_id = $_course['real_id']; |
|
2019 | + |
|
2020 | + $currentCourse = $_course['code']; |
|
2021 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
2022 | + $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
2023 | + |
|
2024 | + echo '<legend>'.get_lang('SubscribeMembers').'</legend>'; |
|
2025 | + |
|
2026 | + $properties["width"] = "100%"; |
|
2027 | + |
|
2028 | + // Get blog members' id. |
|
2029 | + $sql = "SELECT user.user_id FROM $tbl_users user |
|
2031 | 2030 | INNER JOIN $tbl_blogs_rel_user blogs_rel_user |
2032 | 2031 | ON user.user_id = blogs_rel_user.user_id |
2033 | 2032 | WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".intval($blog_id)."'"; |
2034 | - $result = Database::query($sql); |
|
2035 | - |
|
2036 | - $blog_member_ids = array(); |
|
2037 | - while($user = Database::fetch_array($result)) { |
|
2038 | - $blog_member_ids[] = $user['user_id']; |
|
2039 | - } |
|
2040 | - |
|
2041 | - // Set table headers |
|
2042 | - $column_header[] = array ('', false, ''); |
|
2043 | - if ($is_western_name_order) { |
|
2044 | - $column_header[] = array(get_lang('FirstName'), true, ''); |
|
2045 | - $column_header[] = array(get_lang('LastName'), true, ''); |
|
2046 | - } else { |
|
2047 | - $column_header[] = array(get_lang('LastName'), true, ''); |
|
2048 | - $column_header[] = array(get_lang('FirstName'), true, ''); |
|
2049 | - } |
|
2050 | - $column_header[] = array(get_lang('Email'), false, ''); |
|
2051 | - $column_header[] = array(get_lang('Register'), false, ''); |
|
2033 | + $result = Database::query($sql); |
|
2034 | + |
|
2035 | + $blog_member_ids = array(); |
|
2036 | + while($user = Database::fetch_array($result)) { |
|
2037 | + $blog_member_ids[] = $user['user_id']; |
|
2038 | + } |
|
2039 | + |
|
2040 | + // Set table headers |
|
2041 | + $column_header[] = array ('', false, ''); |
|
2042 | + if ($is_western_name_order) { |
|
2043 | + $column_header[] = array(get_lang('FirstName'), true, ''); |
|
2044 | + $column_header[] = array(get_lang('LastName'), true, ''); |
|
2045 | + } else { |
|
2046 | + $column_header[] = array(get_lang('LastName'), true, ''); |
|
2047 | + $column_header[] = array(get_lang('FirstName'), true, ''); |
|
2048 | + } |
|
2049 | + $column_header[] = array(get_lang('Email'), false, ''); |
|
2050 | + $column_header[] = array(get_lang('Register'), false, ''); |
|
2052 | 2051 | |
2053 | 2052 | $student_list = CourseManager:: get_student_list_from_course_code( |
2054 | 2053 | $currentCourse, |
2055 | 2054 | false, |
2056 | 2055 | $session_id |
2057 | 2056 | ); |
2058 | - $user_data = array(); |
|
2059 | - |
|
2060 | - // Add users that are not in this blog to the list. |
|
2061 | - foreach ($student_list as $key=>$user) { |
|
2062 | - if(isset($user['id_user'])) { |
|
2063 | - $user['user_id'] = $user['id_user']; |
|
2064 | - } |
|
2065 | - if(!in_array($user['user_id'],$blog_member_ids)) { |
|
2066 | - $a_infosUser = api_get_user_info($user['user_id']); |
|
2067 | - $row = array (); |
|
2068 | - $row[] = '<input type="checkbox" name="user[]" value="' . $a_infosUser['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "subscribe") ? ' checked="checked" ' : '') . '/>'; |
|
2069 | - $username = api_htmlentities(sprintf(get_lang('LoginX'), $a_infosUser["username"]), ENT_QUOTES); |
|
2070 | - if ($is_western_name_order) { |
|
2071 | - $row[] = $a_infosUser["firstname"]; |
|
2072 | - $row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username)); |
|
2073 | - } else { |
|
2074 | - $row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username)); |
|
2075 | - $row[] = $a_infosUser["firstname"]; |
|
2076 | - } |
|
2077 | - $row[] = Display::icon_mailto_link($a_infosUser["email"]); |
|
2078 | - |
|
2079 | - //Link to register users |
|
2080 | - if ($a_infosUser["user_id"] != $_SESSION['_user']['user_id']){ |
|
2081 | - $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>"; |
|
2082 | - } else { |
|
2083 | - $row[] = ''; |
|
2084 | - } |
|
2085 | - $user_data[] = $row; |
|
2086 | - } |
|
2087 | - } |
|
2088 | - |
|
2089 | - // Display |
|
2090 | - $query_vars['action'] = 'manage_members'; |
|
2091 | - $query_vars['blog_id'] = $blog_id; |
|
2092 | - echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">'; |
|
2093 | - Display::display_sortable_table($column_header, $user_data,null,null,$query_vars); |
|
2094 | - $link = ''; |
|
2095 | - $link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']) . '&' : ''; |
|
2096 | - $link .= "blog_id=$blog_id&"; |
|
2097 | - |
|
2098 | - echo '<a href="blog.php?' . $link . 'selectall=subscribe">' . get_lang('SelectAll') . '</a> - '; |
|
2099 | - echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> '; |
|
2100 | - echo get_lang('WithSelected') . ' : '; |
|
2101 | - echo '<select name="action">'; |
|
2102 | - echo '<option value="select_subscribe">' . get_lang('Register') . '</option>'; |
|
2103 | - echo '</select>'; |
|
2104 | - echo '<input type="hidden" name="register" value="true" />'; |
|
2105 | - echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>'; |
|
2106 | - echo '</form>'; |
|
2107 | - } |
|
2108 | - |
|
2109 | - /** |
|
2110 | - * Displays the form to register users in a blog (in a course) |
|
2111 | - * The listed users are users subcribed in the course. |
|
2112 | - * @author Toon Keppens |
|
2113 | - * |
|
2114 | - * @param Integer $blog_id |
|
2115 | - * |
|
2116 | - * @return Html Form with sortable table with users to unsubcribe from a blog. |
|
2117 | - */ |
|
2118 | - public static function display_form_user_unsubscribe ($blog_id) |
|
2119 | - { |
|
2120 | - $_user = api_get_user_info(); |
|
2121 | - $is_western_name_order = api_is_western_name_order(); |
|
2122 | - |
|
2123 | - // Init |
|
2124 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
2125 | - $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
2126 | - |
|
2127 | - echo '<legend>'.get_lang('UnsubscribeMembers').'</legend>'; |
|
2128 | - |
|
2129 | - $properties["width"] = "100%"; |
|
2130 | - //table column titles |
|
2131 | - $column_header[] = array ('', false, ''); |
|
2132 | - if ($is_western_name_order) { |
|
2133 | - $column_header[] = array (get_lang('FirstName'), true, ''); |
|
2134 | - $column_header[] = array (get_lang('LastName'), true, ''); |
|
2135 | - } else { |
|
2136 | - $column_header[] = array (get_lang('LastName'), true, ''); |
|
2137 | - $column_header[] = array (get_lang('FirstName'), true, ''); |
|
2138 | - } |
|
2139 | - $column_header[] = array (get_lang('Email'), false, ''); |
|
2140 | - $column_header[] = array (get_lang('TaskManager'), true, ''); |
|
2141 | - $column_header[] = array (get_lang('UnRegister'), false, ''); |
|
2142 | - |
|
2143 | - $course_id = api_get_course_int_id(); |
|
2144 | - |
|
2145 | - $sql = "SELECT user.user_id, user.lastname, user.firstname, user.email, user.username |
|
2057 | + $user_data = array(); |
|
2058 | + |
|
2059 | + // Add users that are not in this blog to the list. |
|
2060 | + foreach ($student_list as $key=>$user) { |
|
2061 | + if(isset($user['id_user'])) { |
|
2062 | + $user['user_id'] = $user['id_user']; |
|
2063 | + } |
|
2064 | + if(!in_array($user['user_id'],$blog_member_ids)) { |
|
2065 | + $a_infosUser = api_get_user_info($user['user_id']); |
|
2066 | + $row = array (); |
|
2067 | + $row[] = '<input type="checkbox" name="user[]" value="' . $a_infosUser['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "subscribe") ? ' checked="checked" ' : '') . '/>'; |
|
2068 | + $username = api_htmlentities(sprintf(get_lang('LoginX'), $a_infosUser["username"]), ENT_QUOTES); |
|
2069 | + if ($is_western_name_order) { |
|
2070 | + $row[] = $a_infosUser["firstname"]; |
|
2071 | + $row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username)); |
|
2072 | + } else { |
|
2073 | + $row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username)); |
|
2074 | + $row[] = $a_infosUser["firstname"]; |
|
2075 | + } |
|
2076 | + $row[] = Display::icon_mailto_link($a_infosUser["email"]); |
|
2077 | + |
|
2078 | + //Link to register users |
|
2079 | + if ($a_infosUser["user_id"] != $_SESSION['_user']['user_id']){ |
|
2080 | + $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>"; |
|
2081 | + } else { |
|
2082 | + $row[] = ''; |
|
2083 | + } |
|
2084 | + $user_data[] = $row; |
|
2085 | + } |
|
2086 | + } |
|
2087 | + |
|
2088 | + // Display |
|
2089 | + $query_vars['action'] = 'manage_members'; |
|
2090 | + $query_vars['blog_id'] = $blog_id; |
|
2091 | + echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">'; |
|
2092 | + Display::display_sortable_table($column_header, $user_data,null,null,$query_vars); |
|
2093 | + $link = ''; |
|
2094 | + $link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']) . '&' : ''; |
|
2095 | + $link .= "blog_id=$blog_id&"; |
|
2096 | + |
|
2097 | + echo '<a href="blog.php?' . $link . 'selectall=subscribe">' . get_lang('SelectAll') . '</a> - '; |
|
2098 | + echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> '; |
|
2099 | + echo get_lang('WithSelected') . ' : '; |
|
2100 | + echo '<select name="action">'; |
|
2101 | + echo '<option value="select_subscribe">' . get_lang('Register') . '</option>'; |
|
2102 | + echo '</select>'; |
|
2103 | + echo '<input type="hidden" name="register" value="true" />'; |
|
2104 | + echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>'; |
|
2105 | + echo '</form>'; |
|
2106 | + } |
|
2107 | + |
|
2108 | + /** |
|
2109 | + * Displays the form to register users in a blog (in a course) |
|
2110 | + * The listed users are users subcribed in the course. |
|
2111 | + * @author Toon Keppens |
|
2112 | + * |
|
2113 | + * @param Integer $blog_id |
|
2114 | + * |
|
2115 | + * @return Html Form with sortable table with users to unsubcribe from a blog. |
|
2116 | + */ |
|
2117 | + public static function display_form_user_unsubscribe ($blog_id) |
|
2118 | + { |
|
2119 | + $_user = api_get_user_info(); |
|
2120 | + $is_western_name_order = api_is_western_name_order(); |
|
2121 | + |
|
2122 | + // Init |
|
2123 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
2124 | + $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
2125 | + |
|
2126 | + echo '<legend>'.get_lang('UnsubscribeMembers').'</legend>'; |
|
2127 | + |
|
2128 | + $properties["width"] = "100%"; |
|
2129 | + //table column titles |
|
2130 | + $column_header[] = array ('', false, ''); |
|
2131 | + if ($is_western_name_order) { |
|
2132 | + $column_header[] = array (get_lang('FirstName'), true, ''); |
|
2133 | + $column_header[] = array (get_lang('LastName'), true, ''); |
|
2134 | + } else { |
|
2135 | + $column_header[] = array (get_lang('LastName'), true, ''); |
|
2136 | + $column_header[] = array (get_lang('FirstName'), true, ''); |
|
2137 | + } |
|
2138 | + $column_header[] = array (get_lang('Email'), false, ''); |
|
2139 | + $column_header[] = array (get_lang('TaskManager'), true, ''); |
|
2140 | + $column_header[] = array (get_lang('UnRegister'), false, ''); |
|
2141 | + |
|
2142 | + $course_id = api_get_course_int_id(); |
|
2143 | + |
|
2144 | + $sql = "SELECT user.user_id, user.lastname, user.firstname, user.email, user.username |
|
2146 | 2145 | FROM $tbl_users user INNER JOIN $tbl_blogs_rel_user blogs_rel_user |
2147 | 2146 | ON user.user_id = blogs_rel_user.user_id |
2148 | 2147 | WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".(int)$blog_id."'"; |
2149 | 2148 | |
2150 | - if (!($sql_result = Database::query($sql))) { |
|
2151 | - return false; |
|
2152 | - } |
|
2153 | - |
|
2154 | - $user_data = array (); |
|
2155 | - |
|
2156 | - while ($myrow = Database::fetch_array($sql_result)) { |
|
2157 | - $row = array (); |
|
2158 | - $row[] = '<input type="checkbox" name="user[]" value="' . $myrow['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "unsubscribe") ? ' checked="checked" ' : '') . '/>'; |
|
2159 | - $username = api_htmlentities(sprintf(get_lang('LoginX'), $myrow["username"]), ENT_QUOTES); |
|
2160 | - if ($is_western_name_order) { |
|
2161 | - $row[] = $myrow["firstname"]; |
|
2162 | - $row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username)); |
|
2163 | - } else { |
|
2164 | - $row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username)); |
|
2165 | - $row[] = $myrow["firstname"]; |
|
2166 | - } |
|
2167 | - $row[] = Display::icon_mailto_link($myrow["email"]); |
|
2168 | - |
|
2169 | - $sql = "SELECT bt.title task |
|
2149 | + if (!($sql_result = Database::query($sql))) { |
|
2150 | + return false; |
|
2151 | + } |
|
2152 | + |
|
2153 | + $user_data = array (); |
|
2154 | + |
|
2155 | + while ($myrow = Database::fetch_array($sql_result)) { |
|
2156 | + $row = array (); |
|
2157 | + $row[] = '<input type="checkbox" name="user[]" value="' . $myrow['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "unsubscribe") ? ' checked="checked" ' : '') . '/>'; |
|
2158 | + $username = api_htmlentities(sprintf(get_lang('LoginX'), $myrow["username"]), ENT_QUOTES); |
|
2159 | + if ($is_western_name_order) { |
|
2160 | + $row[] = $myrow["firstname"]; |
|
2161 | + $row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username)); |
|
2162 | + } else { |
|
2163 | + $row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username)); |
|
2164 | + $row[] = $myrow["firstname"]; |
|
2165 | + } |
|
2166 | + $row[] = Display::icon_mailto_link($myrow["email"]); |
|
2167 | + |
|
2168 | + $sql = "SELECT bt.title task |
|
2170 | 2169 | FROM " . Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER) . " btu |
2171 | 2170 | INNER JOIN " . Database::get_course_table(TABLE_BLOGS_TASKS) . " bt |
2172 | 2171 | ON btu.task_id = bt.task_id |
@@ -2174,158 +2173,158 @@ discard block |
||
2174 | 2173 | bt.c_id = $course_id AND |
2175 | 2174 | btu.blog_id = $blog_id AND |
2176 | 2175 | btu.user_id = " . $myrow['user_id']; |
2177 | - $sql_res = Database::query($sql); |
|
2178 | - |
|
2179 | - $task = ''; |
|
2180 | - |
|
2181 | - while($r = Database::fetch_array($sql_res)) { |
|
2182 | - $task .= stripslashes($r['task']) . ', '; |
|
2183 | - } |
|
2184 | - //echo $task; |
|
2185 | - $task = (api_strlen(trim($task)) != 0) ? api_substr($task, 0, api_strlen($task) - 2) : get_lang('Reader'); |
|
2186 | - $row[] = $task; |
|
2187 | - //Link to register users |
|
2188 | - |
|
2189 | - if ($myrow["user_id"] != $_user['user_id']) { |
|
2190 | - $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>"; |
|
2191 | - } else { |
|
2192 | - $row[] = ''; |
|
2193 | - } |
|
2194 | - |
|
2195 | - $user_data[] = $row; |
|
2196 | - } |
|
2197 | - |
|
2198 | - $query_vars['action'] = 'manage_members'; |
|
2199 | - $query_vars['blog_id'] = $blog_id; |
|
2200 | - echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">'; |
|
2201 | - Display::display_sortable_table($column_header, $user_data,null,null,$query_vars); |
|
2202 | - $link = ''; |
|
2203 | - $link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']). '&' : ''; |
|
2204 | - $link .= "blog_id=$blog_id&"; |
|
2205 | - |
|
2206 | - echo '<a href="blog.php?' . $link . 'selectall=unsubscribe">' . get_lang('SelectAll') . '</a> - '; |
|
2207 | - echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> '; |
|
2208 | - echo get_lang('WithSelected') . ' : '; |
|
2209 | - echo '<select name="action">'; |
|
2210 | - echo '<option value="select_unsubscribe">' . get_lang('UnRegister') . '</option>'; |
|
2211 | - echo '</select>'; |
|
2212 | - echo '<input type="hidden" name="unregister" value="true" />'; |
|
2213 | - echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>'; |
|
2214 | - echo '</form>'; |
|
2215 | - } |
|
2216 | - |
|
2217 | - /** |
|
2218 | - * Displays a matrix with selectboxes. On the left: users, on top: possible rights. |
|
2219 | - * The blog admin can thus select what a certain user can do in the current blog |
|
2220 | - * |
|
2221 | - * @param Integer $blog_id |
|
2222 | - */ |
|
2223 | - public static function display_form_user_rights ($blog_id) |
|
2176 | + $sql_res = Database::query($sql); |
|
2177 | + |
|
2178 | + $task = ''; |
|
2179 | + |
|
2180 | + while($r = Database::fetch_array($sql_res)) { |
|
2181 | + $task .= stripslashes($r['task']) . ', '; |
|
2182 | + } |
|
2183 | + //echo $task; |
|
2184 | + $task = (api_strlen(trim($task)) != 0) ? api_substr($task, 0, api_strlen($task) - 2) : get_lang('Reader'); |
|
2185 | + $row[] = $task; |
|
2186 | + //Link to register users |
|
2187 | + |
|
2188 | + if ($myrow["user_id"] != $_user['user_id']) { |
|
2189 | + $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>"; |
|
2190 | + } else { |
|
2191 | + $row[] = ''; |
|
2192 | + } |
|
2193 | + |
|
2194 | + $user_data[] = $row; |
|
2195 | + } |
|
2196 | + |
|
2197 | + $query_vars['action'] = 'manage_members'; |
|
2198 | + $query_vars['blog_id'] = $blog_id; |
|
2199 | + echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">'; |
|
2200 | + Display::display_sortable_table($column_header, $user_data,null,null,$query_vars); |
|
2201 | + $link = ''; |
|
2202 | + $link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']). '&' : ''; |
|
2203 | + $link .= "blog_id=$blog_id&"; |
|
2204 | + |
|
2205 | + echo '<a href="blog.php?' . $link . 'selectall=unsubscribe">' . get_lang('SelectAll') . '</a> - '; |
|
2206 | + echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> '; |
|
2207 | + echo get_lang('WithSelected') . ' : '; |
|
2208 | + echo '<select name="action">'; |
|
2209 | + echo '<option value="select_unsubscribe">' . get_lang('UnRegister') . '</option>'; |
|
2210 | + echo '</select>'; |
|
2211 | + echo '<input type="hidden" name="unregister" value="true" />'; |
|
2212 | + echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>'; |
|
2213 | + echo '</form>'; |
|
2214 | + } |
|
2215 | + |
|
2216 | + /** |
|
2217 | + * Displays a matrix with selectboxes. On the left: users, on top: possible rights. |
|
2218 | + * The blog admin can thus select what a certain user can do in the current blog |
|
2219 | + * |
|
2220 | + * @param Integer $blog_id |
|
2221 | + */ |
|
2222 | + public static function display_form_user_rights ($blog_id) |
|
2223 | + { |
|
2224 | + echo '<legend>'.get_lang('RightsManager').'</legend>'; |
|
2225 | + echo '<br />'; |
|
2226 | + |
|
2227 | + // Integration of patricks permissions system. |
|
2228 | + require_once api_get_path(SYS_CODE_PATH).'permissions/blog_permissions.inc.php'; |
|
2229 | + } |
|
2230 | + |
|
2231 | + /** |
|
2232 | + * Displays the form to create a new post |
|
2233 | + * @author Toon Keppens |
|
2234 | + * |
|
2235 | + * @param Integer $blog_id |
|
2236 | + */ |
|
2237 | + public static function display_new_comment_form($blog_id, $post_id, $title) |
|
2238 | + { |
|
2239 | + $form = new FormValidator( |
|
2240 | + 'add_post', |
|
2241 | + 'post', |
|
2242 | + 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(), |
|
2243 | + null, |
|
2244 | + array('enctype' => 'multipart/form-data') |
|
2245 | + ); |
|
2246 | + |
|
2247 | + $header = get_lang('AddNewComment'); |
|
2248 | + if (isset($_GET['task_id'])) { |
|
2249 | + $header = get_lang('ExecuteThisTask'); |
|
2250 | + } |
|
2251 | + $form->addHeader($header); |
|
2252 | + $form->addText('title', get_lang('Title')); |
|
2253 | + |
|
2254 | + $config = array(); |
|
2255 | + if (!api_is_allowed_to_edit()) { |
|
2256 | + $config['ToolbarSet'] = 'ProjectComment'; |
|
2257 | + } else { |
|
2258 | + $config['ToolbarSet'] = 'ProjectCommentStudent'; |
|
2259 | + } |
|
2260 | + $form->addHtmlEditor('comment', get_lang('Comment'), false, false, $config); |
|
2261 | + $form->addFile('user_upload', get_lang('AddAnAttachment')); |
|
2262 | + |
|
2263 | + $form->addTextarea('post_file_comment', get_lang('FileComment')); |
|
2264 | + |
|
2265 | + $form->addHidden('action', null); |
|
2266 | + $form->addHidden('comment_parent_id', 0); |
|
2267 | + |
|
2268 | + if (isset($_GET['task_id'])) { |
|
2269 | + $form->addHidden('new_task_execution_submit', 'true'); |
|
2270 | + $form->addHidden('task_id', intval($_GET['task_id'])); |
|
2271 | + } else { |
|
2272 | + $form->addHidden('new_comment_submit', 'true'); |
|
2273 | + } |
|
2274 | + $form->addButton('save', get_lang('Save')); |
|
2275 | + $form->display(); |
|
2276 | + } |
|
2277 | + |
|
2278 | + |
|
2279 | + /** |
|
2280 | + * show the calender of the given month |
|
2281 | + * @author Patrick Cool |
|
2282 | + * @author Toon Keppens |
|
2283 | + * |
|
2284 | + * @param Array $blogitems an array containing all the blog items for the given month |
|
2285 | + * @param Integer $month: the integer value of the month we are viewing |
|
2286 | + * @param Integer $year: the 4-digit year indication e.g. 2005 |
|
2287 | + * @param String $monthName: the language variable for the mont name |
|
2288 | + * |
|
2289 | + * @return html code |
|
2290 | + */ |
|
2291 | + public static function display_minimonthcalendar($month, $year, $blog_id) |
|
2224 | 2292 | { |
2225 | - echo '<legend>'.get_lang('RightsManager').'</legend>'; |
|
2226 | - echo '<br />'; |
|
2227 | - |
|
2228 | - // Integration of patricks permissions system. |
|
2229 | - require_once api_get_path(SYS_CODE_PATH).'permissions/blog_permissions.inc.php'; |
|
2230 | - } |
|
2231 | - |
|
2232 | - /** |
|
2233 | - * Displays the form to create a new post |
|
2234 | - * @author Toon Keppens |
|
2235 | - * |
|
2236 | - * @param Integer $blog_id |
|
2237 | - */ |
|
2238 | - public static function display_new_comment_form($blog_id, $post_id, $title) |
|
2239 | - { |
|
2240 | - $form = new FormValidator( |
|
2241 | - 'add_post', |
|
2242 | - 'post', |
|
2243 | - 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(), |
|
2244 | - null, |
|
2245 | - array('enctype' => 'multipart/form-data') |
|
2246 | - ); |
|
2247 | - |
|
2248 | - $header = get_lang('AddNewComment'); |
|
2249 | - if (isset($_GET['task_id'])) { |
|
2250 | - $header = get_lang('ExecuteThisTask'); |
|
2251 | - } |
|
2252 | - $form->addHeader($header); |
|
2253 | - $form->addText('title', get_lang('Title')); |
|
2254 | - |
|
2255 | - $config = array(); |
|
2256 | - if (!api_is_allowed_to_edit()) { |
|
2257 | - $config['ToolbarSet'] = 'ProjectComment'; |
|
2258 | - } else { |
|
2259 | - $config['ToolbarSet'] = 'ProjectCommentStudent'; |
|
2260 | - } |
|
2261 | - $form->addHtmlEditor('comment', get_lang('Comment'), false, false, $config); |
|
2262 | - $form->addFile('user_upload', get_lang('AddAnAttachment')); |
|
2263 | - |
|
2264 | - $form->addTextarea('post_file_comment', get_lang('FileComment')); |
|
2265 | - |
|
2266 | - $form->addHidden('action', null); |
|
2267 | - $form->addHidden('comment_parent_id', 0); |
|
2268 | - |
|
2269 | - if (isset($_GET['task_id'])) { |
|
2270 | - $form->addHidden('new_task_execution_submit', 'true'); |
|
2271 | - $form->addHidden('task_id', intval($_GET['task_id'])); |
|
2272 | - } else { |
|
2273 | - $form->addHidden('new_comment_submit', 'true'); |
|
2274 | - } |
|
2275 | - $form->addButton('save', get_lang('Save')); |
|
2276 | - $form->display(); |
|
2277 | - } |
|
2278 | - |
|
2279 | - |
|
2280 | - /** |
|
2281 | - * show the calender of the given month |
|
2282 | - * @author Patrick Cool |
|
2283 | - * @author Toon Keppens |
|
2284 | - * |
|
2285 | - * @param Array $blogitems an array containing all the blog items for the given month |
|
2286 | - * @param Integer $month: the integer value of the month we are viewing |
|
2287 | - * @param Integer $year: the 4-digit year indication e.g. 2005 |
|
2288 | - * @param String $monthName: the language variable for the mont name |
|
2289 | - * |
|
2290 | - * @return html code |
|
2291 | - */ |
|
2292 | - public static function display_minimonthcalendar($month, $year, $blog_id) |
|
2293 | - { |
|
2294 | - // Init |
|
2295 | - $_user = api_get_user_info(); |
|
2296 | - global $DaysShort; |
|
2297 | - global $MonthsLong; |
|
2298 | - |
|
2299 | - $posts = array(); |
|
2300 | - $tasks = array(); |
|
2301 | - |
|
2302 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
2303 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
2304 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
2305 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
2306 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
2307 | - |
|
2308 | - $course_id = api_get_course_int_id(); |
|
2309 | - |
|
2310 | - //Handle leap year |
|
2311 | - $numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); |
|
2312 | - |
|
2313 | - if(($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0)) |
|
2314 | - $numberofdays[2] = 29; |
|
2315 | - |
|
2316 | - //Get the first day of the month |
|
2317 | - $dayone = getdate(mktime(0, 0, 0, $month, 1, $year)); |
|
2318 | - $monthName = $MonthsLong[$month-1]; |
|
2319 | - |
|
2320 | - //Start the week on monday |
|
2321 | - $startdayofweek = $dayone['wday'] <> 0 ? ($dayone['wday'] - 1) : 6; |
|
2322 | - $blogId = isset($_GET['blog_id']) ? intval($_GET['blog_id']) : null; |
|
2323 | - $filter = isset($_GET['filter']) ? Security::remove_XSS($_GET['filter']) : null; |
|
2324 | - $backwardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 1 ? 12 : $month -1)."&year=". ($month == 1 ? $year -1 : $year); |
|
2325 | - $forewardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 12 ? 1 : $month +1)."&year=". ($month == 12 ? $year +1 : $year); |
|
2326 | - |
|
2327 | - // Get posts for this month |
|
2328 | - $sql = "SELECT post.*, DAYOFMONTH(date_creation) as post_day, user.lastname, user.firstname |
|
2293 | + // Init |
|
2294 | + $_user = api_get_user_info(); |
|
2295 | + global $DaysShort; |
|
2296 | + global $MonthsLong; |
|
2297 | + |
|
2298 | + $posts = array(); |
|
2299 | + $tasks = array(); |
|
2300 | + |
|
2301 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
2302 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
2303 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
2304 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
2305 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
2306 | + |
|
2307 | + $course_id = api_get_course_int_id(); |
|
2308 | + |
|
2309 | + //Handle leap year |
|
2310 | + $numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); |
|
2311 | + |
|
2312 | + if(($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0)) |
|
2313 | + $numberofdays[2] = 29; |
|
2314 | + |
|
2315 | + //Get the first day of the month |
|
2316 | + $dayone = getdate(mktime(0, 0, 0, $month, 1, $year)); |
|
2317 | + $monthName = $MonthsLong[$month-1]; |
|
2318 | + |
|
2319 | + //Start the week on monday |
|
2320 | + $startdayofweek = $dayone['wday'] <> 0 ? ($dayone['wday'] - 1) : 6; |
|
2321 | + $blogId = isset($_GET['blog_id']) ? intval($_GET['blog_id']) : null; |
|
2322 | + $filter = isset($_GET['filter']) ? Security::remove_XSS($_GET['filter']) : null; |
|
2323 | + $backwardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 1 ? 12 : $month -1)."&year=". ($month == 1 ? $year -1 : $year); |
|
2324 | + $forewardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 12 ? 1 : $month +1)."&year=". ($month == 12 ? $year +1 : $year); |
|
2325 | + |
|
2326 | + // Get posts for this month |
|
2327 | + $sql = "SELECT post.*, DAYOFMONTH(date_creation) as post_day, user.lastname, user.firstname |
|
2329 | 2328 | FROM $tbl_blogs_posts post |
2330 | 2329 | INNER JOIN $tbl_users user |
2331 | 2330 | ON post.author_id = user.user_id |
@@ -2335,20 +2334,20 @@ discard block |
||
2335 | 2334 | MONTH(date_creation) = '".(int)$month."' AND |
2336 | 2335 | YEAR(date_creation) = '".(int)$year."' |
2337 | 2336 | ORDER BY date_creation"; |
2338 | - $result = Database::query($sql); |
|
2339 | - |
|
2340 | - // We will create an array of days on which there are posts. |
|
2341 | - if( Database::num_rows($result) > 0) { |
|
2342 | - while($blog_post = Database::fetch_array($result)) { |
|
2343 | - // If the day of this post is not yet in the array, add it. |
|
2344 | - if (!in_array($blog_post['post_day'], $posts)) |
|
2345 | - $posts[] = $blog_post['post_day']; |
|
2346 | - } |
|
2347 | - } |
|
2348 | - |
|
2349 | - // Get tasks for this month |
|
2350 | - if ($_user['user_id']) { |
|
2351 | - $sql = " SELECT task_rel_user.*, DAYOFMONTH(target_date) as task_day, task.title, blog.blog_name |
|
2337 | + $result = Database::query($sql); |
|
2338 | + |
|
2339 | + // We will create an array of days on which there are posts. |
|
2340 | + if( Database::num_rows($result) > 0) { |
|
2341 | + while($blog_post = Database::fetch_array($result)) { |
|
2342 | + // If the day of this post is not yet in the array, add it. |
|
2343 | + if (!in_array($blog_post['post_day'], $posts)) |
|
2344 | + $posts[] = $blog_post['post_day']; |
|
2345 | + } |
|
2346 | + } |
|
2347 | + |
|
2348 | + // Get tasks for this month |
|
2349 | + if ($_user['user_id']) { |
|
2350 | + $sql = " SELECT task_rel_user.*, DAYOFMONTH(target_date) as task_day, task.title, blog.blog_name |
|
2352 | 2351 | FROM $tbl_blogs_tasks_rel_user task_rel_user |
2353 | 2352 | INNER JOIN $tbl_blogs_tasks task ON task_rel_user.task_id = task.task_id |
2354 | 2353 | INNER JOIN $tbl_blogs blog ON task_rel_user.blog_id = blog.blog_id |
@@ -2360,84 +2359,84 @@ discard block |
||
2360 | 2359 | MONTH(target_date) = '".(int)$month."' AND |
2361 | 2360 | YEAR(target_date) = '".(int)$year."' |
2362 | 2361 | ORDER BY target_date ASC"; |
2363 | - $result = Database::query($sql); |
|
2364 | - |
|
2365 | - if (Database::num_rows($result) > 0) { |
|
2366 | - while ($mytask = Database::fetch_array($result)) { |
|
2367 | - $tasks[$mytask['task_day']][$mytask['task_id']]['task_id'] = $mytask['task_id']; |
|
2368 | - $tasks[$mytask['task_day']][$mytask['task_id']]['title'] = $mytask['title']; |
|
2369 | - $tasks[$mytask['task_day']][$mytask['task_id']]['blog_id'] = $mytask['blog_id']; |
|
2370 | - $tasks[$mytask['task_day']][$mytask['task_id']]['blog_name'] = $mytask['blog_name']; |
|
2371 | - $tasks[$mytask['task_day']][$mytask['task_id']]['day'] = $mytask['task_day']; |
|
2372 | - } |
|
2373 | - } |
|
2374 | - } |
|
2375 | - |
|
2376 | - echo '<table id="smallcalendar" class="table table-responsive">', |
|
2377 | - "<tr id=\"title\">\n", |
|
2378 | - "<th width=\"10%\"><a href=\"", $backwardsURL, "\">«</a></th>\n", |
|
2379 | - "<th align=\"center\" width=\"80%\" colspan=\"5\">", $monthName, " ", $year, "</th>\n", |
|
2380 | - "<th width=\"10%\" align=\"right\"><a href=\"", $forewardsURL, "\">»</a></th>\n", "</tr>"; |
|
2381 | - |
|
2382 | - echo "<tr>\n"; |
|
2383 | - |
|
2384 | - for($ii = 1; $ii < 8; $ii ++) |
|
2385 | - echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>"; |
|
2386 | - |
|
2387 | - echo "</tr>"; |
|
2388 | - |
|
2389 | - $curday = -1; |
|
2390 | - $today = getdate(); |
|
2391 | - |
|
2392 | - while ($curday <= $numberofdays[$month]) { |
|
2393 | - echo "<tr>"; |
|
2394 | - for ($ii = 0; $ii < 7; $ii ++) { |
|
2395 | - if (($curday == -1) && ($ii == $startdayofweek)) |
|
2396 | - $curday = 1; |
|
2397 | - |
|
2398 | - if (($curday > 0) && ($curday <= $numberofdays[$month])) { |
|
2399 | - $bgcolor = $ii < 5 ? $class="class=\"days_week\"" : $class="class=\"days_weekend\""; |
|
2400 | - $dayheader = "$curday"; |
|
2401 | - |
|
2402 | - if(($curday == $today['mday']) && ($year == $today['year']) && ($month == $today['mon'])) { |
|
2403 | - $dayheader = "$curday"; |
|
2404 | - $class = "class=\"days_today\""; |
|
2405 | - } |
|
2406 | - |
|
2407 | - echo "<td " . $class.">"; |
|
2408 | - |
|
2409 | - // If there are posts on this day, create a filter link. |
|
2410 | - if(in_array($curday, $posts)) |
|
2411 | - echo '<a href="blog.php?blog_id=' . $blog_id . '&filter=' . $year . '-' . $month . '-' . $curday . '&month=' . $month . '&year=' . $year . '" title="' . get_lang('ViewPostsOfThisDay') . '">' . $curday . '</a>'; |
|
2412 | - else |
|
2413 | - echo $dayheader; |
|
2414 | - |
|
2415 | - if (count($tasks) > 0) { |
|
2416 | - if (isset($tasks[$curday]) && is_array($tasks[$curday])) { |
|
2417 | - // Add tasks to calendar |
|
2418 | - foreach ($tasks[$curday] as $task) { |
|
2419 | - 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') . '"> |
|
2362 | + $result = Database::query($sql); |
|
2363 | + |
|
2364 | + if (Database::num_rows($result) > 0) { |
|
2365 | + while ($mytask = Database::fetch_array($result)) { |
|
2366 | + $tasks[$mytask['task_day']][$mytask['task_id']]['task_id'] = $mytask['task_id']; |
|
2367 | + $tasks[$mytask['task_day']][$mytask['task_id']]['title'] = $mytask['title']; |
|
2368 | + $tasks[$mytask['task_day']][$mytask['task_id']]['blog_id'] = $mytask['blog_id']; |
|
2369 | + $tasks[$mytask['task_day']][$mytask['task_id']]['blog_name'] = $mytask['blog_name']; |
|
2370 | + $tasks[$mytask['task_day']][$mytask['task_id']]['day'] = $mytask['task_day']; |
|
2371 | + } |
|
2372 | + } |
|
2373 | + } |
|
2374 | + |
|
2375 | + echo '<table id="smallcalendar" class="table table-responsive">', |
|
2376 | + "<tr id=\"title\">\n", |
|
2377 | + "<th width=\"10%\"><a href=\"", $backwardsURL, "\">«</a></th>\n", |
|
2378 | + "<th align=\"center\" width=\"80%\" colspan=\"5\">", $monthName, " ", $year, "</th>\n", |
|
2379 | + "<th width=\"10%\" align=\"right\"><a href=\"", $forewardsURL, "\">»</a></th>\n", "</tr>"; |
|
2380 | + |
|
2381 | + echo "<tr>\n"; |
|
2382 | + |
|
2383 | + for($ii = 1; $ii < 8; $ii ++) |
|
2384 | + echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>"; |
|
2385 | + |
|
2386 | + echo "</tr>"; |
|
2387 | + |
|
2388 | + $curday = -1; |
|
2389 | + $today = getdate(); |
|
2390 | + |
|
2391 | + while ($curday <= $numberofdays[$month]) { |
|
2392 | + echo "<tr>"; |
|
2393 | + for ($ii = 0; $ii < 7; $ii ++) { |
|
2394 | + if (($curday == -1) && ($ii == $startdayofweek)) |
|
2395 | + $curday = 1; |
|
2396 | + |
|
2397 | + if (($curday > 0) && ($curday <= $numberofdays[$month])) { |
|
2398 | + $bgcolor = $ii < 5 ? $class="class=\"days_week\"" : $class="class=\"days_weekend\""; |
|
2399 | + $dayheader = "$curday"; |
|
2400 | + |
|
2401 | + if(($curday == $today['mday']) && ($year == $today['year']) && ($month == $today['mon'])) { |
|
2402 | + $dayheader = "$curday"; |
|
2403 | + $class = "class=\"days_today\""; |
|
2404 | + } |
|
2405 | + |
|
2406 | + echo "<td " . $class.">"; |
|
2407 | + |
|
2408 | + // If there are posts on this day, create a filter link. |
|
2409 | + if(in_array($curday, $posts)) |
|
2410 | + echo '<a href="blog.php?blog_id=' . $blog_id . '&filter=' . $year . '-' . $month . '-' . $curday . '&month=' . $month . '&year=' . $year . '" title="' . get_lang('ViewPostsOfThisDay') . '">' . $curday . '</a>'; |
|
2411 | + else |
|
2412 | + echo $dayheader; |
|
2413 | + |
|
2414 | + if (count($tasks) > 0) { |
|
2415 | + if (isset($tasks[$curday]) && is_array($tasks[$curday])) { |
|
2416 | + // Add tasks to calendar |
|
2417 | + foreach ($tasks[$curday] as $task) { |
|
2418 | + 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') . '"> |
|
2420 | 2419 | <img src="../img/blog_task.gif" alt="Task" title="' . get_lang('ExecuteThisTask') . '" /></a>'; |
2421 | - } |
|
2422 | - } |
|
2423 | - } |
|
2424 | - |
|
2425 | - echo "</td>"; |
|
2426 | - $curday ++; |
|
2427 | - } else |
|
2428 | - echo "<td> </td>"; |
|
2429 | - } |
|
2430 | - echo "</tr>"; |
|
2431 | - } |
|
2432 | - echo "</table>"; |
|
2433 | - } |
|
2434 | - |
|
2435 | - /** |
|
2436 | - * Blog admin | Display the form to add a new blog. |
|
2437 | - * |
|
2438 | - */ |
|
2439 | - public static function display_new_blog_form() |
|
2440 | - { |
|
2420 | + } |
|
2421 | + } |
|
2422 | + } |
|
2423 | + |
|
2424 | + echo "</td>"; |
|
2425 | + $curday ++; |
|
2426 | + } else |
|
2427 | + echo "<td> </td>"; |
|
2428 | + } |
|
2429 | + echo "</tr>"; |
|
2430 | + } |
|
2431 | + echo "</table>"; |
|
2432 | + } |
|
2433 | + |
|
2434 | + /** |
|
2435 | + * Blog admin | Display the form to add a new blog. |
|
2436 | + * |
|
2437 | + */ |
|
2438 | + public static function display_new_blog_form() |
|
2439 | + { |
|
2441 | 2440 | $form = new FormValidator('add_blog', 'post', 'blog_admin.php?action=add'); |
2442 | 2441 | $form->addElement('header', get_lang('AddBlog')); |
2443 | 2442 | $form->addElement('text', 'blog_name', get_lang('Title')); |
@@ -2447,34 +2446,34 @@ discard block |
||
2447 | 2446 | $form->addButtonSave(get_lang('SaveProject')); |
2448 | 2447 | |
2449 | 2448 | $defaults = array( |
2450 | - 'blog_name' => isset($_POST['blog_name']) ? Security::remove_XSS($_POST['blog_name']) : null, |
|
2451 | - 'blog_subtitle' => isset($_POST['blog_subtitle']) ? Security::remove_XSS($_POST['blog_subtitle']) : null |
|
2452 | - ); |
|
2449 | + 'blog_name' => isset($_POST['blog_name']) ? Security::remove_XSS($_POST['blog_name']) : null, |
|
2450 | + 'blog_subtitle' => isset($_POST['blog_subtitle']) ? Security::remove_XSS($_POST['blog_subtitle']) : null |
|
2451 | + ); |
|
2453 | 2452 | $form->setDefaults($defaults); |
2454 | 2453 | $form->display(); |
2455 | - } |
|
2456 | - |
|
2457 | - /** |
|
2458 | - * Blog admin | Display the form to edit a blog. |
|
2459 | - * |
|
2460 | - */ |
|
2461 | - public static function display_edit_blog_form($blog_id) |
|
2462 | - { |
|
2463 | - $course_id = api_get_course_int_id(); |
|
2464 | - $blog_id= intval($blog_id); |
|
2465 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
2466 | - |
|
2467 | - $sql = "SELECT blog_id, blog_name, blog_subtitle |
|
2454 | + } |
|
2455 | + |
|
2456 | + /** |
|
2457 | + * Blog admin | Display the form to edit a blog. |
|
2458 | + * |
|
2459 | + */ |
|
2460 | + public static function display_edit_blog_form($blog_id) |
|
2461 | + { |
|
2462 | + $course_id = api_get_course_int_id(); |
|
2463 | + $blog_id= intval($blog_id); |
|
2464 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
2465 | + |
|
2466 | + $sql = "SELECT blog_id, blog_name, blog_subtitle |
|
2468 | 2467 | FROM $tbl_blogs |
2469 | 2468 | WHERE c_id = $course_id AND blog_id = '".$blog_id."'"; |
2470 | - $result = Database::query($sql); |
|
2471 | - $blog = Database::fetch_array($result); |
|
2469 | + $result = Database::query($sql); |
|
2470 | + $blog = Database::fetch_array($result); |
|
2472 | 2471 | |
2473 | - // the form contained errors but we do not want to lose the changes the user already did |
|
2474 | - if ($_POST) { |
|
2475 | - $blog['blog_name'] = Security::remove_XSS($_POST['blog_name']); |
|
2476 | - $blog['blog_subtitle'] = Security::remove_XSS($_POST['blog_subtitle']); |
|
2477 | - } |
|
2472 | + // the form contained errors but we do not want to lose the changes the user already did |
|
2473 | + if ($_POST) { |
|
2474 | + $blog['blog_name'] = Security::remove_XSS($_POST['blog_name']); |
|
2475 | + $blog['blog_subtitle'] = Security::remove_XSS($_POST['blog_subtitle']); |
|
2476 | + } |
|
2478 | 2477 | |
2479 | 2478 | $form = new FormValidator('edit_blog', 'post','blog_admin.php?action=edit&blog_id='.intval($_GET['blog_id'])); |
2480 | 2479 | $form->addElement('header', get_lang('EditBlog')); |
@@ -2490,82 +2489,82 @@ discard block |
||
2490 | 2489 | $defaults['blog_subtitle'] = $blog['blog_subtitle']; |
2491 | 2490 | $form->setDefaults($defaults); |
2492 | 2491 | $form->display(); |
2493 | - } |
|
2492 | + } |
|
2494 | 2493 | |
2495 | - /** |
|
2496 | - * Blog admin | Returns table with blogs in this course |
|
2497 | - */ |
|
2498 | - public static function display_blog_list() |
|
2494 | + /** |
|
2495 | + * Blog admin | Returns table with blogs in this course |
|
2496 | + */ |
|
2497 | + public static function display_blog_list() |
|
2499 | 2498 | { |
2500 | - global $charset; |
|
2501 | - $_user = api_get_user_info(); |
|
2499 | + global $charset; |
|
2500 | + $_user = api_get_user_info(); |
|
2502 | 2501 | $course_id = api_get_course_int_id(); |
2503 | 2502 | |
2504 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
2503 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
2505 | 2504 | |
2506 | - //condition for the session |
|
2507 | - $session_id = api_get_session_id(); |
|
2508 | - $condition_session = api_get_session_condition($session_id, false); |
|
2505 | + //condition for the session |
|
2506 | + $session_id = api_get_session_id(); |
|
2507 | + $condition_session = api_get_session_condition($session_id, false); |
|
2509 | 2508 | |
2510 | - $sql = "SELECT blog_name, blog_subtitle, visibility, blog_id, session_id |
|
2509 | + $sql = "SELECT blog_name, blog_subtitle, visibility, blog_id, session_id |
|
2511 | 2510 | FROM $tbl_blogs WHERE c_id = $course_id |
2512 | 2511 | ORDER BY date_creation DESC"; |
2513 | - $result = Database::query($sql); |
|
2514 | - $list_info = array(); |
|
2515 | - if (Database::num_rows($result)) { |
|
2516 | - while ($row_project=Database::fetch_row($result)) { |
|
2517 | - $list_info[]=$row_project; |
|
2518 | - } |
|
2519 | - } |
|
2520 | - |
|
2521 | - $list_content_blog = array(); |
|
2522 | - $list_body_blog = array(); |
|
2523 | - |
|
2524 | - if (is_array($list_info)) { |
|
2525 | - foreach ($list_info as $key => $info_log) { |
|
2526 | - // Validation when belongs to a session |
|
2527 | - $session_img = api_get_session_image($info_log[4], $_user['status']); |
|
2528 | - |
|
2529 | - $url_start_blog = 'blog.php' ."?". "blog_id=".$info_log[3]. "&".api_get_cidreq(); |
|
2530 | - $title = $info_log[0]; |
|
2512 | + $result = Database::query($sql); |
|
2513 | + $list_info = array(); |
|
2514 | + if (Database::num_rows($result)) { |
|
2515 | + while ($row_project=Database::fetch_row($result)) { |
|
2516 | + $list_info[]=$row_project; |
|
2517 | + } |
|
2518 | + } |
|
2519 | + |
|
2520 | + $list_content_blog = array(); |
|
2521 | + $list_body_blog = array(); |
|
2522 | + |
|
2523 | + if (is_array($list_info)) { |
|
2524 | + foreach ($list_info as $key => $info_log) { |
|
2525 | + // Validation when belongs to a session |
|
2526 | + $session_img = api_get_session_image($info_log[4], $_user['status']); |
|
2527 | + |
|
2528 | + $url_start_blog = 'blog.php' ."?". "blog_id=".$info_log[3]. "&".api_get_cidreq(); |
|
2529 | + $title = $info_log[0]; |
|
2531 | 2530 | $image = Display::return_icon('blog.png', $title); |
2532 | - $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; |
|
2531 | + $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; |
|
2533 | 2532 | |
2534 | - $list_body_blog[] = $list_name; |
|
2535 | - $list_body_blog[] = $info_log[1]; |
|
2533 | + $list_body_blog[] = $list_name; |
|
2534 | + $list_body_blog[] = $info_log[1]; |
|
2536 | 2535 | |
2537 | - $visibility_icon=($info_log[2]==0) ? 'invisible' : 'visible'; |
|
2538 | - $visibility_info=($info_log[2]==0) ? 'Visible' : 'Invisible'; |
|
2539 | - $my_image = '<a href="' .api_get_self(). '?action=edit&blog_id=' . $info_log[3] . '">'; |
|
2536 | + $visibility_icon=($info_log[2]==0) ? 'invisible' : 'visible'; |
|
2537 | + $visibility_info=($info_log[2]==0) ? 'Visible' : 'Invisible'; |
|
2538 | + $my_image = '<a href="' .api_get_self(). '?action=edit&blog_id=' . $info_log[3] . '">'; |
|
2540 | 2539 | $my_image.= Display::return_icon('edit.png', get_lang('EditBlog')); |
2541 | 2540 | |
2542 | - $my_image.= "</a>\n"; |
|
2543 | - $my_image.= '<a href="' .api_get_self(). '?action=delete&blog_id=' . $info_log[3] . '" '; |
|
2544 | - $my_image.= 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;" >'; |
|
2541 | + $my_image.= "</a>\n"; |
|
2542 | + $my_image.= '<a href="' .api_get_self(). '?action=delete&blog_id=' . $info_log[3] . '" '; |
|
2543 | + $my_image.= 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;" >'; |
|
2545 | 2544 | $my_image.= Display::return_icon('delete.png', get_lang('DeleteBlog')); |
2546 | 2545 | |
2547 | - $my_image.= "</a>\n"; |
|
2548 | - $my_image.= '<a href="' .api_get_self(). '?action=visibility&blog_id=' . $info_log[3] . '">'; |
|
2546 | + $my_image.= "</a>\n"; |
|
2547 | + $my_image.= '<a href="' .api_get_self(). '?action=visibility&blog_id=' . $info_log[3] . '">'; |
|
2549 | 2548 | $my_image.= Display::return_icon($visibility_icon . '.gif', get_lang($visibility_info)); |
2550 | 2549 | |
2551 | - $my_image.= "</a>\n"; |
|
2550 | + $my_image.= "</a>\n"; |
|
2552 | 2551 | |
2553 | - $list_body_blog[]=$my_image; |
|
2552 | + $list_body_blog[]=$my_image; |
|
2554 | 2553 | |
2555 | - $list_content_blog[]=$list_body_blog; |
|
2556 | - $list_body_blog = array(); |
|
2554 | + $list_content_blog[]=$list_body_blog; |
|
2555 | + $list_body_blog = array(); |
|
2557 | 2556 | |
2558 | - } |
|
2559 | - $parameters=''; |
|
2560 | - //$parameters=array('action'=>Security::remove_XSS($_GET['action'])); |
|
2561 | - $table = new SortableTableFromArrayConfig($list_content_blog, 1,20,'project'); |
|
2562 | - //$table->set_additional_parameters($parameters); |
|
2563 | - $table->set_header(0, get_lang('Title')); |
|
2564 | - $table->set_header(1, get_lang('SubTitle')); |
|
2565 | - $table->set_header(2, get_lang('Modify')); |
|
2566 | - $table->display(); |
|
2567 | - } |
|
2568 | - } |
|
2557 | + } |
|
2558 | + $parameters=''; |
|
2559 | + //$parameters=array('action'=>Security::remove_XSS($_GET['action'])); |
|
2560 | + $table = new SortableTableFromArrayConfig($list_content_blog, 1,20,'project'); |
|
2561 | + //$table->set_additional_parameters($parameters); |
|
2562 | + $table->set_header(0, get_lang('Title')); |
|
2563 | + $table->set_header(1, get_lang('SubTitle')); |
|
2564 | + $table->set_header(2, get_lang('Modify')); |
|
2565 | + $table->display(); |
|
2566 | + } |
|
2567 | + } |
|
2569 | 2568 | } |
2570 | 2569 | |
2571 | 2570 | /** |
@@ -2585,34 +2584,34 @@ discard block |
||
2585 | 2584 | */ |
2586 | 2585 | function get_blog_attachment($blog_id, $post_id=null,$comment_id=null) |
2587 | 2586 | { |
2588 | - $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
2589 | - |
|
2590 | - $blog_id = intval($blog_id); |
|
2591 | - $comment_id = intval($comment_id); |
|
2592 | - $post_id = intval($post_id); |
|
2593 | - $row=array(); |
|
2594 | - $where=''; |
|
2595 | - if (!empty ($post_id) && is_numeric($post_id)) { |
|
2596 | - $where.=' AND post_id ="'.$post_id.'" '; |
|
2597 | - } |
|
2598 | - |
|
2599 | - if (!empty ($comment_id) && is_numeric($comment_id)) { |
|
2600 | - if (!empty ($post_id)) { |
|
2601 | - $where.= ' AND '; |
|
2602 | - } |
|
2603 | - $where.=' comment_id ="'.$comment_id.'" '; |
|
2604 | - } |
|
2587 | + $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
2588 | + |
|
2589 | + $blog_id = intval($blog_id); |
|
2590 | + $comment_id = intval($comment_id); |
|
2591 | + $post_id = intval($post_id); |
|
2592 | + $row=array(); |
|
2593 | + $where=''; |
|
2594 | + if (!empty ($post_id) && is_numeric($post_id)) { |
|
2595 | + $where.=' AND post_id ="'.$post_id.'" '; |
|
2596 | + } |
|
2597 | + |
|
2598 | + if (!empty ($comment_id) && is_numeric($comment_id)) { |
|
2599 | + if (!empty ($post_id)) { |
|
2600 | + $where.= ' AND '; |
|
2601 | + } |
|
2602 | + $where.=' comment_id ="'.$comment_id.'" '; |
|
2603 | + } |
|
2605 | 2604 | |
2606 | 2605 | $course_id = api_get_course_int_id(); |
2607 | 2606 | |
2608 | - $sql = 'SELECT path, filename, comment FROM '. $blog_table_attachment.' |
|
2607 | + $sql = 'SELECT path, filename, comment FROM '. $blog_table_attachment.' |
|
2609 | 2608 | WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; |
2610 | 2609 | |
2611 | - $result=Database::query($sql); |
|
2612 | - if (Database::num_rows($result)!=0) { |
|
2613 | - $row=Database::fetch_array($result); |
|
2614 | - } |
|
2615 | - return $row; |
|
2610 | + $result=Database::query($sql); |
|
2611 | + if (Database::num_rows($result)!=0) { |
|
2612 | + $row=Database::fetch_array($result); |
|
2613 | + } |
|
2614 | + return $row; |
|
2616 | 2615 | } |
2617 | 2616 | |
2618 | 2617 | /** |
@@ -2626,16 +2625,16 @@ discard block |
||
2626 | 2625 | |
2627 | 2626 | function delete_all_blog_attachment($blog_id,$post_id=null,$comment_id=null) |
2628 | 2627 | { |
2629 | - $_course = api_get_course_info(); |
|
2630 | - $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
2631 | - $blog_id = intval($blog_id); |
|
2632 | - $comment_id = intval($comment_id); |
|
2633 | - $post_id = intval($post_id); |
|
2628 | + $_course = api_get_course_info(); |
|
2629 | + $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
2630 | + $blog_id = intval($blog_id); |
|
2631 | + $comment_id = intval($comment_id); |
|
2632 | + $post_id = intval($post_id); |
|
2634 | 2633 | |
2635 | 2634 | $course_id = api_get_course_int_id(); |
2636 | - $where = null; |
|
2635 | + $where = null; |
|
2637 | 2636 | |
2638 | - // delete files in DB |
|
2637 | + // delete files in DB |
|
2639 | 2638 | if (!empty ($post_id) && is_numeric($post_id)) { |
2640 | 2639 | $where .= ' AND post_id ="'.$post_id.'" '; |
2641 | 2640 | } |
@@ -2647,25 +2646,25 @@ discard block |
||
2647 | 2646 | $where .= ' comment_id ="'.$comment_id.'" '; |
2648 | 2647 | } |
2649 | 2648 | |
2650 | - // delete all files in directory |
|
2651 | - $courseDir = $_course['path'].'/upload/blog'; |
|
2652 | - $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
2653 | - $updir = $sys_course_path.$courseDir; |
|
2649 | + // delete all files in directory |
|
2650 | + $courseDir = $_course['path'].'/upload/blog'; |
|
2651 | + $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
2652 | + $updir = $sys_course_path.$courseDir; |
|
2654 | 2653 | |
2655 | - $sql = 'SELECT path FROM '.$blog_table_attachment.' |
|
2654 | + $sql = 'SELECT path FROM '.$blog_table_attachment.' |
|
2656 | 2655 | WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; |
2657 | - $result=Database::query($sql); |
|
2658 | - |
|
2659 | - while ($row=Database::fetch_row($result)) { |
|
2660 | - $file=$updir.'/'.$row[0]; |
|
2661 | - if (Security::check_abs_path($file,$updir) ) |
|
2662 | - { |
|
2663 | - @ unlink($file); |
|
2664 | - } |
|
2665 | - } |
|
2666 | - $sql = 'DELETE FROM '. $blog_table_attachment.' |
|
2656 | + $result=Database::query($sql); |
|
2657 | + |
|
2658 | + while ($row=Database::fetch_row($result)) { |
|
2659 | + $file=$updir.'/'.$row[0]; |
|
2660 | + if (Security::check_abs_path($file,$updir) ) |
|
2661 | + { |
|
2662 | + @ unlink($file); |
|
2663 | + } |
|
2664 | + } |
|
2665 | + $sql = 'DELETE FROM '. $blog_table_attachment.' |
|
2667 | 2666 | WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; |
2668 | - Database::query($sql); |
|
2667 | + Database::query($sql); |
|
2669 | 2668 | } |
2670 | 2669 | |
2671 | 2670 | /** |
@@ -2675,12 +2674,12 @@ discard block |
||
2675 | 2674 | */ |
2676 | 2675 | function get_blog_post_from_user($course_code, $user_id) |
2677 | 2676 | { |
2678 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
2679 | - $tbl_blog_post = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
2680 | - $course_info = api_get_course_info($course_code); |
|
2681 | - $course_id = $course_info['real_id']; |
|
2677 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
2678 | + $tbl_blog_post = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
2679 | + $course_info = api_get_course_info($course_code); |
|
2680 | + $course_id = $course_info['real_id']; |
|
2682 | 2681 | |
2683 | - $sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation |
|
2682 | + $sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation |
|
2684 | 2683 | FROM $tbl_blogs blog |
2685 | 2684 | INNER JOIN $tbl_blog_post post |
2686 | 2685 | ON (blog.blog_id = post.blog_id) |
@@ -2689,19 +2688,19 @@ discard block |
||
2689 | 2688 | post.c_id = $course_id AND |
2690 | 2689 | author_id = $user_id AND visibility = 1 |
2691 | 2690 | ORDER BY post.date_creation DESC "; |
2692 | - $result = Database::query($sql); |
|
2693 | - $return_data = ''; |
|
2694 | - |
|
2695 | - if (Database::num_rows($result)!=0) { |
|
2696 | - while ($row=Database::fetch_array($result)) { |
|
2697 | - $return_data.= '<div class="clear"></div><br />'; |
|
2698 | - $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>'; |
|
2699 | - $return_data.= '<br / >'; |
|
2700 | - $return_data.= $row['full_text']; |
|
2701 | - $return_data.= '<br /><br />'; |
|
2702 | - } |
|
2703 | - } |
|
2704 | - return $return_data; |
|
2691 | + $result = Database::query($sql); |
|
2692 | + $return_data = ''; |
|
2693 | + |
|
2694 | + if (Database::num_rows($result)!=0) { |
|
2695 | + while ($row=Database::fetch_array($result)) { |
|
2696 | + $return_data.= '<div class="clear"></div><br />'; |
|
2697 | + $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>'; |
|
2698 | + $return_data.= '<br / >'; |
|
2699 | + $return_data.= $row['full_text']; |
|
2700 | + $return_data.= '<br /><br />'; |
|
2701 | + } |
|
2702 | + } |
|
2703 | + return $return_data; |
|
2705 | 2704 | } |
2706 | 2705 | |
2707 | 2706 | /** |
@@ -2718,7 +2717,7 @@ discard block |
||
2718 | 2717 | $course_info = api_get_course_info($course_code); |
2719 | 2718 | $course_id = $course_info['real_id']; |
2720 | 2719 | |
2721 | - $sql = "SELECT DISTINCT blog.blog_id, comment_id, title, comment, comment.date_creation |
|
2720 | + $sql = "SELECT DISTINCT blog.blog_id, comment_id, title, comment, comment.date_creation |
|
2722 | 2721 | FROM $tbl_blogs blog INNER JOIN $tbl_blog_comment comment |
2723 | 2722 | ON (blog.blog_id = comment.blog_id) |
2724 | 2723 | WHERE blog.c_id = $course_id AND |
@@ -2726,18 +2725,18 @@ discard block |
||
2726 | 2725 | author_id = $user_id AND |
2727 | 2726 | visibility = 1 |
2728 | 2727 | ORDER BY blog_name"; |
2729 | - $result = Database::query($sql); |
|
2730 | - $return_data = ''; |
|
2731 | - if (Database::num_rows($result)!=0) { |
|
2732 | - while ($row=Database::fetch_array($result)) { |
|
2733 | - $return_data.= '<div class="clear"></div><br />'; |
|
2734 | - $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>'; |
|
2735 | - $return_data.= '<br / >'; |
|
2736 | - //$return_data.= '<strong>'.$row['title'].'</strong>'; echo '<br>';*/ |
|
2737 | - $return_data.= $row['comment']; |
|
2738 | - $return_data.= '<br />'; |
|
2739 | - } |
|
2740 | - } |
|
2741 | - return $return_data; |
|
2728 | + $result = Database::query($sql); |
|
2729 | + $return_data = ''; |
|
2730 | + if (Database::num_rows($result)!=0) { |
|
2731 | + while ($row=Database::fetch_array($result)) { |
|
2732 | + $return_data.= '<div class="clear"></div><br />'; |
|
2733 | + $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>'; |
|
2734 | + $return_data.= '<br / >'; |
|
2735 | + //$return_data.= '<strong>'.$row['title'].'</strong>'; echo '<br>';*/ |
|
2736 | + $return_data.= $row['comment']; |
|
2737 | + $return_data.= '<br />'; |
|
2738 | + } |
|
2739 | + } |
|
2740 | + return $return_data; |
|
2742 | 2741 | } |
2743 | 2742 |
@@ -591,13 +591,13 @@ |
||
591 | 591 | |
592 | 592 | } |
593 | 593 | |
594 | - /** |
|
595 | - * Add a tab to platform |
|
596 | - * @param string $tabName |
|
597 | - * @param string $url |
|
598 | - * |
|
599 | - * @return boolean |
|
600 | - */ |
|
594 | + /** |
|
595 | + * Add a tab to platform |
|
596 | + * @param string $tabName |
|
597 | + * @param string $url |
|
598 | + * |
|
599 | + * @return boolean |
|
600 | + */ |
|
601 | 601 | public function addTab($tabName, $url) |
602 | 602 | { |
603 | 603 | $sql = "SELECT * FROM settings_current |
@@ -1679,7 +1679,7 @@ discard block |
||
1679 | 1679 | |
1680 | 1680 | // We get the coach for the given course in a given session. |
1681 | 1681 | $sql = 'SELECT user_id FROM ' . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . |
1682 | - ' WHERE session_id ="' . $session_id . '" AND c_id="' . $courseId . '" AND status = 2'; |
|
1682 | + ' WHERE session_id ="' . $session_id . '" AND c_id="' . $courseId . '" AND status = 2'; |
|
1683 | 1683 | $rs = Database::query($sql); |
1684 | 1684 | while ($user = Database::fetch_array($rs)) { |
1685 | 1685 | $user_info = api_get_user_info($user['user_id']); |
@@ -3972,7 +3972,7 @@ discard block |
||
3972 | 3972 | } |
3973 | 3973 | |
3974 | 3974 | $session_title .= isset($course['special_course']) ? ' ' . |
3975 | - Display::return_icon('klipper.png', get_lang('CourseAutoRegister')) : ''; |
|
3975 | + Display::return_icon('klipper.png', get_lang('CourseAutoRegister')) : ''; |
|
3976 | 3976 | |
3977 | 3977 | $params['title'] = $session_title; |
3978 | 3978 | $params['extra'] = ''; |
@@ -510,7 +510,7 @@ discard block |
||
510 | 510 | if ($course_visibility != COURSE_VISIBILITY_HIDDEN && |
511 | 511 | ($course_visibility != COURSE_VISIBILITY_CLOSED || $user_in_course_status == COURSEMANAGER) |
512 | 512 | ) { |
513 | - $result .= '<span class="title">' . $course_title . '<span>'; |
|
513 | + $result .= '<span class="title">' . $course_title . '<span>'; |
|
514 | 514 | } else { |
515 | 515 | $result .= $course_title." "." ".get_lang('CourseClosed').""; |
516 | 516 | } |
@@ -1414,7 +1414,7 @@ discard block |
||
1414 | 1414 | } |
1415 | 1415 | $media .= '<div class="user-image">'; |
1416 | 1416 | $media .= '<a href="'.$url.'" ><img src="'. $users[$userIdLoop]['avatar'] . |
1417 | - '" alt="'.$users[$userIdLoop]['complete_name'].'" class="avatar-thumb"></a>'; |
|
1417 | + '" alt="'.$users[$userIdLoop]['complete_name'].'" class="avatar-thumb"></a>'; |
|
1418 | 1418 | $media .= '</div>'; |
1419 | 1419 | $media .= '<div class="user-data">'; |
1420 | 1420 | $media .= '<div class="username">' . '<a href="'.$url.'">'.$nameComplete.'</a></div>'; |
@@ -1645,10 +1645,10 @@ discard block |
||
1645 | 1645 | return $name; |
1646 | 1646 | } |
1647 | 1647 | /** |
1648 | - * Delete messages delete logic |
|
1649 | - * @param int $id id message to delete. |
|
1650 | - * @return bool status query |
|
1651 | - */ |
|
1648 | + * Delete messages delete logic |
|
1649 | + * @param int $id id message to delete. |
|
1650 | + * @return bool status query |
|
1651 | + */ |
|
1652 | 1652 | public static function deleteMessage($id) |
1653 | 1653 | { |
1654 | 1654 | $id = intval($id); |
@@ -1532,7 +1532,7 @@ |
||
1532 | 1532 | |
1533 | 1533 | if (isset($_REQUEST['action'])) { |
1534 | 1534 | switch ($_REQUEST['action']) { |
1535 | - case 'mark_as_unread' : |
|
1535 | + case 'mark_as_unread' : |
|
1536 | 1536 | $number_of_selected_messages = count($_POST['id']); |
1537 | 1537 | if (is_array($_POST['id'])) { |
1538 | 1538 | foreach ($_POST['id'] as $index => $message_id) { |
@@ -33,11 +33,11 @@ discard block |
||
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
36 | - * This function is for editing profile info from profile_id. |
|
37 | - * @param int $profileId |
|
38 | - * @param string $name |
|
39 | - * @param string $description |
|
40 | - */ |
|
36 | + * This function is for editing profile info from profile_id. |
|
37 | + * @param int $profileId |
|
38 | + * @param string $name |
|
39 | + * @param string $description |
|
40 | + */ |
|
41 | 41 | public function updateProfileInfo($profileId, $name, $description) |
42 | 42 | { |
43 | 43 | $profileId = intval($profileId); |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
131 | - * This function is for getting profile info from profile_id. |
|
132 | - * @param int $profileId |
|
133 | - */ |
|
131 | + * This function is for getting profile info from profile_id. |
|
132 | + * @param int $profileId |
|
133 | + */ |
|
134 | 134 | |
135 | 135 | public function getProfileInfo($profileId) |
136 | 136 | { |