@@ -443,6 +443,7 @@ |
||
| 443 | 443 | * @param bool hide navigation optionally |
| 444 | 444 | * @param int content per page when show navigation (optional) |
| 445 | 445 | * @param bool sort data optionally |
| 446 | + * @param boolean $visibility_options |
|
| 446 | 447 | * @return string grid html |
| 447 | 448 | */ |
| 448 | 449 | public function display_simple_grid($visibility_options, $hide_navigation = true, $per_page = 20, $sort_data = true, $grid_class = array()) |
@@ -339,9 +339,9 @@ discard block |
||
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | /** |
| 342 | - * This function shows the content of a table in a grid. |
|
| 343 | - * Should not be use to edit information (edit/delete rows) only. |
|
| 344 | - **/ |
|
| 342 | + * This function shows the content of a table in a grid. |
|
| 343 | + * Should not be use to edit information (edit/delete rows) only. |
|
| 344 | + **/ |
|
| 345 | 345 | public function display_grid() |
| 346 | 346 | { |
| 347 | 347 | |
@@ -790,7 +790,7 @@ discard block |
||
| 790 | 790 | //$param[$tablename.'_direction'] = $_GET[$tablename.'_direction']; |
| 791 | 791 | $my_get_direction = $_GET[$tablename.'_direction']; |
| 792 | 792 | if (!in_array($my_get_direction, array('ASC', 'DESC'))) { |
| 793 | - $param[$tablename.'_direction'] = 'ASC'; |
|
| 793 | + $param[$tablename.'_direction'] = 'ASC'; |
|
| 794 | 794 | } else { |
| 795 | 795 | $param[$tablename.'_direction'] = $my_get_direction; |
| 796 | 796 | } |
@@ -917,7 +917,7 @@ discard block |
||
| 917 | 917 | if (is_array($row)) { |
| 918 | 918 | foreach ($row as & $value) { |
| 919 | 919 | if (empty($value)) { |
| 920 | - $value = '-'; |
|
| 920 | + $value = '-'; |
|
| 921 | 921 | } |
| 922 | 922 | } |
| 923 | 923 | } |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | $this->per_page = isset($_GET[$this->param_prefix.'per_page']) ? intval($_GET[$this->param_prefix.'per_page']) : $this->per_page; |
| 176 | 176 | |
| 177 | 177 | $_SESSION[$this->param_prefix.'per_page'] = $this->per_page; |
| 178 | - $_SESSION[$this->param_prefix.'direction'] = $this->direction ; |
|
| 178 | + $_SESSION[$this->param_prefix.'direction'] = $this->direction; |
|
| 179 | 179 | $_SESSION[$this->param_prefix.'page_nr'] = $this->page_nr; |
| 180 | 180 | $_SESSION[$this->param_prefix.'column'] = $this->column; |
| 181 | 181 | $this->pager = null; |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | $params['spacesBeforeSeparator'] = ''; |
| 216 | 216 | $params['spacesAfterSeparator'] = ''; |
| 217 | 217 | $query_vars = array_keys($_GET); |
| 218 | - $query_vars_needed = array ($this->param_prefix.'column', $this->param_prefix.'direction', $this->param_prefix.'per_page'); |
|
| 218 | + $query_vars_needed = array($this->param_prefix.'column', $this->param_prefix.'direction', $this->param_prefix.'per_page'); |
|
| 219 | 219 | if (count($this->additional_parameters) > 0) { |
| 220 | 220 | $query_vars_needed = array_merge($query_vars_needed, array_keys($this->additional_parameters)); |
| 221 | 221 | } |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | |
| 288 | 288 | if (!$empty_table) { |
| 289 | 289 | if (!empty($this->additional_parameters)) { |
| 290 | - foreach($this->additional_parameters as $key => $value) { |
|
| 290 | + foreach ($this->additional_parameters as $key => $value) { |
|
| 291 | 291 | $html .= '<input type="hidden" name ="'.Security::remove_XSS($key).'" value ="'.Security::remove_XSS($value).'" />'; |
| 292 | 292 | } |
| 293 | 293 | } |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | $html .= '<li><a data-action ="'.$action.'" href="#" onclick="javascript:action_click(this, \''.$table_id.'\');">'.$label.'</a></li>'; |
| 313 | 313 | } |
| 314 | 314 | $html .= '</ul>'; |
| 315 | - $html .= '</div>';//btn-group |
|
| 315 | + $html .= '</div>'; //btn-group |
|
| 316 | 316 | $html .= '</div>'; //toolbar |
| 317 | 317 | } else { |
| 318 | 318 | $html .= $form; |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | |
| 391 | 391 | $html .= '<div class="clear"></div>'; |
| 392 | 392 | if (count($this->form_actions) > 0) { |
| 393 | - $script= '<script> |
|
| 393 | + $script = '<script> |
|
| 394 | 394 | /*<![CDATA[*/ |
| 395 | 395 | function setCheckbox(value) { |
| 396 | 396 | d = document.form_'.$this->table_name.'; |
@@ -412,7 +412,7 @@ discard block |
||
| 412 | 412 | } |
| 413 | 413 | } |
| 414 | 414 | // Getting the items of the table |
| 415 | - $items = $this->get_clean_html(false); //no sort |
|
| 415 | + $items = $this->get_clean_html(false); //no sort |
|
| 416 | 416 | |
| 417 | 417 | // Generation of style classes must be improved. Maybe we need a a table name to create style on the fly: |
| 418 | 418 | // i.e: .whoisonline_table_grid_container instead of .grid_container |
@@ -480,7 +480,7 @@ discard block |
||
| 480 | 480 | |
| 481 | 481 | $html .= '<div class="clear"></div>'; |
| 482 | 482 | if (count($this->form_actions) > 0) { |
| 483 | - $script= '<script> |
|
| 483 | + $script = '<script> |
|
| 484 | 484 | /*<![CDATA[*/ |
| 485 | 485 | function setCheckbox(value) { |
| 486 | 486 | d = document.form_'.$this->table_name.'; |
@@ -586,7 +586,7 @@ discard block |
||
| 586 | 586 | $counter = 0; |
| 587 | 587 | foreach ($row as $index => $rowInfo) { |
| 588 | 588 | if (!isset($this->columnsToHide[$index])) { |
| 589 | - $newRow[$counter] = $rowInfo ; |
|
| 589 | + $newRow[$counter] = $rowInfo; |
|
| 590 | 590 | $counter++; |
| 591 | 591 | } |
| 592 | 592 | } |
@@ -601,7 +601,7 @@ discard block |
||
| 601 | 601 | } |
| 602 | 602 | |
| 603 | 603 | if ($this->odd_even_rows_enabled == true) { |
| 604 | - $this->altRowAttributes(0, array ('class' => 'row_odd'), array ('class' => 'row_even'), true); |
|
| 604 | + $this->altRowAttributes(0, array('class' => 'row_odd'), array('class' => 'row_even'), true); |
|
| 605 | 605 | } |
| 606 | 606 | |
| 607 | 607 | foreach ($this->th_attributes as $column => $attributes) { |
@@ -661,11 +661,11 @@ discard block |
||
| 661 | 661 | } |
| 662 | 662 | $result[] = '<select name="'.$this->param_prefix.'per_page" onchange="javascript: this.form.submit();">'; |
| 663 | 663 | for ($nr = 10; $nr <= min(50, $total_number_of_items); $nr += 10) { |
| 664 | - $result[] = '<option value="'.$nr.'" '. ($nr == $this->per_page ? 'selected="selected"' : '').'>'.$nr.'</option>'; |
|
| 664 | + $result[] = '<option value="'.$nr.'" '.($nr == $this->per_page ? 'selected="selected"' : '').'>'.$nr.'</option>'; |
|
| 665 | 665 | } |
| 666 | 666 | // @todo no limits |
| 667 | 667 | //if ($total_number_of_items < 500) { |
| 668 | - $result[] = '<option value="'.$total_number_of_items.'" '. ($total_number_of_items == $this->per_page ? 'selected="selected"' : '').'>'.api_ucfirst(get_lang('All')).'</option>'; |
|
| 668 | + $result[] = '<option value="'.$total_number_of_items.'" '.($total_number_of_items == $this->per_page ? 'selected="selected"' : '').'>'.api_ucfirst(get_lang('All')).'</option>'; |
|
| 669 | 669 | //} |
| 670 | 670 | $result[] = '</select>'; |
| 671 | 671 | $result[] = '<noscript>'; |
@@ -777,7 +777,7 @@ discard block |
||
| 777 | 777 | */ |
| 778 | 778 | public function get_additional_url_paramstring() |
| 779 | 779 | { |
| 780 | - $param_string_parts = array (); |
|
| 780 | + $param_string_parts = array(); |
|
| 781 | 781 | if (is_array($this->additional_parameters) && count($this->additional_parameters) > 0) { |
| 782 | 782 | foreach ($this->additional_parameters as $key => & $value) { |
| 783 | 783 | $param_string_parts[] = urlencode($key).'='.urlencode($value); |
@@ -790,7 +790,7 @@ discard block |
||
| 790 | 790 | //$param[$tablename.'_direction'] = $_GET[$tablename.'_direction']; |
| 791 | 791 | $my_get_direction = $_GET[$tablename.'_direction']; |
| 792 | 792 | if (!in_array($my_get_direction, array('ASC', 'DESC'))) { |
| 793 | - $param[$tablename.'_direction'] = 'ASC'; |
|
| 793 | + $param[$tablename.'_direction'] = 'ASC'; |
|
| 794 | 794 | } else { |
| 795 | 795 | $param[$tablename.'_direction'] = $my_get_direction; |
| 796 | 796 | } |
@@ -804,7 +804,7 @@ discard block |
||
| 804 | 804 | if (isset($_GET[$tablename.'_column'])) { |
| 805 | 805 | $param[$tablename.'_column'] = intval($_GET[$tablename.'_column']); |
| 806 | 806 | } |
| 807 | - $param_string_parts = array (); |
|
| 807 | + $param_string_parts = array(); |
|
| 808 | 808 | foreach ($param as $key => & $value) { |
| 809 | 809 | $param_string_parts[] = urlencode($key).'='.urlencode($value); |
| 810 | 810 | } |
@@ -824,7 +824,7 @@ discard block |
||
| 824 | 824 | $param[$this->param_prefix.'page_nr'] = $this->page_nr; |
| 825 | 825 | $param[$this->param_prefix.'per_page'] = $this->per_page; |
| 826 | 826 | $param[$this->param_prefix.'column'] = $this->column; |
| 827 | - $param_string_parts = array (); |
|
| 827 | + $param_string_parts = array(); |
|
| 828 | 828 | foreach ($param as $key => & $value) { |
| 829 | 829 | $param_string_parts[] = urlencode($key).'='.urlencode($value); |
| 830 | 830 | } |
@@ -808,8 +808,9 @@ |
||
| 808 | 808 | foreach ($param as $key => & $value) { |
| 809 | 809 | $param_string_parts[] = urlencode($key).'='.urlencode($value); |
| 810 | 810 | } |
| 811 | - if (count($param_string_parts) > 0) |
|
| 812 | - $result .= '&'.implode('&', $param_string_parts); |
|
| 811 | + if (count($param_string_parts) > 0) { |
|
| 812 | + $result .= '&'.implode('&', $param_string_parts); |
|
| 813 | + } |
|
| 813 | 814 | } |
| 814 | 815 | return $result; |
| 815 | 816 | } |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | |
| 101 | 101 | /** |
| 102 | 102 | * @param array $conditions a list of condition (exemple : status=>STUDENT) |
| 103 | - * @param array $order_by a list of fields on which sort |
|
| 103 | + * @param string[] $order_by a list of fields on which sort |
|
| 104 | 104 | * @return array An array with all users of the platform. |
| 105 | 105 | */ |
| 106 | 106 | function get_specific_field_values_list( |
@@ -235,6 +235,7 @@ discard block |
||
| 235 | 235 | * @param string Course code |
| 236 | 236 | * @param string Tool ID |
| 237 | 237 | * @param int Internal ID used in specific tool table |
| 238 | + * @param string $tool_id |
|
| 238 | 239 | */ |
| 239 | 240 | function delete_all_values_for_item($course_id, $tool_id, $ref_id) { |
| 240 | 241 | $table_sf_values = Database :: get_main_table(TABLE_MAIN_SPECIFIC_FIELD_VALUES); |
@@ -248,6 +249,7 @@ discard block |
||
| 248 | 249 | * Defaults to the first letter of the name, otherwise iterate through available |
| 249 | 250 | * letters |
| 250 | 251 | * @param string Name |
| 252 | + * @param string $name |
|
| 251 | 253 | * @return string One-letter code, upper-case |
| 252 | 254 | */ |
| 253 | 255 | function get_specific_field_code_from_name($name) { |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Manage specific tools |
|
| 4 | - * @package chamilo.library |
|
| 5 | - */ |
|
| 3 | + * Manage specific tools |
|
| 4 | + * @package chamilo.library |
|
| 5 | + */ |
|
| 6 | 6 | |
| 7 | 7 | // Database table definitions |
| 8 | 8 | $table_sf = Database :: get_main_table(TABLE_MAIN_SPECIFIC_FIELD); |
@@ -237,10 +237,10 @@ discard block |
||
| 237 | 237 | * @param int Internal ID used in specific tool table |
| 238 | 238 | */ |
| 239 | 239 | function delete_all_values_for_item($course_id, $tool_id, $ref_id) { |
| 240 | - $table_sf_values = Database :: get_main_table(TABLE_MAIN_SPECIFIC_FIELD_VALUES); |
|
| 241 | - $sql = 'DELETE FROM %s WHERE course_code = \'%s\' AND tool_id = \'%s\' AND ref_id = %s'; |
|
| 242 | - $sql = sprintf($sql, $table_sf_values, $course_id, $tool_id, $ref_id); |
|
| 243 | - Database::query($sql); |
|
| 240 | + $table_sf_values = Database :: get_main_table(TABLE_MAIN_SPECIFIC_FIELD_VALUES); |
|
| 241 | + $sql = 'DELETE FROM %s WHERE course_code = \'%s\' AND tool_id = \'%s\' AND ref_id = %s'; |
|
| 242 | + $sql = sprintf($sql, $table_sf_values, $course_id, $tool_id, $ref_id); |
|
| 243 | + Database::query($sql); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | /** |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | function delete_specific_field($id) |
| 43 | 43 | { |
| 44 | 44 | $table_sf = Database:: get_main_table(TABLE_MAIN_SPECIFIC_FIELD); |
| 45 | - $id = (int)$id; |
|
| 45 | + $id = (int) $id; |
|
| 46 | 46 | if (!is_numeric($id)) { |
| 47 | 47 | return false; |
| 48 | 48 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | function edit_specific_field($id, $name) |
| 61 | 61 | { |
| 62 | 62 | $table_sf = Database:: get_main_table(TABLE_MAIN_SPECIFIC_FIELD); |
| 63 | - $id = (int)$id; |
|
| 63 | + $id = (int) $id; |
|
| 64 | 64 | if (!is_numeric($id)) { |
| 65 | 65 | return false; |
| 66 | 66 | } |
@@ -85,6 +85,7 @@ |
||
| 85 | 85 | /** |
| 86 | 86 | * @author Sebastien Piraux <[email protected]> |
| 87 | 87 | * @param sql : a sql query (as a string) |
| 88 | + * @param integer $X |
|
| 88 | 89 | * @desc Return many results of a query in a X column tab |
| 89 | 90 | * in $resu[$i][0], $resu[$i][1],$resu[$i][2],... |
| 90 | 91 | * this function is more 'standard' but use a little |
@@ -107,14 +107,14 @@ |
||
| 107 | 107 | return $resu; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - /** |
|
| 111 | - * @author Sebastien Piraux <[email protected]> |
|
| 112 | - * @param sql : a sql query (as a string) |
|
| 113 | - * @return hours_array |
|
| 114 | - * @desc Return an assoc array. Keys are the hours, values are |
|
| 115 | - * the number of time this hours was found. |
|
| 116 | - * key 'total' return the sum of all number of time hours |
|
| 117 | - * appear |
|
| 110 | + /** |
|
| 111 | + * @author Sebastien Piraux <[email protected]> |
|
| 112 | + * @param sql : a sql query (as a string) |
|
| 113 | + * @return hours_array |
|
| 114 | + * @desc Return an assoc array. Keys are the hours, values are |
|
| 115 | + * the number of time this hours was found. |
|
| 116 | + * key 'total' return the sum of all number of time hours |
|
| 117 | + * appear |
|
| 118 | 118 | */ |
| 119 | 119 | public static function hoursTab($sql) |
| 120 | 120 | { |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | $last_day = -1; |
| 156 | 156 | while ($row = Database::fetch_row($res)) { |
| 157 | 157 | $date_array = getdate($row[0]); |
| 158 | - $display_date = $date_array['mday'] . ' ' . $MonthsShort[$date_array['mon'] - 1] . ' ' . $date_array['year']; |
|
| 158 | + $display_date = $date_array['mday'].' '.$MonthsShort[$date_array['mon'] - 1].' '.$date_array['year']; |
|
| 159 | 159 | if ($date_array['mday'] == $last_day) { |
| 160 | 160 | $days_array[$display_date]++; |
| 161 | 161 | } else { |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | |
| 222 | 222 | </td> |
| 223 | 223 | <td width='10%'> |
| 224 | - <b>" . get_lang('Hits') . "</b> |
|
| 224 | + <b>".get_lang('Hits')."</b> |
|
| 225 | 225 | </td> |
| 226 | 226 | <td width='15%'> |
| 227 | 227 | <b>%</b> |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | echo "<img src='../img/bar_1m.gif' width='1' height='12' alt='$periodPiece : $cpt hits – $pourcent %' />"; |
| 250 | 250 | } |
| 251 | 251 | if ($pourcent != 100) { |
| 252 | - echo "<img src='../img/bar_1r.gif' width='" . ($maxSize - $barwidth) . "' height='12' alt='$periodPiece : $cpt hits – $pourcent %' />"; |
|
| 252 | + echo "<img src='../img/bar_1r.gif' width='".($maxSize - $barwidth)."' height='12' alt='$periodPiece : $cpt hits – $pourcent %' />"; |
|
| 253 | 253 | } |
| 254 | 254 | echo "<img src='../img/bar_1.gif' width='1' height='12' alt='$periodPiece : $cpt hits – $pourcent %' /> |
| 255 | 255 | </td> |
@@ -265,13 +265,13 @@ discard block |
||
| 265 | 265 | } |
| 266 | 266 | echo "<tr bgcolor='#E6E6E6'> |
| 267 | 267 | <td width='15%' align='center'> |
| 268 | - " . get_lang('Total') . " |
|
| 268 | + " . get_lang('Total')." |
|
| 269 | 269 | </td> |
| 270 | 270 | <td align='right' width='60%'> |
| 271 | 271 | |
| 272 | 272 | </td> |
| 273 | 273 | <td align='center' width='10%'> |
| 274 | - " . $period_array['total'] . " |
|
| 274 | + " . $period_array['total']." |
|
| 275 | 275 | </td> |
| 276 | 276 | <td width='15%'> |
| 277 | 277 | |
@@ -18,6 +18,7 @@ discard block |
||
| 18 | 18 | * Get all files of lang folder (forum.inc.php,gradebook.inc.php,notebook.inc.php) |
| 19 | 19 | * @param String The lang path folder (/var/www/my_lms/main/lang/spanish) |
| 20 | 20 | * @param bool true if we only want the "subname" trad4all instead of trad4all.inc.php |
| 21 | + * @param string $path |
|
| 21 | 22 | * |
| 22 | 23 | * @return Array All file of lang folder |
| 23 | 24 | */ |
@@ -68,6 +69,7 @@ discard block |
||
| 68 | 69 | /** |
| 69 | 70 | * Get all information of language |
| 70 | 71 | * @param Integer The parent id(Language father id) |
| 72 | + * @param integer $parent_id |
|
| 71 | 73 | * @return Array All information about language |
| 72 | 74 | */ |
| 73 | 75 | public static function get_all_information_of_language($parent_id) |
@@ -86,6 +88,7 @@ discard block |
||
| 86 | 88 | /** |
| 87 | 89 | * Get all information of chamilo file |
| 88 | 90 | * @param String The chamilo path file (/var/www/chamilo/main/lang/spanish/gradebook.inc.php) |
| 91 | + * @param string $system_path_file |
|
| 89 | 92 | * @patam Bool Whether we want to remove the '$' prefix in the results or not |
| 90 | 93 | * @return Array Contains all information of chamilo file |
| 91 | 94 | */ |
@@ -345,7 +348,7 @@ discard block |
||
| 345 | 348 | /** |
| 346 | 349 | * Make available the language |
| 347 | 350 | * @param Integer The language id |
| 348 | - * @return void |
|
| 351 | + * @return boolean |
|
| 349 | 352 | */ |
| 350 | 353 | public static function make_available_language($language_id) |
| 351 | 354 | { |
@@ -29,8 +29,9 @@ |
||
| 29 | 29 | while (($file = readdir($dh)) !== false) { |
| 30 | 30 | if ($file[0] <> '.' && substr($file, -4, strlen($file)) == '.php') { |
| 31 | 31 | if ($only_main_name) { |
| 32 | - if ($file != '' && strpos($file, '.inc.php')) |
|
| 33 | - $content_dir[] = substr($file, 0, strpos($file, '.inc.php')); |
|
| 32 | + if ($file != '' && strpos($file, '.inc.php')) { |
|
| 33 | + $content_dir[] = substr($file, 0, strpos($file, '.inc.php')); |
|
| 34 | + } |
|
| 34 | 35 | } else { |
| 35 | 36 | $content_dir[] = $file; |
| 36 | 37 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | public static function getAllLanguages() |
| 22 | 22 | { |
| 23 | 23 | $table = Database :: get_main_table(TABLE_MAIN_LANGUAGE); |
| 24 | - $sql = 'SELECT * FROM ' . $table; |
|
| 24 | + $sql = 'SELECT * FROM '.$table; |
|
| 25 | 25 | $rs = Database::query($sql); |
| 26 | 26 | $all_languages = []; |
| 27 | 27 | while ($row = Database::fetch_array($rs, 'ASSOC')) { |
@@ -70,10 +70,10 @@ discard block |
||
| 70 | 70 | public static function get_all_information_of_sub_language($parent_id, $sub_language_id) |
| 71 | 71 | { |
| 72 | 72 | $table = Database :: get_main_table(TABLE_MAIN_LANGUAGE); |
| 73 | - $sql = 'SELECT * FROM ' . $table . ' |
|
| 73 | + $sql = 'SELECT * FROM '.$table.' |
|
| 74 | 74 | WHERE |
| 75 | 75 | parent_id= ' . intval($parent_id).' AND |
| 76 | - id= ' . intval($sub_language_id) . ''; |
|
| 76 | + id= ' . intval($sub_language_id).''; |
|
| 77 | 77 | $rs = Database::query($sql); |
| 78 | 78 | $all_information = array(); |
| 79 | 79 | while ($row = Database::fetch_array($rs, 'ASSOC')) { |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | public static function get_all_information_of_language($parent_id) |
| 92 | 92 | { |
| 93 | 93 | $table = Database :: get_main_table(TABLE_MAIN_LANGUAGE); |
| 94 | - $sql = 'SELECT * FROM ' . $table . ' WHERE id = "' . intval($parent_id) . '"'; |
|
| 94 | + $sql = 'SELECT * FROM '.$table.' WHERE id = "'.intval($parent_id).'"'; |
|
| 95 | 95 | $rs = Database::query($sql); |
| 96 | 96 | $all_information = array(); |
| 97 | 97 | while ($row = Database::fetch_array($rs, 'ASSOC')) { |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | */ |
| 138 | 138 | public static function add_file_in_language_directory($system_path_file) |
| 139 | 139 | { |
| 140 | - $return_value = @file_put_contents($system_path_file, '<?php' . PHP_EOL); |
|
| 140 | + $return_value = @file_put_contents($system_path_file, '<?php'.PHP_EOL); |
|
| 141 | 141 | |
| 142 | 142 | return $return_value; |
| 143 | 143 | } |
@@ -152,10 +152,10 @@ discard block |
||
| 152 | 152 | public static function write_data_in_file($path_file, $new_term, $new_variable) |
| 153 | 153 | { |
| 154 | 154 | $return_value = false; |
| 155 | - $new_data = $new_variable . '=' . $new_term; |
|
| 155 | + $new_data = $new_variable.'='.$new_term; |
|
| 156 | 156 | $resource = @fopen($path_file, "a"); |
| 157 | 157 | if (file_exists($path_file) && $resource) { |
| 158 | - if (fwrite($resource, $new_data . PHP_EOL) === false) { |
|
| 158 | + if (fwrite($resource, $new_data.PHP_EOL) === false) { |
|
| 159 | 159 | //not allow to write |
| 160 | 160 | $return_value = false; |
| 161 | 161 | } else { |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | if (empty($sub_language_dir)) { |
| 178 | 178 | return false; |
| 179 | 179 | } |
| 180 | - $dir = api_get_path(SYS_LANG_PATH) . $sub_language_dir; |
|
| 180 | + $dir = api_get_path(SYS_LANG_PATH).$sub_language_dir; |
|
| 181 | 181 | if (is_dir($dir)) { |
| 182 | 182 | return true; |
| 183 | 183 | } //even if the dir already exists, we reach the objective of having the directory there |
@@ -201,8 +201,8 @@ discard block |
||
| 201 | 201 | return false; |
| 202 | 202 | } |
| 203 | 203 | $table = Database :: get_main_table(TABLE_MAIN_LANGUAGE); |
| 204 | - $sql = 'SELECT dokeos_folder FROM ' . $table . ' |
|
| 205 | - WHERE parent_id = ' . $parent_id . ' and id = ' . $sub_language_id; |
|
| 204 | + $sql = 'SELECT dokeos_folder FROM '.$table.' |
|
| 205 | + WHERE parent_id = ' . $parent_id.' and id = '.$sub_language_id; |
|
| 206 | 206 | $res = Database::query($sql); |
| 207 | 207 | if ($res === false or Database::num_rows($res) < 1) { |
| 208 | 208 | return false; |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | if ($res === false) { |
| 213 | 213 | return false; |
| 214 | 214 | } //can't delete dir, so do not delete language record |
| 215 | - $sql = 'DELETE FROM ' . $table . ' |
|
| 215 | + $sql = 'DELETE FROM '.$table.' |
|
| 216 | 216 | WHERE id= ' . intval($sub_language_id); |
| 217 | 217 | $res = Database::query($sql); |
| 218 | 218 | |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | if (empty($sub_language_dir)) { |
| 230 | 230 | return false; |
| 231 | 231 | } |
| 232 | - $dir = api_get_path(SYS_LANG_PATH) . $sub_language_dir; |
|
| 232 | + $dir = api_get_path(SYS_LANG_PATH).$sub_language_dir; |
|
| 233 | 233 | if (!is_dir($dir)) { |
| 234 | 234 | return true; |
| 235 | 235 | } //even if the dir does not exist, we reach the objective of not having the directory there |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | |
| 238 | 238 | if (count($content) > 0) { |
| 239 | 239 | foreach ($content as $value_content) { |
| 240 | - $path_file = $dir . '/' . $value_content; |
|
| 240 | + $path_file = $dir.'/'.$value_content; |
|
| 241 | 241 | unlink($path_file); |
| 242 | 242 | } |
| 243 | 243 | return @rmdir($dir); |
@@ -255,8 +255,8 @@ discard block |
||
| 255 | 255 | { |
| 256 | 256 | $table = Database :: get_main_table(TABLE_MAIN_LANGUAGE); |
| 257 | 257 | $sql = 'SELECT count(*) as count |
| 258 | - FROM ' . $table . ' |
|
| 259 | - WHERE id="' . intval($language_id) . '"'; |
|
| 258 | + FROM ' . $table.' |
|
| 259 | + WHERE id="' . intval($language_id).'"'; |
|
| 260 | 260 | $rs = Database::query($sql); |
| 261 | 261 | if (Database::num_rows($rs) > 0) { |
| 262 | 262 | if (Database::result($rs, 0, 'count') == 1) { |
@@ -278,8 +278,8 @@ discard block |
||
| 278 | 278 | { |
| 279 | 279 | $table = Database :: get_main_table(TABLE_MAIN_LANGUAGE); |
| 280 | 280 | $sql = 'SELECT original_name |
| 281 | - FROM ' . $table . ' |
|
| 282 | - WHERE id= ' . intval($language_id) . ''; |
|
| 281 | + FROM ' . $table.' |
|
| 282 | + WHERE id= ' . intval($language_id).''; |
|
| 283 | 283 | $rs = Database::query($sql); |
| 284 | 284 | if (Database::num_rows($rs) > 0) { |
| 285 | 285 | return Database::result($rs, 0, 'original_name'); |
@@ -297,8 +297,8 @@ discard block |
||
| 297 | 297 | public static function check_if_language_is_sub_language($language_id) |
| 298 | 298 | { |
| 299 | 299 | $table = Database :: get_main_table(TABLE_MAIN_LANGUAGE); |
| 300 | - $sql = 'SELECT count(*) AS count FROM ' . $table . ' |
|
| 301 | - WHERE id = ' . intval($language_id) . ' AND NOT ISNULL(parent_id)'; |
|
| 300 | + $sql = 'SELECT count(*) AS count FROM '.$table.' |
|
| 301 | + WHERE id = ' . intval($language_id).' AND NOT ISNULL(parent_id)'; |
|
| 302 | 302 | $rs = Database::query($sql); |
| 303 | 303 | |
| 304 | 304 | if (Database::num_rows($rs) > 0 && Database::result($rs, '0', 'count') == 1) { |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | { |
| 317 | 317 | $language_info = self::get_all_information_of_language($language_id); |
| 318 | 318 | $table = Database :: get_main_table(TABLE_MAIN_USER); |
| 319 | - $sql = 'SELECT count(*) AS count FROM ' . $table . ' |
|
| 319 | + $sql = 'SELECT count(*) AS count FROM '.$table.' |
|
| 320 | 320 | WHERE language ="' . Database::escape_string($language_info['english_name']).'"'; |
| 321 | 321 | $rs = Database::query($sql); |
| 322 | 322 | if (Database::num_rows($rs) > 0 && Database::result($rs, '0', 'count') >= 1) { |
@@ -334,8 +334,8 @@ discard block |
||
| 334 | 334 | public static function check_if_language_is_father($language_id) |
| 335 | 335 | { |
| 336 | 336 | $table = Database :: get_main_table(TABLE_MAIN_LANGUAGE); |
| 337 | - $sql = 'SELECT count(*) AS count FROM ' . $table . ' |
|
| 338 | - WHERE parent_id= ' . intval($language_id) . ' AND NOT ISNULL(parent_id);'; |
|
| 337 | + $sql = 'SELECT count(*) AS count FROM '.$table.' |
|
| 338 | + WHERE parent_id= ' . intval($language_id).' AND NOT ISNULL(parent_id);'; |
|
| 339 | 339 | $rs = Database::query($sql); |
| 340 | 340 | |
| 341 | 341 | if (Database::num_rows($rs) > 0 && Database::result($rs, '0', 'count') == 1) { |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | { |
| 355 | 355 | $tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE); |
| 356 | 356 | $sql = "UPDATE $tbl_admin_languages SET available='0' |
| 357 | - WHERE id = " . intval($language_id) . ""; |
|
| 357 | + WHERE id = ".intval($language_id).""; |
|
| 358 | 358 | $result = Database::query($sql); |
| 359 | 359 | |
| 360 | 360 | return $result !== false; //only return false on sql error |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | { |
| 370 | 370 | $tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE); |
| 371 | 371 | $sql = "UPDATE $tbl_admin_languages SET available='1' |
| 372 | - WHERE id = " . intval($language_id) . ""; |
|
| 372 | + WHERE id = ".intval($language_id).""; |
|
| 373 | 373 | $result = Database::query($sql); |
| 374 | 374 | |
| 375 | 375 | return $result !== false; //only return false on sql error |
@@ -387,11 +387,11 @@ discard block |
||
| 387 | 387 | } |
| 388 | 388 | $tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE); |
| 389 | 389 | $tbl_settings_current = Database :: get_main_table(TABLE_MAIN_SETTINGS_CURRENT); |
| 390 | - $sql = "SELECT english_name FROM " . $tbl_admin_languages . " |
|
| 391 | - WHERE id= " . intval($language_id) . ""; |
|
| 390 | + $sql = "SELECT english_name FROM ".$tbl_admin_languages." |
|
| 391 | + WHERE id= " . intval($language_id).""; |
|
| 392 | 392 | $result = Database::query($sql); |
| 393 | 393 | $lang = Database::fetch_array($result); |
| 394 | - $sql_update_2 = "UPDATE " . $tbl_settings_current . " SET selected_value='" . $lang['english_name'] . "' |
|
| 394 | + $sql_update_2 = "UPDATE ".$tbl_settings_current." SET selected_value='".$lang['english_name']."' |
|
| 395 | 395 | WHERE variable='platformLanguage'"; |
| 396 | 396 | $result_2 = Database::query($sql_update_2); |
| 397 | 397 | Event::addEvent( |
@@ -411,7 +411,7 @@ discard block |
||
| 411 | 411 | { |
| 412 | 412 | $name = api_get_setting('platformLanguage'); |
| 413 | 413 | $tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE); |
| 414 | - $sql = "SELECT id FROM " . $tbl_admin_languages . " WHERE english_name ='$name'"; |
|
| 414 | + $sql = "SELECT id FROM ".$tbl_admin_languages." WHERE english_name ='$name'"; |
|
| 415 | 415 | $res = Database::query($sql); |
| 416 | 416 | if (Database::num_rows($res) < 1) { |
| 417 | 417 | return false; |
@@ -430,10 +430,10 @@ discard block |
||
| 430 | 430 | { |
| 431 | 431 | $tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE); |
| 432 | 432 | $sql = "SELECT dokeos_folder |
| 433 | - FROM " . $tbl_admin_languages . " |
|
| 433 | + FROM " . $tbl_admin_languages." |
|
| 434 | 434 | WHERE id = ( |
| 435 | - SELECT parent_id FROM " . $tbl_admin_languages . " |
|
| 436 | - WHERE dokeos_folder = '" . Database::escape_string($language_path) . "' |
|
| 435 | + SELECT parent_id FROM " . $tbl_admin_languages." |
|
| 436 | + WHERE dokeos_folder = '" . Database::escape_string($language_path)."' |
|
| 437 | 437 | ) |
| 438 | 438 | "; |
| 439 | 439 | $result = Database::query($sql); |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | $adminLanguagesTable = Database :: get_main_table(TABLE_MAIN_LANGUAGE); |
| 456 | 456 | // select language - if case several languages match, get the last (more recent) one |
| 457 | 457 | $sql = "SELECT english_name |
| 458 | - FROM " . $adminLanguagesTable . " |
|
| 458 | + FROM " . $adminLanguagesTable." |
|
| 459 | 459 | WHERE |
| 460 | 460 | isocode ='$isocode' AND |
| 461 | 461 | available = 1 |
@@ -14,6 +14,9 @@ |
||
| 14 | 14 | class Session implements \ArrayAccess |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | + /** |
|
| 18 | + * @param string $variable |
|
| 19 | + */ |
|
| 17 | 20 | static function read($variable, $default = null) |
| 18 | 21 | { |
| 19 | 22 | return isset($_SESSION[$variable]) ? $_SESSION[$variable] : $default; |
@@ -31,6 +31,10 @@ |
||
| 31 | 31 | return $method == 'GET'; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | + /** |
|
| 35 | + * @param string $key |
|
| 36 | + * @param string $default |
|
| 37 | + */ |
|
| 34 | 38 | public static function post($key, $default = null) |
| 35 | 39 | { |
| 36 | 40 | return isset($_POST[$key]) ? $_POST[$key] : $default; |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | return isset($_REQUEST[$key]) ? $_REQUEST[$key] : $default; |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | - public static function has($key){ |
|
| 18 | + public static function has($key) { |
|
| 19 | 19 | return isset($_REQUEST[$key]); |
| 20 | 20 | } |
| 21 | 21 | |
@@ -16,7 +16,6 @@ |
||
| 16 | 16 | * @author Patrick Cool |
| 17 | 17 | * @author René Haentjens, added CSV file import (October 2004) |
| 18 | 18 | * @package chamilo.link |
| 19 | - |
|
| 20 | 19 | */ |
| 21 | 20 | |
| 22 | 21 | // Including libraries |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | * @param int Whether the announcement should be visible to anonymous users (1) or not (0) |
| 307 | 307 | * @param string The language for which the announvement should be shown. Leave null for all langages |
| 308 | 308 | * @param int Whether to send an e-mail to all users (1) or not (0) |
| 309 | - * @return mixed insert_id on success, false on failure |
|
| 309 | + * @return false|string insert_id on success, false on failure |
|
| 310 | 310 | */ |
| 311 | 311 | public static function add_announcement( |
| 312 | 312 | $title, |
@@ -648,6 +648,8 @@ discard block |
||
| 648 | 648 | * @param int Whether to send to all teachers (1) or not (0) |
| 649 | 649 | * @param int Whether to send to all students (1) or not (0) |
| 650 | 650 | * @param string Language (optional, considered for all languages if left empty) |
| 651 | + * @param integer|null $teacher |
|
| 652 | + * @param integer|null $student |
|
| 651 | 653 | * @return bool True if the message was sent or there was no destination matching. False on database or e-mail sending error. |
| 652 | 654 | */ |
| 653 | 655 | public static function send_system_announcement_by_email($title, $content, $teacher, $student, $language = null, $sendEmailTest = false) |
@@ -22,14 +22,14 @@ discard block |
||
| 22 | 22 | $tbl_announcement_group = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS_GROUPS); |
| 23 | 23 | $userGroup = new UserGroup(); |
| 24 | 24 | |
| 25 | - $temp_user_groups = $userGroup->get_groups_by_user(api_get_user_id(),0); |
|
| 25 | + $temp_user_groups = $userGroup->get_groups_by_user(api_get_user_id(), 0); |
|
| 26 | 26 | $groups = array(); |
| 27 | 27 | foreach ($temp_user_groups as $user_group) { |
| 28 | 28 | $groups = array_merge($groups, array($user_group['id'])); |
| 29 | 29 | $groups = array_merge($groups, $userGroup->get_parent_groups($user_group['id'])); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - $groups_string = '('.implode($groups,',').')'; |
|
| 32 | + $groups_string = '('.implode($groups, ',').')'; |
|
| 33 | 33 | $now = api_get_utc_datetime(); |
| 34 | 34 | $sql = "SELECT *, DATE_FORMAT(date_start,'%d-%m-%Y %h:%i:%s') AS display_date |
| 35 | 35 | FROM $db_table |
@@ -104,13 +104,13 @@ discard block |
||
| 104 | 104 | * @param string $user_id |
| 105 | 105 | * @return string |
| 106 | 106 | */ |
| 107 | - public static function display_all_announcements($visible, $id = -1, $start = 0,$user_id='') |
|
| 107 | + public static function display_all_announcements($visible, $id = -1, $start = 0, $user_id = '') |
|
| 108 | 108 | { |
| 109 | 109 | $user_selected_language = api_get_interface_language(); |
| 110 | - $start = intval($start); |
|
| 110 | + $start = intval($start); |
|
| 111 | 111 | $userGroup = new UserGroup(); |
| 112 | 112 | $tbl_announcement_group = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS_GROUPS); |
| 113 | - $temp_user_groups = $userGroup->get_groups_by_user(api_get_user_id(),0); |
|
| 113 | + $temp_user_groups = $userGroup->get_groups_by_user(api_get_user_id(), 0); |
|
| 114 | 114 | $groups = array(); |
| 115 | 115 | foreach ($temp_user_groups as $user_group) { |
| 116 | 116 | $groups = array_merge($groups, array($user_group['id'])); |
@@ -118,10 +118,10 @@ discard block |
||
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | // Checks if tables exists to not break platform not updated |
| 121 | - $groups_string = '('.implode($groups,',').')'; |
|
| 121 | + $groups_string = '('.implode($groups, ',').')'; |
|
| 122 | 122 | |
| 123 | 123 | $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
| 124 | - $now = api_get_utc_datetime(); |
|
| 124 | + $now = api_get_utc_datetime(); |
|
| 125 | 125 | |
| 126 | 126 | $sql = "SELECT * FROM ".$db_table." |
| 127 | 127 | WHERE |
@@ -152,10 +152,10 @@ discard block |
||
| 152 | 152 | $sql .= " AND access_url_id IN ('1', '$current_access_url_id')"; |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - if(!isset($_GET['start']) || $_GET['start'] == 0) { |
|
| 155 | + if (!isset($_GET['start']) || $_GET['start'] == 0) { |
|
| 156 | 156 | $sql .= " ORDER BY date_start DESC LIMIT ".$start.",20"; |
| 157 | 157 | } else { |
| 158 | - $sql .= " ORDER BY date_start DESC LIMIT ".($start+1).",20"; |
|
| 158 | + $sql .= " ORDER BY date_start DESC LIMIT ".($start + 1).",20"; |
|
| 159 | 159 | } |
| 160 | 160 | $announcements = Database::query($sql); |
| 161 | 161 | $content = ''; |
@@ -207,13 +207,13 @@ discard block |
||
| 207 | 207 | */ |
| 208 | 208 | public static function display_arrow($user_id) |
| 209 | 209 | { |
| 210 | - $start = (int)$_GET['start']; |
|
| 211 | - $nb_announcement = SystemAnnouncementManager :: count_nb_announcement($start,$user_id); |
|
| 212 | - $next = ((int)$_GET['start']+19); |
|
| 213 | - $prev = ((int)$_GET['start']-19); |
|
| 210 | + $start = (int) $_GET['start']; |
|
| 211 | + $nb_announcement = SystemAnnouncementManager :: count_nb_announcement($start, $user_id); |
|
| 212 | + $next = ((int) $_GET['start'] + 19); |
|
| 213 | + $prev = ((int) $_GET['start'] - 19); |
|
| 214 | 214 | $content = ''; |
| 215 | - if(!isset($_GET['start']) || $_GET['start'] == 0) { |
|
| 216 | - if($nb_announcement > 20) { |
|
| 215 | + if (!isset($_GET['start']) || $_GET['start'] == 0) { |
|
| 216 | + if ($nb_announcement > 20) { |
|
| 217 | 217 | $content .= '<a href="news_list.php?start='.$next.'">'.get_lang('NextBis').' >> </a>'; |
| 218 | 218 | } |
| 219 | 219 | } else { |
@@ -322,15 +322,15 @@ discard block |
||
| 322 | 322 | $sendEmailTest = false |
| 323 | 323 | ) { |
| 324 | 324 | $original_content = $content; |
| 325 | - $a_dateS = explode(' ',$date_start); |
|
| 326 | - $a_arraySD = explode('-',$a_dateS[0]); |
|
| 327 | - $a_arraySH = explode(':',$a_dateS[1]); |
|
| 328 | - $date_start_to_compare = array_merge($a_arraySD,$a_arraySH); |
|
| 325 | + $a_dateS = explode(' ', $date_start); |
|
| 326 | + $a_arraySD = explode('-', $a_dateS[0]); |
|
| 327 | + $a_arraySH = explode(':', $a_dateS[1]); |
|
| 328 | + $date_start_to_compare = array_merge($a_arraySD, $a_arraySH); |
|
| 329 | 329 | |
| 330 | - $a_dateE = explode(' ',$date_end); |
|
| 331 | - $a_arrayED = explode('-',$a_dateE[0]); |
|
| 332 | - $a_arrayEH = explode(':',$a_dateE[1]); |
|
| 333 | - $date_end_to_compare = array_merge($a_arrayED,$a_arrayEH); |
|
| 330 | + $a_dateE = explode(' ', $date_end); |
|
| 331 | + $a_arrayED = explode('-', $a_dateE[0]); |
|
| 332 | + $a_arrayEH = explode(':', $a_dateE[1]); |
|
| 333 | + $date_end_to_compare = array_merge($a_arrayED, $a_arrayEH); |
|
| 334 | 334 | |
| 335 | 335 | $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
| 336 | 336 | |
@@ -504,15 +504,15 @@ discard block |
||
| 504 | 504 | $send_mail = 0, |
| 505 | 505 | $sendEmailTest = false |
| 506 | 506 | ) { |
| 507 | - $a_dateS = explode(' ',$date_start); |
|
| 508 | - $a_arraySD = explode('-',$a_dateS[0]); |
|
| 509 | - $a_arraySH = explode(':',$a_dateS[1]); |
|
| 510 | - $date_start_to_compare = array_merge($a_arraySD,$a_arraySH); |
|
| 507 | + $a_dateS = explode(' ', $date_start); |
|
| 508 | + $a_arraySD = explode('-', $a_dateS[0]); |
|
| 509 | + $a_arraySH = explode(':', $a_dateS[1]); |
|
| 510 | + $date_start_to_compare = array_merge($a_arraySD, $a_arraySH); |
|
| 511 | 511 | |
| 512 | - $a_dateE = explode(' ',$date_end); |
|
| 513 | - $a_arrayED = explode('-',$a_dateE[0]); |
|
| 514 | - $a_arrayEH = explode(':',$a_dateE[1]); |
|
| 515 | - $date_end_to_compare = array_merge($a_arrayED,$a_arrayEH); |
|
| 512 | + $a_dateE = explode(' ', $date_end); |
|
| 513 | + $a_arrayED = explode('-', $a_dateE[0]); |
|
| 514 | + $a_arrayEH = explode(':', $a_dateE[1]); |
|
| 515 | + $date_end_to_compare = array_merge($a_arrayED, $a_arrayEH); |
|
| 516 | 516 | |
| 517 | 517 | $langsql = is_null($lang) ? 'NULL' : "'".Database::escape_string($lang)."'"; |
| 518 | 518 | $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
@@ -536,8 +536,8 @@ discard block |
||
| 536 | 536 | return false; |
| 537 | 537 | } |
| 538 | 538 | |
| 539 | - $start = api_get_utc_datetime($date_start); |
|
| 540 | - $end = api_get_utc_datetime($date_end); |
|
| 539 | + $start = api_get_utc_datetime($date_start); |
|
| 540 | + $end = api_get_utc_datetime($date_end); |
|
| 541 | 541 | |
| 542 | 542 | $title = Database::escape_string($title); |
| 543 | 543 | $content = Database::escape_string($content); |
@@ -560,7 +560,7 @@ discard block |
||
| 560 | 560 | $sendEmailTest |
| 561 | 561 | ); |
| 562 | 562 | } else { |
| 563 | - if ($send_mail==1) { |
|
| 563 | + if ($send_mail == 1) { |
|
| 564 | 564 | SystemAnnouncementManager::send_system_announcement_by_email( |
| 565 | 565 | $title, |
| 566 | 566 | $content, |
@@ -655,7 +655,7 @@ discard block |
||
| 655 | 655 | global $charset; |
| 656 | 656 | |
| 657 | 657 | $title = api_html_entity_decode(stripslashes($title), ENT_QUOTES, $charset); |
| 658 | - $content = api_html_entity_decode(stripslashes(str_replace(array('\r\n', '\n', '\r'),'', $content)), ENT_QUOTES, $charset); |
|
| 658 | + $content = api_html_entity_decode(stripslashes(str_replace(array('\r\n', '\n', '\r'), '', $content)), ENT_QUOTES, $charset); |
|
| 659 | 659 | $now = api_get_utc_datetime(); |
| 660 | 660 | |
| 661 | 661 | if ($sendEmailTest) { |
@@ -678,7 +678,7 @@ discard block |
||
| 678 | 678 | $sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE status = '5' "; |
| 679 | 679 | } |
| 680 | 680 | |
| 681 | - if ($teacher<> 0 AND $student <> 0) { |
|
| 681 | + if ($teacher <> 0 AND $student <> 0) { |
|
| 682 | 682 | $sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE 1 = 1 "; |
| 683 | 683 | } |
| 684 | 684 | |
@@ -696,7 +696,7 @@ discard block |
||
| 696 | 696 | // Expiration date |
| 697 | 697 | $sql .= " AND (expiration_date = '' OR expiration_date IS NULL OR expiration_date > '$now') "; |
| 698 | 698 | |
| 699 | - if ((empty($teacher) or $teacher == '0') AND (empty($student) or $student == '0')) { |
|
| 699 | + if ((empty($teacher) or $teacher == '0') AND (empty($student) or $student == '0')) { |
|
| 700 | 700 | return true; |
| 701 | 701 | } |
| 702 | 702 | |
@@ -707,7 +707,7 @@ discard block |
||
| 707 | 707 | |
| 708 | 708 | $message_sent = false; |
| 709 | 709 | |
| 710 | - while ($row = Database::fetch_array($result,'ASSOC')) { |
|
| 710 | + while ($row = Database::fetch_array($result, 'ASSOC')) { |
|
| 711 | 711 | MessageManager::send_message_simple($row['user_id'], $title, $content); |
| 712 | 712 | $message_sent = true; |
| 713 | 713 | } |
@@ -727,7 +727,7 @@ discard block |
||
| 727 | 727 | $cut_size = 500; |
| 728 | 728 | $now = api_get_utc_datetime(); |
| 729 | 729 | |
| 730 | - $sql = "SELECT * FROM " . $table . " |
|
| 730 | + $sql = "SELECT * FROM ".$table." |
|
| 731 | 731 | WHERE |
| 732 | 732 | (lang = '$user_selected_language' OR lang = '') AND |
| 733 | 733 | ('$now' >= date_start AND '$now' <= date_end) "; |
@@ -10,17 +10,17 @@ discard block |
||
| 10 | 10 | CONST VISIBLE_STUDENT = 2; |
| 11 | 11 | CONST VISIBLE_TEACHER = 3; |
| 12 | 12 | |
| 13 | - /** |
|
| 14 | - * Displays all announcements |
|
| 15 | - * @param int $visible VISIBLE_GUEST, VISIBLE_STUDENT or VISIBLE_TEACHER |
|
| 16 | - * @param int $id The identifier of the announcement to display |
|
| 17 | - */ |
|
| 18 | - public static function display_announcements($visible, $id = -1) |
|
| 13 | + /** |
|
| 14 | + * Displays all announcements |
|
| 15 | + * @param int $visible VISIBLE_GUEST, VISIBLE_STUDENT or VISIBLE_TEACHER |
|
| 16 | + * @param int $id The identifier of the announcement to display |
|
| 17 | + */ |
|
| 18 | + public static function display_announcements($visible, $id = -1) |
|
| 19 | 19 | { |
| 20 | - $user_selected_language = api_get_interface_language(); |
|
| 21 | - $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
| 20 | + $user_selected_language = api_get_interface_language(); |
|
| 21 | + $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
| 22 | 22 | $tbl_announcement_group = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS_GROUPS); |
| 23 | - $userGroup = new UserGroup(); |
|
| 23 | + $userGroup = new UserGroup(); |
|
| 24 | 24 | |
| 25 | 25 | $temp_user_groups = $userGroup->get_groups_by_user(api_get_user_id(),0); |
| 26 | 26 | $groups = array(); |
@@ -55,47 +55,47 @@ discard block |
||
| 55 | 55 | WHERE group_id in $groups_string |
| 56 | 56 | ) "; |
| 57 | 57 | } |
| 58 | - $current_access_url_id = 1; |
|
| 59 | - if (api_is_multiple_url_enabled()) { |
|
| 60 | - $current_access_url_id = api_get_current_access_url_id(); |
|
| 61 | - } |
|
| 62 | - $sql .= " AND access_url_id = '$current_access_url_id' "; |
|
| 63 | - $sql .= " ORDER BY date_start DESC LIMIT 0,7"; |
|
| 64 | - |
|
| 65 | - $announcements = Database::query($sql); |
|
| 66 | - if (Database::num_rows($announcements) > 0) { |
|
| 67 | - $query_string = ereg_replace('announcement=[1-9]+', '', $_SERVER['QUERY_STRING']); |
|
| 68 | - $query_string = ereg_replace('&$', '', $query_string); |
|
| 69 | - $url = api_get_self(); |
|
| 70 | - echo '<div class="system_announcements">'; |
|
| 71 | - echo '<h3>'.get_lang('SystemAnnouncements').'</h3>'; |
|
| 72 | - echo '<div style="margin:10px;text-align:right;"><a href="news_list.php">'.get_lang('More').'</a></div>'; |
|
| 73 | - |
|
| 74 | - while ($announcement = Database::fetch_object($announcements)) { |
|
| 75 | - if ($id != $announcement->id) { |
|
| 76 | - if (strlen($query_string) > 0) { |
|
| 77 | - $show_url = 'news_list.php#'.$announcement->id; |
|
| 78 | - } else { |
|
| 79 | - $show_url = 'news_list.php#'.$announcement->id; |
|
| 80 | - } |
|
| 81 | - $display_date = api_convert_and_format_date($announcement->display_date, DATE_FORMAT_LONG); |
|
| 82 | - echo '<a name="'.$announcement->id.'"></a> |
|
| 58 | + $current_access_url_id = 1; |
|
| 59 | + if (api_is_multiple_url_enabled()) { |
|
| 60 | + $current_access_url_id = api_get_current_access_url_id(); |
|
| 61 | + } |
|
| 62 | + $sql .= " AND access_url_id = '$current_access_url_id' "; |
|
| 63 | + $sql .= " ORDER BY date_start DESC LIMIT 0,7"; |
|
| 64 | + |
|
| 65 | + $announcements = Database::query($sql); |
|
| 66 | + if (Database::num_rows($announcements) > 0) { |
|
| 67 | + $query_string = ereg_replace('announcement=[1-9]+', '', $_SERVER['QUERY_STRING']); |
|
| 68 | + $query_string = ereg_replace('&$', '', $query_string); |
|
| 69 | + $url = api_get_self(); |
|
| 70 | + echo '<div class="system_announcements">'; |
|
| 71 | + echo '<h3>'.get_lang('SystemAnnouncements').'</h3>'; |
|
| 72 | + echo '<div style="margin:10px;text-align:right;"><a href="news_list.php">'.get_lang('More').'</a></div>'; |
|
| 73 | + |
|
| 74 | + while ($announcement = Database::fetch_object($announcements)) { |
|
| 75 | + if ($id != $announcement->id) { |
|
| 76 | + if (strlen($query_string) > 0) { |
|
| 77 | + $show_url = 'news_list.php#'.$announcement->id; |
|
| 78 | + } else { |
|
| 79 | + $show_url = 'news_list.php#'.$announcement->id; |
|
| 80 | + } |
|
| 81 | + $display_date = api_convert_and_format_date($announcement->display_date, DATE_FORMAT_LONG); |
|
| 82 | + echo '<a name="'.$announcement->id.'"></a> |
|
| 83 | 83 | <div class="system_announcement"> |
| 84 | 84 | <div class="system_announcement_title"><a name="ann'.$announcement->id.'" href="'.$show_url.'">'.$announcement->title.'</a></div><div class="system_announcement_date">'.$display_date.'</div> |
| 85 | 85 | </div>'; |
| 86 | - } else { |
|
| 87 | - echo '<div class="system_announcement"> |
|
| 86 | + } else { |
|
| 87 | + echo '<div class="system_announcement"> |
|
| 88 | 88 | <div class="system_announcement_title">' |
| 89 | - .$announcement->display_date.' |
|
| 89 | + .$announcement->display_date.' |
|
| 90 | 90 | <a name="ann'.$announcement->id.'" href="'.$url.'?'.$query_string.'#ann'.$announcement->id.'">'.$announcement->title.'</a> |
| 91 | 91 | </div>'; |
| 92 | - } |
|
| 93 | - echo '<br />'; |
|
| 94 | - } |
|
| 95 | - echo '</div>'; |
|
| 96 | - } |
|
| 97 | - return; |
|
| 98 | - } |
|
| 92 | + } |
|
| 93 | + echo '<br />'; |
|
| 94 | + } |
|
| 95 | + echo '</div>'; |
|
| 96 | + } |
|
| 97 | + return; |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | 100 | /** |
| 101 | 101 | * @param $visible |
@@ -106,100 +106,100 @@ discard block |
||
| 106 | 106 | */ |
| 107 | 107 | public static function display_all_announcements($visible, $id = -1, $start = 0,$user_id='') |
| 108 | 108 | { |
| 109 | - $user_selected_language = api_get_interface_language(); |
|
| 110 | - $start = intval($start); |
|
| 109 | + $user_selected_language = api_get_interface_language(); |
|
| 110 | + $start = intval($start); |
|
| 111 | 111 | $userGroup = new UserGroup(); |
| 112 | - $tbl_announcement_group = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS_GROUPS); |
|
| 113 | - $temp_user_groups = $userGroup->get_groups_by_user(api_get_user_id(),0); |
|
| 112 | + $tbl_announcement_group = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS_GROUPS); |
|
| 113 | + $temp_user_groups = $userGroup->get_groups_by_user(api_get_user_id(),0); |
|
| 114 | 114 | $groups = array(); |
| 115 | - foreach ($temp_user_groups as $user_group) { |
|
| 116 | - $groups = array_merge($groups, array($user_group['id'])); |
|
| 117 | - $groups = array_merge($groups, $userGroup->get_parent_groups($user_group['id'])); |
|
| 118 | - } |
|
| 115 | + foreach ($temp_user_groups as $user_group) { |
|
| 116 | + $groups = array_merge($groups, array($user_group['id'])); |
|
| 117 | + $groups = array_merge($groups, $userGroup->get_parent_groups($user_group['id'])); |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | - // Checks if tables exists to not break platform not updated |
|
| 121 | - $groups_string = '('.implode($groups,',').')'; |
|
| 120 | + // Checks if tables exists to not break platform not updated |
|
| 121 | + $groups_string = '('.implode($groups,',').')'; |
|
| 122 | 122 | |
| 123 | - $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
| 124 | - $now = api_get_utc_datetime(); |
|
| 123 | + $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
| 124 | + $now = api_get_utc_datetime(); |
|
| 125 | 125 | |
| 126 | - $sql = "SELECT * FROM ".$db_table." |
|
| 126 | + $sql = "SELECT * FROM ".$db_table." |
|
| 127 | 127 | WHERE |
| 128 | 128 | (lang = '$user_selected_language' OR lang IS NULL) AND |
| 129 | 129 | ( '$now' >= date_start AND '$now' <= date_end) "; |
| 130 | 130 | |
| 131 | - switch ($visible) { |
|
| 132 | - case self::VISIBLE_GUEST : |
|
| 133 | - $sql .= " AND visible_guest = 1 "; |
|
| 134 | - break; |
|
| 135 | - case self::VISIBLE_STUDENT : |
|
| 136 | - $sql .= " AND visible_student = 1 "; |
|
| 137 | - break; |
|
| 138 | - case self::VISIBLE_TEACHER : |
|
| 139 | - $sql .= " AND visible_teacher = 1 "; |
|
| 140 | - break; |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - if (count($groups) > 0) { |
|
| 131 | + switch ($visible) { |
|
| 132 | + case self::VISIBLE_GUEST : |
|
| 133 | + $sql .= " AND visible_guest = 1 "; |
|
| 134 | + break; |
|
| 135 | + case self::VISIBLE_STUDENT : |
|
| 136 | + $sql .= " AND visible_student = 1 "; |
|
| 137 | + break; |
|
| 138 | + case self::VISIBLE_TEACHER : |
|
| 139 | + $sql .= " AND visible_teacher = 1 "; |
|
| 140 | + break; |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + if (count($groups) > 0) { |
|
| 144 | 144 | $sql .= " OR id IN ( |
| 145 | 145 | SELECT announcement_id FROM $tbl_announcement_group |
| 146 | 146 | WHERE group_id in $groups_string |
| 147 | 147 | ) "; |
| 148 | - } |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | - if (api_is_multiple_url_enabled()) { |
|
| 151 | - $current_access_url_id = api_get_current_access_url_id(); |
|
| 150 | + if (api_is_multiple_url_enabled()) { |
|
| 151 | + $current_access_url_id = api_get_current_access_url_id(); |
|
| 152 | 152 | $sql .= " AND access_url_id IN ('1', '$current_access_url_id')"; |
| 153 | - } |
|
| 154 | - |
|
| 155 | - if(!isset($_GET['start']) || $_GET['start'] == 0) { |
|
| 156 | - $sql .= " ORDER BY date_start DESC LIMIT ".$start.",20"; |
|
| 157 | - } else { |
|
| 158 | - $sql .= " ORDER BY date_start DESC LIMIT ".($start+1).",20"; |
|
| 159 | - } |
|
| 160 | - $announcements = Database::query($sql); |
|
| 161 | - $content = ''; |
|
| 162 | - if (Database::num_rows($announcements) > 0) { |
|
| 163 | - $query_string = ereg_replace('announcement=[1-9]+', '', $_SERVER['QUERY_STRING']); |
|
| 164 | - $query_string = ereg_replace('&$', '', $query_string); |
|
| 165 | - $url = api_get_self(); |
|
| 166 | - $content .= '<div class="system_announcements">'; |
|
| 167 | - $content .= '<h3>'.get_lang('SystemAnnouncements').'</h3>'; |
|
| 168 | - $content .= '<table align="center">'; |
|
| 169 | - $content .= '<tr>'; |
|
| 170 | - $content .= '<td>'; |
|
| 171 | - $content .= SystemAnnouncementManager :: display_arrow($user_id); |
|
| 172 | - $content .= '</td>'; |
|
| 173 | - $content .= '</tr>'; |
|
| 174 | - $content .= '</table>'; |
|
| 175 | - $content .= '<table align="center" border="0" width="900px">'; |
|
| 176 | - while ($announcement = Database::fetch_object($announcements)) { |
|
| 177 | - $display_date = api_convert_and_format_date($announcement->display_date, DATE_FORMAT_LONG); |
|
| 178 | - $content .= '<tr><td>'; |
|
| 179 | - $content .= '<a name="'.$announcement->id.'"></a> |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + if(!isset($_GET['start']) || $_GET['start'] == 0) { |
|
| 156 | + $sql .= " ORDER BY date_start DESC LIMIT ".$start.",20"; |
|
| 157 | + } else { |
|
| 158 | + $sql .= " ORDER BY date_start DESC LIMIT ".($start+1).",20"; |
|
| 159 | + } |
|
| 160 | + $announcements = Database::query($sql); |
|
| 161 | + $content = ''; |
|
| 162 | + if (Database::num_rows($announcements) > 0) { |
|
| 163 | + $query_string = ereg_replace('announcement=[1-9]+', '', $_SERVER['QUERY_STRING']); |
|
| 164 | + $query_string = ereg_replace('&$', '', $query_string); |
|
| 165 | + $url = api_get_self(); |
|
| 166 | + $content .= '<div class="system_announcements">'; |
|
| 167 | + $content .= '<h3>'.get_lang('SystemAnnouncements').'</h3>'; |
|
| 168 | + $content .= '<table align="center">'; |
|
| 169 | + $content .= '<tr>'; |
|
| 170 | + $content .= '<td>'; |
|
| 171 | + $content .= SystemAnnouncementManager :: display_arrow($user_id); |
|
| 172 | + $content .= '</td>'; |
|
| 173 | + $content .= '</tr>'; |
|
| 174 | + $content .= '</table>'; |
|
| 175 | + $content .= '<table align="center" border="0" width="900px">'; |
|
| 176 | + while ($announcement = Database::fetch_object($announcements)) { |
|
| 177 | + $display_date = api_convert_and_format_date($announcement->display_date, DATE_FORMAT_LONG); |
|
| 178 | + $content .= '<tr><td>'; |
|
| 179 | + $content .= '<a name="'.$announcement->id.'"></a> |
|
| 180 | 180 | <div class="system_announcement"> |
| 181 | 181 | <h2>'.$announcement->title.'</h2><div class="system_announcement_date">'.$display_date.'</div> |
| 182 | 182 | <br /> |
| 183 | 183 | <div class="system_announcement_content">' |
| 184 | - .$announcement->content.' |
|
| 184 | + .$announcement->content.' |
|
| 185 | 185 | </div> |
| 186 | 186 | </div><br />'; |
| 187 | - $content .= '</tr></td>'; |
|
| 188 | - } |
|
| 189 | - $content .= '</table>'; |
|
| 190 | - |
|
| 191 | - $content .= '<table align="center">'; |
|
| 192 | - $content .= '<tr>'; |
|
| 193 | - $content .= '<td>'; |
|
| 194 | - $content .= SystemAnnouncementManager :: display_arrow($user_id); |
|
| 195 | - $content .= '</td>'; |
|
| 196 | - $content .= '</tr>'; |
|
| 197 | - $content .= '</table>'; |
|
| 198 | - $content .= '</div>'; |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - return $content; |
|
| 202 | - } |
|
| 187 | + $content .= '</tr></td>'; |
|
| 188 | + } |
|
| 189 | + $content .= '</table>'; |
|
| 190 | + |
|
| 191 | + $content .= '<table align="center">'; |
|
| 192 | + $content .= '<tr>'; |
|
| 193 | + $content .= '<td>'; |
|
| 194 | + $content .= SystemAnnouncementManager :: display_arrow($user_id); |
|
| 195 | + $content .= '</td>'; |
|
| 196 | + $content .= '</tr>'; |
|
| 197 | + $content .= '</table>'; |
|
| 198 | + $content .= '</div>'; |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + return $content; |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | 204 | /** |
| 205 | 205 | * @param int $user_id |
@@ -207,23 +207,23 @@ discard block |
||
| 207 | 207 | */ |
| 208 | 208 | public static function display_arrow($user_id) |
| 209 | 209 | { |
| 210 | - $start = (int)$_GET['start']; |
|
| 211 | - $nb_announcement = SystemAnnouncementManager :: count_nb_announcement($start,$user_id); |
|
| 212 | - $next = ((int)$_GET['start']+19); |
|
| 213 | - $prev = ((int)$_GET['start']-19); |
|
| 214 | - $content = ''; |
|
| 215 | - if(!isset($_GET['start']) || $_GET['start'] == 0) { |
|
| 216 | - if($nb_announcement > 20) { |
|
| 217 | - $content .= '<a href="news_list.php?start='.$next.'">'.get_lang('NextBis').' >> </a>'; |
|
| 218 | - } |
|
| 219 | - } else { |
|
| 220 | - echo '<a href="news_list.php?start='.$prev.'"> << '.get_lang('Prev').'</a>'; |
|
| 221 | - if ($nb_announcement > 20) { |
|
| 222 | - $content .= '<a href="news_list.php?start='.$next.'">'.get_lang('NextBis').' >> </a>'; |
|
| 223 | - } |
|
| 224 | - } |
|
| 225 | - return $content; |
|
| 226 | - } |
|
| 210 | + $start = (int)$_GET['start']; |
|
| 211 | + $nb_announcement = SystemAnnouncementManager :: count_nb_announcement($start,$user_id); |
|
| 212 | + $next = ((int)$_GET['start']+19); |
|
| 213 | + $prev = ((int)$_GET['start']-19); |
|
| 214 | + $content = ''; |
|
| 215 | + if(!isset($_GET['start']) || $_GET['start'] == 0) { |
|
| 216 | + if($nb_announcement > 20) { |
|
| 217 | + $content .= '<a href="news_list.php?start='.$next.'">'.get_lang('NextBis').' >> </a>'; |
|
| 218 | + } |
|
| 219 | + } else { |
|
| 220 | + echo '<a href="news_list.php?start='.$prev.'"> << '.get_lang('Prev').'</a>'; |
|
| 221 | + if ($nb_announcement > 20) { |
|
| 222 | + $content .= '<a href="news_list.php?start='.$next.'">'.get_lang('NextBis').' >> </a>'; |
|
| 223 | + } |
|
| 224 | + } |
|
| 225 | + return $content; |
|
| 226 | + } |
|
| 227 | 227 | |
| 228 | 228 | /** |
| 229 | 229 | * @param int $start |
@@ -232,82 +232,82 @@ discard block |
||
| 232 | 232 | */ |
| 233 | 233 | public static function count_nb_announcement($start = 0, $user_id = '') |
| 234 | 234 | { |
| 235 | - $start = intval($start); |
|
| 236 | - $visibility = api_is_allowed_to_create_course() ? self::VISIBLE_TEACHER : self::VISIBLE_STUDENT; |
|
| 237 | - $user_selected_language = api_get_interface_language(); |
|
| 238 | - $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
| 239 | - $sql = 'SELECT id FROM '.$db_table.' |
|
| 235 | + $start = intval($start); |
|
| 236 | + $visibility = api_is_allowed_to_create_course() ? self::VISIBLE_TEACHER : self::VISIBLE_STUDENT; |
|
| 237 | + $user_selected_language = api_get_interface_language(); |
|
| 238 | + $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
| 239 | + $sql = 'SELECT id FROM '.$db_table.' |
|
| 240 | 240 | WHERE (lang="'.$user_selected_language.'" OR lang IS NULL) '; |
| 241 | - if (isset($user_id)) { |
|
| 242 | - switch ($visibility) { |
|
| 243 | - case self::VISIBLE_GUEST : |
|
| 244 | - $sql .= " AND visible_guest = 1 "; |
|
| 245 | - break; |
|
| 246 | - case self::VISIBLE_STUDENT : |
|
| 247 | - $sql .= " AND visible_student = 1 "; |
|
| 248 | - break; |
|
| 249 | - case self::VISIBLE_TEACHER : |
|
| 250 | - $sql .= " AND visible_teacher = 1 "; |
|
| 251 | - break; |
|
| 252 | - } |
|
| 253 | - } |
|
| 254 | - |
|
| 255 | - $current_access_url_id = 1; |
|
| 256 | - if (api_is_multiple_url_enabled()) { |
|
| 257 | - $current_access_url_id = api_get_current_access_url_id(); |
|
| 258 | - } |
|
| 259 | - $sql .= " AND access_url_id = '$current_access_url_id' "; |
|
| 260 | - |
|
| 261 | - |
|
| 262 | - $sql .= 'LIMIT '.$start.', 21'; |
|
| 263 | - $announcements = Database::query($sql); |
|
| 264 | - $i = 0; |
|
| 265 | - while ($rows = Database::fetch_array($announcements)) { |
|
| 266 | - $i++; |
|
| 267 | - } |
|
| 268 | - return $i; |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - /** |
|
| 272 | - * Get all announcements |
|
| 273 | - * @return array An array with all available system announcements (as php |
|
| 274 | - * objects) |
|
| 275 | - */ |
|
| 276 | - public static function get_all_announcements() |
|
| 241 | + if (isset($user_id)) { |
|
| 242 | + switch ($visibility) { |
|
| 243 | + case self::VISIBLE_GUEST : |
|
| 244 | + $sql .= " AND visible_guest = 1 "; |
|
| 245 | + break; |
|
| 246 | + case self::VISIBLE_STUDENT : |
|
| 247 | + $sql .= " AND visible_student = 1 "; |
|
| 248 | + break; |
|
| 249 | + case self::VISIBLE_TEACHER : |
|
| 250 | + $sql .= " AND visible_teacher = 1 "; |
|
| 251 | + break; |
|
| 252 | + } |
|
| 253 | + } |
|
| 254 | + |
|
| 255 | + $current_access_url_id = 1; |
|
| 256 | + if (api_is_multiple_url_enabled()) { |
|
| 257 | + $current_access_url_id = api_get_current_access_url_id(); |
|
| 258 | + } |
|
| 259 | + $sql .= " AND access_url_id = '$current_access_url_id' "; |
|
| 260 | + |
|
| 261 | + |
|
| 262 | + $sql .= 'LIMIT '.$start.', 21'; |
|
| 263 | + $announcements = Database::query($sql); |
|
| 264 | + $i = 0; |
|
| 265 | + while ($rows = Database::fetch_array($announcements)) { |
|
| 266 | + $i++; |
|
| 267 | + } |
|
| 268 | + return $i; |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + /** |
|
| 272 | + * Get all announcements |
|
| 273 | + * @return array An array with all available system announcements (as php |
|
| 274 | + * objects) |
|
| 275 | + */ |
|
| 276 | + public static function get_all_announcements() |
|
| 277 | 277 | { |
| 278 | - $table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
| 279 | - $now = api_get_utc_datetime(); |
|
| 280 | - $sql = "SELECT *, IF ( '$now' >= date_start AND '$now' <= date_end, '1', '0') AS visible |
|
| 278 | + $table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
| 279 | + $now = api_get_utc_datetime(); |
|
| 280 | + $sql = "SELECT *, IF ( '$now' >= date_start AND '$now' <= date_end, '1', '0') AS visible |
|
| 281 | 281 | FROM $table"; |
| 282 | 282 | |
| 283 | - $current_access_url_id = 1; |
|
| 284 | - if (api_is_multiple_url_enabled()) { |
|
| 285 | - $current_access_url_id = api_get_current_access_url_id(); |
|
| 286 | - } |
|
| 287 | - $sql .= " WHERE access_url_id = '$current_access_url_id' "; |
|
| 288 | - $sql .= " ORDER BY date_start ASC"; |
|
| 289 | - |
|
| 290 | - $announcements = Database::query($sql); |
|
| 291 | - $all_announcements = array(); |
|
| 292 | - while ($announcement = Database::fetch_object($announcements)) { |
|
| 293 | - $all_announcements[] = $announcement; |
|
| 294 | - } |
|
| 295 | - return $all_announcements; |
|
| 296 | - } |
|
| 297 | - |
|
| 298 | - /** |
|
| 299 | - * Adds an announcement to the database |
|
| 300 | - * @param string Title of the announcement |
|
| 301 | - * @param string Content of the announcement |
|
| 302 | - * @param string Start date (YYYY-MM-DD HH:II: SS) |
|
| 303 | - * @param string End date (YYYY-MM-DD HH:II: SS) |
|
| 304 | - * @param int Whether the announcement should be visible to teachers (1) or not (0) |
|
| 305 | - * @param int Whether the announcement should be visible to students (1) or not (0) |
|
| 306 | - * @param int Whether the announcement should be visible to anonymous users (1) or not (0) |
|
| 307 | - * @param string The language for which the announvement should be shown. Leave null for all langages |
|
| 308 | - * @param int Whether to send an e-mail to all users (1) or not (0) |
|
| 309 | - * @return mixed insert_id on success, false on failure |
|
| 310 | - */ |
|
| 283 | + $current_access_url_id = 1; |
|
| 284 | + if (api_is_multiple_url_enabled()) { |
|
| 285 | + $current_access_url_id = api_get_current_access_url_id(); |
|
| 286 | + } |
|
| 287 | + $sql .= " WHERE access_url_id = '$current_access_url_id' "; |
|
| 288 | + $sql .= " ORDER BY date_start ASC"; |
|
| 289 | + |
|
| 290 | + $announcements = Database::query($sql); |
|
| 291 | + $all_announcements = array(); |
|
| 292 | + while ($announcement = Database::fetch_object($announcements)) { |
|
| 293 | + $all_announcements[] = $announcement; |
|
| 294 | + } |
|
| 295 | + return $all_announcements; |
|
| 296 | + } |
|
| 297 | + |
|
| 298 | + /** |
|
| 299 | + * Adds an announcement to the database |
|
| 300 | + * @param string Title of the announcement |
|
| 301 | + * @param string Content of the announcement |
|
| 302 | + * @param string Start date (YYYY-MM-DD HH:II: SS) |
|
| 303 | + * @param string End date (YYYY-MM-DD HH:II: SS) |
|
| 304 | + * @param int Whether the announcement should be visible to teachers (1) or not (0) |
|
| 305 | + * @param int Whether the announcement should be visible to students (1) or not (0) |
|
| 306 | + * @param int Whether the announcement should be visible to anonymous users (1) or not (0) |
|
| 307 | + * @param string The language for which the announvement should be shown. Leave null for all langages |
|
| 308 | + * @param int Whether to send an e-mail to all users (1) or not (0) |
|
| 309 | + * @return mixed insert_id on success, false on failure |
|
| 310 | + */ |
|
| 311 | 311 | public static function add_announcement( |
| 312 | 312 | $title, |
| 313 | 313 | $content, |
@@ -321,112 +321,112 @@ discard block |
||
| 321 | 321 | $add_to_calendar = false, |
| 322 | 322 | $sendEmailTest = false |
| 323 | 323 | ) { |
| 324 | - $original_content = $content; |
|
| 325 | - $a_dateS = explode(' ',$date_start); |
|
| 326 | - $a_arraySD = explode('-',$a_dateS[0]); |
|
| 327 | - $a_arraySH = explode(':',$a_dateS[1]); |
|
| 328 | - $date_start_to_compare = array_merge($a_arraySD,$a_arraySH); |
|
| 324 | + $original_content = $content; |
|
| 325 | + $a_dateS = explode(' ',$date_start); |
|
| 326 | + $a_arraySD = explode('-',$a_dateS[0]); |
|
| 327 | + $a_arraySH = explode(':',$a_dateS[1]); |
|
| 328 | + $date_start_to_compare = array_merge($a_arraySD,$a_arraySH); |
|
| 329 | 329 | |
| 330 | - $a_dateE = explode(' ',$date_end); |
|
| 331 | - $a_arrayED = explode('-',$a_dateE[0]); |
|
| 332 | - $a_arrayEH = explode(':',$a_dateE[1]); |
|
| 333 | - $date_end_to_compare = array_merge($a_arrayED,$a_arrayEH); |
|
| 330 | + $a_dateE = explode(' ',$date_end); |
|
| 331 | + $a_arrayED = explode('-',$a_dateE[0]); |
|
| 332 | + $a_arrayEH = explode(':',$a_dateE[1]); |
|
| 333 | + $date_end_to_compare = array_merge($a_arrayED,$a_arrayEH); |
|
| 334 | 334 | |
| 335 | - $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
| 335 | + $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
| 336 | 336 | |
| 337 | - if (!checkdate($date_start_to_compare[1], $date_start_to_compare[2], $date_start_to_compare[0])) { |
|
| 338 | - Display :: display_normal_message(get_lang('InvalidStartDate')); |
|
| 339 | - return false; |
|
| 340 | - } |
|
| 337 | + if (!checkdate($date_start_to_compare[1], $date_start_to_compare[2], $date_start_to_compare[0])) { |
|
| 338 | + Display :: display_normal_message(get_lang('InvalidStartDate')); |
|
| 339 | + return false; |
|
| 340 | + } |
|
| 341 | 341 | |
| 342 | - if (($date_end_to_compare[1] || |
|
| 342 | + if (($date_end_to_compare[1] || |
|
| 343 | 343 | $date_end_to_compare[2] || |
| 344 | 344 | $date_end_to_compare[0]) && |
| 345 | 345 | !checkdate($date_end_to_compare[1], $date_end_to_compare[2], $date_end_to_compare[0]) |
| 346 | 346 | ) { |
| 347 | - Display :: display_normal_message(get_lang('InvalidEndDate')); |
|
| 348 | - return false; |
|
| 349 | - } |
|
| 350 | - if (strlen(trim($title)) == 0) { |
|
| 351 | - Display::display_normal_message(get_lang('InvalidTitle')); |
|
| 352 | - return false; |
|
| 353 | - } |
|
| 354 | - |
|
| 355 | - $start = api_get_utc_datetime($date_start); |
|
| 347 | + Display :: display_normal_message(get_lang('InvalidEndDate')); |
|
| 348 | + return false; |
|
| 349 | + } |
|
| 350 | + if (strlen(trim($title)) == 0) { |
|
| 351 | + Display::display_normal_message(get_lang('InvalidTitle')); |
|
| 352 | + return false; |
|
| 353 | + } |
|
| 354 | + |
|
| 355 | + $start = api_get_utc_datetime($date_start); |
|
| 356 | 356 | $end = api_get_utc_datetime($date_end); |
| 357 | 357 | |
| 358 | - //Fixing urls that are sent by email |
|
| 359 | - $content = str_replace('src=\"/home/', 'src=\"'.api_get_path(WEB_PATH).'home/', $content); |
|
| 360 | - $content = str_replace('file=/home/', 'file='.api_get_path(WEB_PATH).'home/', $content); |
|
| 358 | + //Fixing urls that are sent by email |
|
| 359 | + $content = str_replace('src=\"/home/', 'src=\"'.api_get_path(WEB_PATH).'home/', $content); |
|
| 360 | + $content = str_replace('file=/home/', 'file='.api_get_path(WEB_PATH).'home/', $content); |
|
| 361 | 361 | |
| 362 | 362 | $lang = is_null($lang) ? '' : $lang; |
| 363 | 363 | |
| 364 | - $current_access_url_id = 1; |
|
| 365 | - if (api_is_multiple_url_enabled()) { |
|
| 366 | - $current_access_url_id = api_get_current_access_url_id(); |
|
| 367 | - } |
|
| 368 | - |
|
| 369 | - $params = [ |
|
| 370 | - 'title' => $title, |
|
| 371 | - 'content' => $content, |
|
| 372 | - 'date_start' => $start, |
|
| 373 | - 'date_end' => $end, |
|
| 374 | - 'visible_teacher' => $visible_teacher, |
|
| 375 | - 'visible_student' => $visible_student, |
|
| 376 | - 'visible_guest' => $visible_guest, |
|
| 377 | - 'lang' => $lang, |
|
| 378 | - 'access_url_id' => $current_access_url_id, |
|
| 379 | - ]; |
|
| 380 | - |
|
| 381 | - $resultId = Database::insert($db_table, $params); |
|
| 382 | - |
|
| 383 | - if ($resultId) { |
|
| 384 | - |
|
| 385 | - if ($sendEmailTest) { |
|
| 386 | - SystemAnnouncementManager::send_system_announcement_by_email( |
|
| 387 | - $title, |
|
| 388 | - $content, |
|
| 389 | - $visible_teacher, |
|
| 390 | - $visible_student, |
|
| 391 | - $lang, |
|
| 392 | - true |
|
| 393 | - ); |
|
| 394 | - } else { |
|
| 395 | - if ($send_mail == 1) { |
|
| 396 | - SystemAnnouncementManager::send_system_announcement_by_email( |
|
| 397 | - $title, |
|
| 398 | - $content, |
|
| 399 | - $visible_teacher, |
|
| 400 | - $visible_student, |
|
| 401 | - $lang |
|
| 402 | - ); |
|
| 403 | - } |
|
| 404 | - } |
|
| 405 | - |
|
| 406 | - if ($add_to_calendar) { |
|
| 407 | - $agenda = new Agenda(); |
|
| 408 | - $agenda->setType('admin'); |
|
| 409 | - $agenda->addEvent( |
|
| 410 | - $date_start, |
|
| 411 | - $date_end, |
|
| 412 | - false, |
|
| 413 | - $title, |
|
| 414 | - $original_content |
|
| 415 | - ); |
|
| 416 | - } |
|
| 417 | - |
|
| 418 | - return $resultId; |
|
| 419 | - |
|
| 420 | - } |
|
| 421 | - |
|
| 422 | - return false; |
|
| 423 | - } |
|
| 364 | + $current_access_url_id = 1; |
|
| 365 | + if (api_is_multiple_url_enabled()) { |
|
| 366 | + $current_access_url_id = api_get_current_access_url_id(); |
|
| 367 | + } |
|
| 368 | + |
|
| 369 | + $params = [ |
|
| 370 | + 'title' => $title, |
|
| 371 | + 'content' => $content, |
|
| 372 | + 'date_start' => $start, |
|
| 373 | + 'date_end' => $end, |
|
| 374 | + 'visible_teacher' => $visible_teacher, |
|
| 375 | + 'visible_student' => $visible_student, |
|
| 376 | + 'visible_guest' => $visible_guest, |
|
| 377 | + 'lang' => $lang, |
|
| 378 | + 'access_url_id' => $current_access_url_id, |
|
| 379 | + ]; |
|
| 380 | + |
|
| 381 | + $resultId = Database::insert($db_table, $params); |
|
| 382 | + |
|
| 383 | + if ($resultId) { |
|
| 384 | + |
|
| 385 | + if ($sendEmailTest) { |
|
| 386 | + SystemAnnouncementManager::send_system_announcement_by_email( |
|
| 387 | + $title, |
|
| 388 | + $content, |
|
| 389 | + $visible_teacher, |
|
| 390 | + $visible_student, |
|
| 391 | + $lang, |
|
| 392 | + true |
|
| 393 | + ); |
|
| 394 | + } else { |
|
| 395 | + if ($send_mail == 1) { |
|
| 396 | + SystemAnnouncementManager::send_system_announcement_by_email( |
|
| 397 | + $title, |
|
| 398 | + $content, |
|
| 399 | + $visible_teacher, |
|
| 400 | + $visible_student, |
|
| 401 | + $lang |
|
| 402 | + ); |
|
| 403 | + } |
|
| 404 | + } |
|
| 405 | + |
|
| 406 | + if ($add_to_calendar) { |
|
| 407 | + $agenda = new Agenda(); |
|
| 408 | + $agenda->setType('admin'); |
|
| 409 | + $agenda->addEvent( |
|
| 410 | + $date_start, |
|
| 411 | + $date_end, |
|
| 412 | + false, |
|
| 413 | + $title, |
|
| 414 | + $original_content |
|
| 415 | + ); |
|
| 416 | + } |
|
| 417 | + |
|
| 418 | + return $resultId; |
|
| 419 | + |
|
| 420 | + } |
|
| 421 | + |
|
| 422 | + return false; |
|
| 423 | + } |
|
| 424 | 424 | |
| 425 | 425 | /** |
| 426 | - * Makes the announcement id visible only for groups in groups_array |
|
| 427 | - * @param int announcement id |
|
| 428 | - * @param array array of group id |
|
| 429 | - **/ |
|
| 426 | + * Makes the announcement id visible only for groups in groups_array |
|
| 427 | + * @param int announcement id |
|
| 428 | + * @param array array of group id |
|
| 429 | + **/ |
|
| 430 | 430 | public static function announcement_for_groups($announcement_id, $group_array) |
| 431 | 431 | { |
| 432 | 432 | $tbl_announcement_group = Database:: get_main_table( |
@@ -460,10 +460,10 @@ discard block |
||
| 460 | 460 | } |
| 461 | 461 | |
| 462 | 462 | /** |
| 463 | - * Gets the groups of this announce |
|
| 464 | - * @param int announcement id |
|
| 465 | - * @return array array of group id |
|
| 466 | - **/ |
|
| 463 | + * Gets the groups of this announce |
|
| 464 | + * @param int announcement id |
|
| 465 | + * @return array array of group id |
|
| 466 | + **/ |
|
| 467 | 467 | public static function get_announcement_groups($announcement_id) |
| 468 | 468 | { |
| 469 | 469 | $tbl_announcement_group = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS_GROUPS); |
@@ -482,15 +482,15 @@ discard block |
||
| 482 | 482 | return $groups; |
| 483 | 483 | } |
| 484 | 484 | |
| 485 | - /** |
|
| 486 | - * Updates an announcement to the database |
|
| 487 | - * @param integer $id : id of the announcement |
|
| 488 | - * @param string $title : title of the announcement |
|
| 489 | - * @param string $content : content of the announcement |
|
| 490 | - * @param array $date_start: start date of announcement (0 => day ; 1 => month ; 2 => year ; 3 => hour ; 4 => minute) |
|
| 491 | - * @param array $date_end : end date of announcement (0 => day ; 1 => month ; 2 => year ; 3 => hour ; 4 => minute) |
|
| 492 | - * @return bool True on success, false on failure |
|
| 493 | - */ |
|
| 485 | + /** |
|
| 486 | + * Updates an announcement to the database |
|
| 487 | + * @param integer $id : id of the announcement |
|
| 488 | + * @param string $title : title of the announcement |
|
| 489 | + * @param string $content : content of the announcement |
|
| 490 | + * @param array $date_start: start date of announcement (0 => day ; 1 => month ; 2 => year ; 3 => hour ; 4 => minute) |
|
| 491 | + * @param array $date_end : end date of announcement (0 => day ; 1 => month ; 2 => year ; 3 => hour ; 4 => minute) |
|
| 492 | + * @return bool True on success, false on failure |
|
| 493 | + */ |
|
| 494 | 494 | public static function update_announcement( |
| 495 | 495 | $id, |
| 496 | 496 | $title, |
@@ -506,43 +506,43 @@ discard block |
||
| 506 | 506 | ) { |
| 507 | 507 | $em = Database::getManager(); |
| 508 | 508 | |
| 509 | - $a_dateS = explode(' ',$date_start); |
|
| 510 | - $a_arraySD = explode('-',$a_dateS[0]); |
|
| 511 | - $a_arraySH = explode(':',$a_dateS[1]); |
|
| 512 | - $date_start_to_compare = array_merge($a_arraySD,$a_arraySH); |
|
| 509 | + $a_dateS = explode(' ',$date_start); |
|
| 510 | + $a_arraySD = explode('-',$a_dateS[0]); |
|
| 511 | + $a_arraySH = explode(':',$a_dateS[1]); |
|
| 512 | + $date_start_to_compare = array_merge($a_arraySD,$a_arraySH); |
|
| 513 | 513 | |
| 514 | - $a_dateE = explode(' ',$date_end); |
|
| 515 | - $a_arrayED = explode('-',$a_dateE[0]); |
|
| 516 | - $a_arrayEH = explode(':',$a_dateE[1]); |
|
| 517 | - $date_end_to_compare = array_merge($a_arrayED,$a_arrayEH); |
|
| 514 | + $a_dateE = explode(' ',$date_end); |
|
| 515 | + $a_arrayED = explode('-',$a_dateE[0]); |
|
| 516 | + $a_arrayEH = explode(':',$a_dateE[1]); |
|
| 517 | + $date_end_to_compare = array_merge($a_arrayED,$a_arrayEH); |
|
| 518 | 518 | |
| 519 | 519 | $lang = is_null($lang) ? '' : $lang; |
| 520 | 520 | |
| 521 | - if (!checkdate($date_start_to_compare[1], $date_start_to_compare[2], $date_start_to_compare[0])) { |
|
| 522 | - Display :: display_normal_message(get_lang('InvalidStartDate')); |
|
| 523 | - return false; |
|
| 524 | - } |
|
| 521 | + if (!checkdate($date_start_to_compare[1], $date_start_to_compare[2], $date_start_to_compare[0])) { |
|
| 522 | + Display :: display_normal_message(get_lang('InvalidStartDate')); |
|
| 523 | + return false; |
|
| 524 | + } |
|
| 525 | 525 | |
| 526 | - if (($date_end_to_compare[1] || |
|
| 526 | + if (($date_end_to_compare[1] || |
|
| 527 | 527 | $date_end_to_compare[2] || |
| 528 | 528 | $date_end_to_compare[0]) && |
| 529 | 529 | !checkdate($date_end_to_compare[1], $date_end_to_compare[2], $date_end_to_compare[0]) |
| 530 | 530 | ) { |
| 531 | - Display :: display_normal_message(get_lang('InvalidEndDate')); |
|
| 532 | - return false; |
|
| 533 | - } |
|
| 531 | + Display :: display_normal_message(get_lang('InvalidEndDate')); |
|
| 532 | + return false; |
|
| 533 | + } |
|
| 534 | 534 | |
| 535 | - if (strlen(trim($title)) == 0) { |
|
| 536 | - Display::display_normal_message(get_lang('InvalidTitle')); |
|
| 537 | - return false; |
|
| 538 | - } |
|
| 535 | + if (strlen(trim($title)) == 0) { |
|
| 536 | + Display::display_normal_message(get_lang('InvalidTitle')); |
|
| 537 | + return false; |
|
| 538 | + } |
|
| 539 | 539 | |
| 540 | - $start = api_get_utc_datetime($date_start); |
|
| 540 | + $start = api_get_utc_datetime($date_start); |
|
| 541 | 541 | $end = api_get_utc_datetime($date_end); |
| 542 | 542 | |
| 543 | - //Fixing urls that are sent by email |
|
| 544 | - $content = str_replace('src=\"/home/', 'src=\"'.api_get_path(WEB_PATH).'home/', $content); |
|
| 545 | - $content = str_replace('file=/home/', 'file='.api_get_path(WEB_PATH).'home/', $content); |
|
| 543 | + //Fixing urls that are sent by email |
|
| 544 | + $content = str_replace('src=\"/home/', 'src=\"'.api_get_path(WEB_PATH).'home/', $content); |
|
| 545 | + $content = str_replace('file=/home/', 'file='.api_get_path(WEB_PATH).'home/', $content); |
|
| 546 | 546 | |
| 547 | 547 | $id = intval($id); |
| 548 | 548 | |
@@ -591,84 +591,84 @@ discard block |
||
| 591 | 591 | $em->merge($announcement); |
| 592 | 592 | $em->flush(); |
| 593 | 593 | |
| 594 | - return true; |
|
| 595 | - } |
|
| 594 | + return true; |
|
| 595 | + } |
|
| 596 | 596 | |
| 597 | - /** |
|
| 598 | - * Deletes an announcement |
|
| 599 | - * @param int $id The identifier of the announcement that should be |
|
| 600 | - * @return bool True on success, false on failure |
|
| 601 | - */ |
|
| 602 | - public static function delete_announcement($id) |
|
| 597 | + /** |
|
| 598 | + * Deletes an announcement |
|
| 599 | + * @param int $id The identifier of the announcement that should be |
|
| 600 | + * @return bool True on success, false on failure |
|
| 601 | + */ |
|
| 602 | + public static function delete_announcement($id) |
|
| 603 | 603 | { |
| 604 | - $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
| 605 | - $id = intval($id); |
|
| 606 | - $sql = "DELETE FROM ".$db_table." WHERE id =".$id; |
|
| 607 | - $res = Database::query($sql); |
|
| 608 | - if ($res === false) { |
|
| 609 | - |
|
| 610 | - return false; |
|
| 611 | - } |
|
| 612 | - return true; |
|
| 613 | - } |
|
| 614 | - |
|
| 615 | - /** |
|
| 616 | - * Gets an announcement |
|
| 617 | - * @param int $id The identifier of the announcement that should be |
|
| 618 | - * @return object Object of class StdClass or the required class, containing the query result row |
|
| 619 | - */ |
|
| 620 | - public static function get_announcement($id) |
|
| 604 | + $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
| 605 | + $id = intval($id); |
|
| 606 | + $sql = "DELETE FROM ".$db_table." WHERE id =".$id; |
|
| 607 | + $res = Database::query($sql); |
|
| 608 | + if ($res === false) { |
|
| 609 | + |
|
| 610 | + return false; |
|
| 611 | + } |
|
| 612 | + return true; |
|
| 613 | + } |
|
| 614 | + |
|
| 615 | + /** |
|
| 616 | + * Gets an announcement |
|
| 617 | + * @param int $id The identifier of the announcement that should be |
|
| 618 | + * @return object Object of class StdClass or the required class, containing the query result row |
|
| 619 | + */ |
|
| 620 | + public static function get_announcement($id) |
|
| 621 | 621 | { |
| 622 | - $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
| 623 | - $id = intval($id); |
|
| 624 | - $sql = "SELECT * FROM ".$db_table." WHERE id = ".$id; |
|
| 625 | - $announcement = Database::fetch_object(Database::query($sql)); |
|
| 626 | - |
|
| 627 | - return $announcement; |
|
| 628 | - } |
|
| 629 | - |
|
| 630 | - /** |
|
| 631 | - * Change the visibility of an announcement |
|
| 632 | - * @param int $announcement_id |
|
| 633 | - * @param int $user For who should the visibility be changed |
|
| 622 | + $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
| 623 | + $id = intval($id); |
|
| 624 | + $sql = "SELECT * FROM ".$db_table." WHERE id = ".$id; |
|
| 625 | + $announcement = Database::fetch_object(Database::query($sql)); |
|
| 626 | + |
|
| 627 | + return $announcement; |
|
| 628 | + } |
|
| 629 | + |
|
| 630 | + /** |
|
| 631 | + * Change the visibility of an announcement |
|
| 632 | + * @param int $announcement_id |
|
| 633 | + * @param int $user For who should the visibility be changed |
|
| 634 | 634 | * (possible values are VISIBLE_TEACHER, VISIBLE_STUDENT, VISIBLE_GUEST) |
| 635 | - * @return bool True on success, false on failure |
|
| 636 | - */ |
|
| 637 | - public static function set_visibility($announcement_id, $user, $visible) |
|
| 635 | + * @return bool True on success, false on failure |
|
| 636 | + */ |
|
| 637 | + public static function set_visibility($announcement_id, $user, $visible) |
|
| 638 | 638 | { |
| 639 | - $db_table = Database::get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
| 640 | - $visible = intval($visible); |
|
| 641 | - $announcement_id = intval($announcement_id); |
|
| 639 | + $db_table = Database::get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
| 640 | + $visible = intval($visible); |
|
| 641 | + $announcement_id = intval($announcement_id); |
|
| 642 | 642 | |
| 643 | 643 | if (!in_array($user, array(self::VISIBLE_GUEST, self::VISIBLE_STUDENT, self::VISIBLE_TEACHER))) { |
| 644 | 644 | return false; |
| 645 | 645 | } |
| 646 | 646 | |
| 647 | - $field = ($user == self::VISIBLE_TEACHER ? 'visible_teacher' : ($user == self::VISIBLE_STUDENT ? 'visible_student' : 'visible_guest')); |
|
| 647 | + $field = ($user == self::VISIBLE_TEACHER ? 'visible_teacher' : ($user == self::VISIBLE_STUDENT ? 'visible_student' : 'visible_guest')); |
|
| 648 | 648 | |
| 649 | - $sql = "UPDATE ".$db_table." SET ".$field." = '".$visible."' |
|
| 649 | + $sql = "UPDATE ".$db_table." SET ".$field." = '".$visible."' |
|
| 650 | 650 | WHERE id='".$announcement_id."'"; |
| 651 | - $res = Database::query($sql); |
|
| 652 | - |
|
| 653 | - if ($res === false) { |
|
| 654 | - return false; |
|
| 655 | - } |
|
| 656 | - |
|
| 657 | - return true; |
|
| 658 | - } |
|
| 659 | - |
|
| 660 | - /** |
|
| 661 | - * Send a system announcement by e-mail to all teachers/students depending on parameters |
|
| 662 | - * @param string Title |
|
| 663 | - * @param string Content |
|
| 664 | - * @param int Whether to send to all teachers (1) or not (0) |
|
| 665 | - * @param int Whether to send to all students (1) or not (0) |
|
| 666 | - * @param string Language (optional, considered for all languages if left empty) |
|
| 651 | + $res = Database::query($sql); |
|
| 652 | + |
|
| 653 | + if ($res === false) { |
|
| 654 | + return false; |
|
| 655 | + } |
|
| 656 | + |
|
| 657 | + return true; |
|
| 658 | + } |
|
| 659 | + |
|
| 660 | + /** |
|
| 661 | + * Send a system announcement by e-mail to all teachers/students depending on parameters |
|
| 662 | + * @param string Title |
|
| 663 | + * @param string Content |
|
| 664 | + * @param int Whether to send to all teachers (1) or not (0) |
|
| 665 | + * @param int Whether to send to all students (1) or not (0) |
|
| 666 | + * @param string Language (optional, considered for all languages if left empty) |
|
| 667 | 667 | * @return bool True if the message was sent or there was no destination matching. False on database or e-mail sending error. |
| 668 | - */ |
|
| 669 | - public static function send_system_announcement_by_email($title, $content, $teacher, $student, $language = null, $sendEmailTest = false) |
|
| 668 | + */ |
|
| 669 | + public static function send_system_announcement_by_email($title, $content, $teacher, $student, $language = null, $sendEmailTest = false) |
|
| 670 | 670 | { |
| 671 | - global $charset; |
|
| 671 | + global $charset; |
|
| 672 | 672 | |
| 673 | 673 | $title = api_html_entity_decode(stripslashes($title), ENT_QUOTES, $charset); |
| 674 | 674 | $content = api_html_entity_decode(stripslashes(str_replace(array('\r\n', '\n', '\r'),'', $content)), ENT_QUOTES, $charset); |
@@ -687,22 +687,22 @@ discard block |
||
| 687 | 687 | } |
| 688 | 688 | |
| 689 | 689 | if ($teacher <> 0 AND $student == 0) { |
| 690 | - $sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE status = '1' "; |
|
| 691 | - } |
|
| 690 | + $sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE status = '1' "; |
|
| 691 | + } |
|
| 692 | 692 | |
| 693 | - if ($teacher == 0 AND $student <> 0) { |
|
| 694 | - $sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE status = '5' "; |
|
| 695 | - } |
|
| 693 | + if ($teacher == 0 AND $student <> 0) { |
|
| 694 | + $sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE status = '5' "; |
|
| 695 | + } |
|
| 696 | 696 | |
| 697 | - if ($teacher<> 0 AND $student <> 0) { |
|
| 698 | - $sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE 1 = 1 "; |
|
| 699 | - } |
|
| 697 | + if ($teacher<> 0 AND $student <> 0) { |
|
| 698 | + $sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE 1 = 1 "; |
|
| 699 | + } |
|
| 700 | 700 | |
| 701 | - if (!empty($language)) { //special condition because language was already treated for SQL insert before |
|
| 702 | - $sql .= " AND language = '".Database::escape_string($language)."' "; |
|
| 703 | - } |
|
| 701 | + if (!empty($language)) { //special condition because language was already treated for SQL insert before |
|
| 702 | + $sql .= " AND language = '".Database::escape_string($language)."' "; |
|
| 703 | + } |
|
| 704 | 704 | |
| 705 | - if (api_is_multiple_url_enabled()) { |
|
| 705 | + if (api_is_multiple_url_enabled()) { |
|
| 706 | 706 | $sql .= " AND access_url_id = '".$current_access_url_id."' "; |
| 707 | 707 | } |
| 708 | 708 | |
@@ -712,25 +712,25 @@ discard block |
||
| 712 | 712 | // Expiration date |
| 713 | 713 | $sql .= " AND (expiration_date = '' OR expiration_date IS NULL OR expiration_date > '$now') "; |
| 714 | 714 | |
| 715 | - if ((empty($teacher) or $teacher == '0') AND (empty($student) or $student == '0')) { |
|
| 716 | - return true; |
|
| 717 | - } |
|
| 715 | + if ((empty($teacher) or $teacher == '0') AND (empty($student) or $student == '0')) { |
|
| 716 | + return true; |
|
| 717 | + } |
|
| 718 | 718 | |
| 719 | - $result = Database::query($sql); |
|
| 720 | - if ($result === false) { |
|
| 721 | - return false; |
|
| 722 | - } |
|
| 719 | + $result = Database::query($sql); |
|
| 720 | + if ($result === false) { |
|
| 721 | + return false; |
|
| 722 | + } |
|
| 723 | 723 | |
| 724 | 724 | $message_sent = false; |
| 725 | 725 | |
| 726 | - while ($row = Database::fetch_array($result,'ASSOC')) { |
|
| 726 | + while ($row = Database::fetch_array($result,'ASSOC')) { |
|
| 727 | 727 | MessageManager::send_message_simple($row['user_id'], $title, $content); |
| 728 | 728 | $message_sent = true; |
| 729 | - } |
|
| 730 | - return $message_sent; //true if at least one e-mail was sent |
|
| 731 | - } |
|
| 729 | + } |
|
| 730 | + return $message_sent; //true if at least one e-mail was sent |
|
| 731 | + } |
|
| 732 | 732 | |
| 733 | - /** |
|
| 733 | + /** |
|
| 734 | 734 | * Displays announcements as an slideshow |
| 735 | 735 | * @param int $visible VISIBLE_GUEST, VISIBLE_STUDENT or VISIBLE_TEACHER |
| 736 | 736 | * @param int $id The identifier of the announcement to display |
@@ -80,7 +80,7 @@ |
||
| 80 | 80 | * @param string $direction The direction to sort (SORT_ASC (default) orSORT_DESC) |
| 81 | 81 | * @param array $column_show The columns that we will show in the table i.e: $column_show = array('1','0','1') we will show the 1st and the 3th column. |
| 82 | 82 | * @param array $column_order Changes how the columns will be sorted ie. $column_order = array('0','3','2','3') The column [1] will be sorted like the column [3] |
| 83 | - * @param constant $type How should data be sorted (SORT_REGULAR, SORT_NUMERIC, SORT_STRING, SORT_DATE, SORT_IMAGE) |
|
| 83 | + * @param integer $type How should data be sorted (SORT_REGULAR, SORT_NUMERIC, SORT_STRING, SORT_DATE, SORT_IMAGE) |
|
| 84 | 84 | * @return array The sorted dataset |
| 85 | 85 | * @author [email protected] |
| 86 | 86 | */ |
@@ -1,10 +1,10 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /* For licensing terms, see /license.txt */ |
| 3 | 3 | /** |
| 4 | - * This is a library with some functions to sort tabular data |
|
| 5 | - * |
|
| 6 | - * @package chamilo.library |
|
| 7 | - */ |
|
| 4 | + * This is a library with some functions to sort tabular data |
|
| 5 | + * |
|
| 6 | + * @package chamilo.library |
|
| 7 | + */ |
|
| 8 | 8 | |
| 9 | 9 | define('SORT_DATE', 3); |
| 10 | 10 | define('SORT_IMAGE', 4); |
@@ -15,16 +15,16 @@ discard block |
||
| 15 | 15 | class TableSort |
| 16 | 16 | { |
| 17 | 17 | /** |
| 18 | - * Sorts 2-dimensional table. |
|
| 19 | - * @param array $data The data to be sorted. |
|
| 20 | - * @param int $column The column on which the data should be sorted (default = 0) |
|
| 21 | - * @param int $direction The direction to sort (SORT_ASC (default) or SORT_DESC) |
|
| 22 | - * @param int $type How should data be sorted (SORT_REGULAR, SORT_NUMERIC, |
|
| 23 | - * SORT_STRING,SORT_DATE,SORT_IMAGE) |
|
| 24 | - * @return array The sorted dataset |
|
| 25 | - * @author [email protected] |
|
| 26 | - */ |
|
| 27 | - public static function sort_table($data, $column = 0, $direction = SORT_ASC, $type = SORT_REGULAR) |
|
| 18 | + * Sorts 2-dimensional table. |
|
| 19 | + * @param array $data The data to be sorted. |
|
| 20 | + * @param int $column The column on which the data should be sorted (default = 0) |
|
| 21 | + * @param int $direction The direction to sort (SORT_ASC (default) or SORT_DESC) |
|
| 22 | + * @param int $type How should data be sorted (SORT_REGULAR, SORT_NUMERIC, |
|
| 23 | + * SORT_STRING,SORT_DATE,SORT_IMAGE) |
|
| 24 | + * @return array The sorted dataset |
|
| 25 | + * @author [email protected] |
|
| 26 | + */ |
|
| 27 | + public static function sort_table($data, $column = 0, $direction = SORT_ASC, $type = SORT_REGULAR) |
|
| 28 | 28 | { |
| 29 | 29 | if (!is_array($data) || empty($data)) { |
| 30 | 30 | return array(); |
@@ -71,20 +71,20 @@ discard block |
||
| 71 | 71 | usort($data, create_function('$a, $b', $compare_function)); |
| 72 | 72 | |
| 73 | 73 | return $data; |
| 74 | - } |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * Sorts 2-dimensional table. It is possile changing the columns that will be shown and the way that the columns are to be sorted. |
|
| 78 | - * @param array $data The data to be sorted. |
|
| 79 | - * @param int $column The column on which the data should be sorted (default = 0) |
|
| 80 | - * @param string $direction The direction to sort (SORT_ASC (default) orSORT_DESC) |
|
| 81 | - * @param array $column_show The columns that we will show in the table i.e: $column_show = array('1','0','1') we will show the 1st and the 3th column. |
|
| 82 | - * @param array $column_order Changes how the columns will be sorted ie. $column_order = array('0','3','2','3') The column [1] will be sorted like the column [3] |
|
| 83 | - * @param constant $type How should data be sorted (SORT_REGULAR, SORT_NUMERIC, SORT_STRING, SORT_DATE, SORT_IMAGE) |
|
| 84 | - * @return array The sorted dataset |
|
| 85 | - * @author [email protected] |
|
| 86 | - */ |
|
| 87 | - public static function sort_table_config( |
|
| 76 | + /** |
|
| 77 | + * Sorts 2-dimensional table. It is possile changing the columns that will be shown and the way that the columns are to be sorted. |
|
| 78 | + * @param array $data The data to be sorted. |
|
| 79 | + * @param int $column The column on which the data should be sorted (default = 0) |
|
| 80 | + * @param string $direction The direction to sort (SORT_ASC (default) orSORT_DESC) |
|
| 81 | + * @param array $column_show The columns that we will show in the table i.e: $column_show = array('1','0','1') we will show the 1st and the 3th column. |
|
| 82 | + * @param array $column_order Changes how the columns will be sorted ie. $column_order = array('0','3','2','3') The column [1] will be sorted like the column [3] |
|
| 83 | + * @param constant $type How should data be sorted (SORT_REGULAR, SORT_NUMERIC, SORT_STRING, SORT_DATE, SORT_IMAGE) |
|
| 84 | + * @return array The sorted dataset |
|
| 85 | + * @author [email protected] |
|
| 86 | + */ |
|
| 87 | + public static function sort_table_config( |
|
| 88 | 88 | $data, |
| 89 | 89 | $column = 0, |
| 90 | 90 | $direction = SORT_ASC, |
@@ -132,9 +132,9 @@ discard block |
||
| 132 | 132 | if (!empty($data)) { |
| 133 | 133 | foreach ($data as $document) { |
| 134 | 134 | if ($document['type'] == 'folder') { |
| 135 | - $docs_to_sort[$document['id']] = api_strtolower($document['name']); |
|
| 135 | + $docs_to_sort[$document['id']] = api_strtolower($document['name']); |
|
| 136 | 136 | } else { |
| 137 | - $folder_to_sort[$document['id']] = api_strtolower($document['name']); |
|
| 137 | + $folder_to_sort[$document['id']] = api_strtolower($document['name']); |
|
| 138 | 138 | } |
| 139 | 139 | $new_data[$document['id']] = $document; |
| 140 | 140 | } |
@@ -196,91 +196,91 @@ discard block |
||
| 196 | 196 | usort($data, create_function('$a, $b', $compare_function)); |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | - if (is_array($column_show) && !empty($column_show)) { |
|
| 199 | + if (is_array($column_show) && !empty($column_show)) { |
|
| 200 | 200 | |
| 201 | - // We show only the columns data that were set up on the $column_show array |
|
| 202 | - $new_order_data = array(); |
|
| 203 | - $count_data = count($data); |
|
| 204 | - $count_column_show = count($column_show); |
|
| 205 | - for ($j = 0; $j < $count_data; $j++) { |
|
| 206 | - $k = 0; |
|
| 207 | - for ($i = 0; $i < $count_column_show; $i++) { |
|
| 208 | - if ($column_show[$i]) { |
|
| 209 | - $new_order_data[$j][$k] = $data[$j][$i]; |
|
| 210 | - } |
|
| 211 | - $k++; |
|
| 212 | - } |
|
| 213 | - } |
|
| 214 | - // Replace the multi-arrays |
|
| 215 | - $data = $new_order_data; |
|
| 216 | - } |
|
| 201 | + // We show only the columns data that were set up on the $column_show array |
|
| 202 | + $new_order_data = array(); |
|
| 203 | + $count_data = count($data); |
|
| 204 | + $count_column_show = count($column_show); |
|
| 205 | + for ($j = 0; $j < $count_data; $j++) { |
|
| 206 | + $k = 0; |
|
| 207 | + for ($i = 0; $i < $count_column_show; $i++) { |
|
| 208 | + if ($column_show[$i]) { |
|
| 209 | + $new_order_data[$j][$k] = $data[$j][$i]; |
|
| 210 | + } |
|
| 211 | + $k++; |
|
| 212 | + } |
|
| 213 | + } |
|
| 214 | + // Replace the multi-arrays |
|
| 215 | + $data = $new_order_data; |
|
| 216 | + } |
|
| 217 | 217 | |
| 218 | - return $data; |
|
| 219 | - } |
|
| 218 | + return $data; |
|
| 219 | + } |
|
| 220 | 220 | |
| 221 | - /** |
|
| 222 | - * Checks whether a column of a 2D-array contains only numeric values |
|
| 223 | - * @param array $data The data-array |
|
| 224 | - * @param int $column The index of the column to check |
|
| 225 | - * @return bool TRUE if column contains only dates, FALSE otherwise |
|
| 226 | - * @todo Take locale into account (eg decimal point or comma ?) |
|
| 227 | - * @author [email protected] |
|
| 228 | - */ |
|
| 229 | - private static function is_numeric_column(& $data, $column) |
|
| 221 | + /** |
|
| 222 | + * Checks whether a column of a 2D-array contains only numeric values |
|
| 223 | + * @param array $data The data-array |
|
| 224 | + * @param int $column The index of the column to check |
|
| 225 | + * @return bool TRUE if column contains only dates, FALSE otherwise |
|
| 226 | + * @todo Take locale into account (eg decimal point or comma ?) |
|
| 227 | + * @author [email protected] |
|
| 228 | + */ |
|
| 229 | + private static function is_numeric_column(& $data, $column) |
|
| 230 | 230 | { |
| 231 | - $is_numeric = true; |
|
| 232 | - foreach ($data as $index => & $row) { |
|
| 233 | - $is_numeric &= is_numeric(strip_tags($row[$column])); |
|
| 234 | - if (!$is_numeric) { |
|
| 235 | - break; |
|
| 236 | - } |
|
| 237 | - } |
|
| 238 | - return $is_numeric; |
|
| 239 | - } |
|
| 231 | + $is_numeric = true; |
|
| 232 | + foreach ($data as $index => & $row) { |
|
| 233 | + $is_numeric &= is_numeric(strip_tags($row[$column])); |
|
| 234 | + if (!$is_numeric) { |
|
| 235 | + break; |
|
| 236 | + } |
|
| 237 | + } |
|
| 238 | + return $is_numeric; |
|
| 239 | + } |
|
| 240 | 240 | |
| 241 | - /** |
|
| 242 | - * Checks whether a column of a 2D-array contains only dates (GNU date syntax) |
|
| 243 | - * @param array $data The data-array |
|
| 244 | - * @param int $column The index of the column to check |
|
| 245 | - * @return bool TRUE if column contains only dates, FALSE otherwise |
|
| 246 | - * @author [email protected] |
|
| 247 | - */ |
|
| 248 | - private static function is_date_column(& $data, $column) |
|
| 241 | + /** |
|
| 242 | + * Checks whether a column of a 2D-array contains only dates (GNU date syntax) |
|
| 243 | + * @param array $data The data-array |
|
| 244 | + * @param int $column The index of the column to check |
|
| 245 | + * @return bool TRUE if column contains only dates, FALSE otherwise |
|
| 246 | + * @author [email protected] |
|
| 247 | + */ |
|
| 248 | + private static function is_date_column(& $data, $column) |
|
| 249 | 249 | { |
| 250 | - $is_date = true; |
|
| 251 | - foreach ($data as $index => & $row) { |
|
| 252 | - if (strlen(strip_tags($row[$column])) != 0) { |
|
| 253 | - $check_date = strtotime(strip_tags($row[$column])); |
|
| 254 | - // strtotime Returns a timestamp on success, FALSE otherwise. |
|
| 255 | - // Previous to PHP 5.1.0, this function would return -1 on failure. |
|
| 256 | - $is_date &= ($check_date != -1 && $check_date); |
|
| 257 | - } else { |
|
| 258 | - $is_date &= false; |
|
| 259 | - } |
|
| 260 | - if (!$is_date) { |
|
| 261 | - break; |
|
| 262 | - } |
|
| 263 | - } |
|
| 264 | - return $is_date; |
|
| 265 | - } |
|
| 250 | + $is_date = true; |
|
| 251 | + foreach ($data as $index => & $row) { |
|
| 252 | + if (strlen(strip_tags($row[$column])) != 0) { |
|
| 253 | + $check_date = strtotime(strip_tags($row[$column])); |
|
| 254 | + // strtotime Returns a timestamp on success, FALSE otherwise. |
|
| 255 | + // Previous to PHP 5.1.0, this function would return -1 on failure. |
|
| 256 | + $is_date &= ($check_date != -1 && $check_date); |
|
| 257 | + } else { |
|
| 258 | + $is_date &= false; |
|
| 259 | + } |
|
| 260 | + if (!$is_date) { |
|
| 261 | + break; |
|
| 262 | + } |
|
| 263 | + } |
|
| 264 | + return $is_date; |
|
| 265 | + } |
|
| 266 | 266 | |
| 267 | - /** |
|
| 268 | - * Checks whether a column of a 2D-array contains only images (<img src="path/file.ext" alt=".."/>) |
|
| 269 | - * @param array $data The data-array |
|
| 270 | - * @param int $column The index of the column to check |
|
| 271 | - * @return bool TRUE if column contains only images, FALSE otherwise |
|
| 272 | - * @author [email protected] |
|
| 273 | - */ |
|
| 274 | - private static function is_image_column(& $data, $column) |
|
| 267 | + /** |
|
| 268 | + * Checks whether a column of a 2D-array contains only images (<img src="path/file.ext" alt=".."/>) |
|
| 269 | + * @param array $data The data-array |
|
| 270 | + * @param int $column The index of the column to check |
|
| 271 | + * @return bool TRUE if column contains only images, FALSE otherwise |
|
| 272 | + * @author [email protected] |
|
| 273 | + */ |
|
| 274 | + private static function is_image_column(& $data, $column) |
|
| 275 | 275 | { |
| 276 | - $is_image = true; |
|
| 277 | - foreach ($data as $index => & $row) { |
|
| 278 | - $is_image &= strlen(trim(strip_tags($row[$column], '<img>'))) > 0; // at least one img-tag |
|
| 279 | - $is_image &= strlen(trim(strip_tags($row[$column]))) == 0; // and no text outside attribute-values |
|
| 280 | - if (!$is_image) { |
|
| 281 | - break; |
|
| 282 | - } |
|
| 283 | - } |
|
| 284 | - return $is_image; |
|
| 285 | - } |
|
| 276 | + $is_image = true; |
|
| 277 | + foreach ($data as $index => & $row) { |
|
| 278 | + $is_image &= strlen(trim(strip_tags($row[$column], '<img>'))) > 0; // at least one img-tag |
|
| 279 | + $is_image &= strlen(trim(strip_tags($row[$column]))) == 0; // and no text outside attribute-values |
|
| 280 | + if (!$is_image) { |
|
| 281 | + break; |
|
| 282 | + } |
|
| 283 | + } |
|
| 284 | + return $is_image; |
|
| 285 | + } |
|
| 286 | 286 | } |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | |
| 158 | 158 | $new_data_order = array(); |
| 159 | 159 | if (!empty($docs_to_sort)) { |
| 160 | - foreach($docs_to_sort as $id => $document) { |
|
| 160 | + foreach ($docs_to_sort as $id => $document) { |
|
| 161 | 161 | if (isset($new_data[$id])) { |
| 162 | 162 | $new_data_order[] = $new_data[$id]; |
| 163 | 163 | } |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | if (!empty($folder_to_sort)) { |
| 168 | - foreach($folder_to_sort as $id => $document) { |
|
| 168 | + foreach ($folder_to_sort as $id => $document) { |
|
| 169 | 169 | if (isset($new_data[$id])) { |
| 170 | 170 | $new_data_order[] = $new_data[$id]; |
| 171 | 171 | } |
@@ -330,6 +330,7 @@ discard block |
||
| 330 | 330 | /** |
| 331 | 331 | * Sets the footer visibility |
| 332 | 332 | * @param bool true if we show the footer |
| 333 | + * @param boolean $status |
|
| 333 | 334 | */ |
| 334 | 335 | public function set_footer($status) |
| 335 | 336 | { |
@@ -370,6 +371,7 @@ discard block |
||
| 370 | 371 | /** |
| 371 | 372 | * Sets the header visibility |
| 372 | 373 | * @param bool true if we show the header |
| 374 | + * @param boolean $status |
|
| 373 | 375 | */ |
| 374 | 376 | public function set_header($status) |
| 375 | 377 | { |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | $content = '<li class="help">'; |
| 265 | 265 | $content .= Display::url( |
| 266 | 266 | Display::return_icon('help.large.png', get_lang('Help')), |
| 267 | - api_get_path(WEB_CODE_PATH) . 'help/help.php?open=' . $help, |
|
| 267 | + api_get_path(WEB_CODE_PATH).'help/help.php?open='.$help, |
|
| 268 | 268 | [ |
| 269 | 269 | 'class' => 'ajax', |
| 270 | 270 | 'data-title' => get_lang('Help') |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | 'web_course' => api_get_path(WEB_COURSE_PATH), |
| 479 | 479 | 'web_main' => api_get_path(WEB_CODE_PATH), |
| 480 | 480 | 'web_css' => api_get_path(WEB_CSS_PATH), |
| 481 | - 'web_css_theme' => api_get_path(WEB_CSS_PATH) . 'themes/' . $this->theme . '/', |
|
| 481 | + 'web_css_theme' => api_get_path(WEB_CSS_PATH).'themes/'.$this->theme.'/', |
|
| 482 | 482 | 'web_ajax' => api_get_path(WEB_AJAX_PATH), |
| 483 | 483 | 'web_img' => api_get_path(WEB_IMG_PATH), |
| 484 | 484 | 'web_plugin' => api_get_path(WEB_PLUGIN_PATH), |
@@ -536,12 +536,12 @@ discard block |
||
| 536 | 536 | foreach ($bowerCSSFiles as $file) { |
| 537 | 537 | $css[] = api_get_path(WEB_PATH).'web/assets/'.$file; |
| 538 | 538 | } |
| 539 | - $css[] = api_get_path(WEB_LIBRARY_PATH) . 'javascript/bootstrap-select/css/bootstrap-select.min.css'; |
|
| 540 | - $css[] = api_get_path(WEB_LIBRARY_PATH) . 'javascript/chosen/chosen.css'; |
|
| 541 | - $css[] = api_get_path(WEB_LIBRARY_PATH) . 'javascript/tag/style.css'; |
|
| 539 | + $css[] = api_get_path(WEB_LIBRARY_PATH).'javascript/bootstrap-select/css/bootstrap-select.min.css'; |
|
| 540 | + $css[] = api_get_path(WEB_LIBRARY_PATH).'javascript/chosen/chosen.css'; |
|
| 541 | + $css[] = api_get_path(WEB_LIBRARY_PATH).'javascript/tag/style.css'; |
|
| 542 | 542 | |
| 543 | 543 | if (api_is_global_chat_enabled()) { |
| 544 | - $css[] = api_get_path(WEB_LIBRARY_PATH) . 'javascript/chat/css/chat.css'; |
|
| 544 | + $css[] = api_get_path(WEB_LIBRARY_PATH).'javascript/chat/css/chat.css'; |
|
| 545 | 545 | } |
| 546 | 546 | |
| 547 | 547 | //THEME CSS STYLE |
@@ -608,7 +608,7 @@ discard block |
||
| 608 | 608 | |
| 609 | 609 | $style_print = ''; |
| 610 | 610 | if (is_readable(api_get_path(SYS_CSS_PATH).$this->theme.'/print.css')) { |
| 611 | - $style_print = api_get_css(api_get_cdn_path(api_get_path(WEB_CSS_PATH) . $this->theme . '/print.css'), |
|
| 611 | + $style_print = api_get_css(api_get_cdn_path(api_get_path(WEB_CSS_PATH).$this->theme.'/print.css'), |
|
| 612 | 612 | 'print'); |
| 613 | 613 | } |
| 614 | 614 | $this->assign('css_style_print', $style_print); |
@@ -631,10 +631,10 @@ discard block |
||
| 631 | 631 | |
| 632 | 632 | $isoCode = api_get_language_isocode(); |
| 633 | 633 | |
| 634 | - $selectLink = 'bootstrap-select/js/i18n/defaults-' . $isoCode . '_' . strtoupper($isoCode) . '.min.js'; |
|
| 634 | + $selectLink = 'bootstrap-select/js/i18n/defaults-'.$isoCode.'_'.strtoupper($isoCode).'.min.js'; |
|
| 635 | 635 | |
| 636 | 636 | if ($isoCode == 'en') { |
| 637 | - $selectLink = 'bootstrap-select/js/i18n/defaults-' . $isoCode . '_US.min.js'; |
|
| 637 | + $selectLink = 'bootstrap-select/js/i18n/defaults-'.$isoCode.'_US.min.js'; |
|
| 638 | 638 | } |
| 639 | 639 | // JS files |
| 640 | 640 | $js_files = array( |
@@ -684,8 +684,8 @@ discard block |
||
| 684 | 684 | } |
| 685 | 685 | |
| 686 | 686 | if ($isoCode != 'en') { |
| 687 | - $bowerJsFiles[] = 'jqueryui-timepicker-addon/dist/i18n/jquery-ui-timepicker-' . $isoCode . '.js'; |
|
| 688 | - $bowerJsFiles[] = 'jquery-ui/ui/minified/i18n/datepicker-' . $isoCode . '.min.js'; |
|
| 687 | + $bowerJsFiles[] = 'jqueryui-timepicker-addon/dist/i18n/jquery-ui-timepicker-'.$isoCode.'.js'; |
|
| 688 | + $bowerJsFiles[] = 'jquery-ui/ui/minified/i18n/datepicker-'.$isoCode.'.min.js'; |
|
| 689 | 689 | } |
| 690 | 690 | |
| 691 | 691 | foreach ($bowerJsFiles as $file) { |
@@ -766,7 +766,7 @@ discard block |
||
| 766 | 766 | } |
| 767 | 767 | |
| 768 | 768 | $this->assign('online_button', Display::return_icon('statusonline.png', null, null, ICON_SIZE_ATOM)); |
| 769 | - $this->assign('offline_button',Display::return_icon('statusoffline.png', null, null, ICON_SIZE_ATOM)); |
|
| 769 | + $this->assign('offline_button', Display::return_icon('statusoffline.png', null, null, ICON_SIZE_ATOM)); |
|
| 770 | 770 | |
| 771 | 771 | // Get language iso-code for this page - ignore errors |
| 772 | 772 | $this->assign('document_language', api_get_language_isocode()); |
@@ -825,15 +825,15 @@ discard block |
||
| 825 | 825 | $this->assign('section_name', 'section-'.$this_section); |
| 826 | 826 | |
| 827 | 827 | //Defaul root chamilo favicon |
| 828 | - $favico = '<link rel="shortcut icon" href="' . api_get_path(WEB_PATH) . 'favicon.ico" type="image/x-icon" />'; |
|
| 828 | + $favico = '<link rel="shortcut icon" href="'.api_get_path(WEB_PATH).'favicon.ico" type="image/x-icon" />'; |
|
| 829 | 829 | |
| 830 | 830 | //Added to verify if in the current Chamilo Theme exist a favicon |
| 831 | - $favicoThemeUrl = api_get_path(SYS_CSS_PATH) . 'themes/' . $this->theme . '/images/'; |
|
| 831 | + $favicoThemeUrl = api_get_path(SYS_CSS_PATH).'themes/'.$this->theme.'/images/'; |
|
| 832 | 832 | |
| 833 | 833 | //If exist pick the current chamilo theme favicon |
| 834 | - if (is_file($favicoThemeUrl . 'favicon.ico')) { |
|
| 835 | - $favico = '<link rel="shortcut icon" href="' . api_get_path(WEB_CSS_PATH) |
|
| 836 | - . 'themes/' . $this->theme . '/images/favicon.ico" type="image/x-icon" />'; |
|
| 834 | + if (is_file($favicoThemeUrl.'favicon.ico')) { |
|
| 835 | + $favico = '<link rel="shortcut icon" href="'.api_get_path(WEB_CSS_PATH) |
|
| 836 | + . 'themes/'.$this->theme.'/images/favicon.ico" type="image/x-icon" />'; |
|
| 837 | 837 | } |
| 838 | 838 | |
| 839 | 839 | if (api_is_multiple_url_enabled()) { |
@@ -863,7 +863,7 @@ discard block |
||
| 863 | 863 | if (api_get_setting('show_link_bug_notification') == 'true' && $this->user_is_logged_in) { |
| 864 | 864 | $bug_notification_link = '<li class="report"> |
| 865 | 865 | <a href="http://support.chamilo.org/projects/chamilo-18/wiki/How_to_report_bugs" target="_blank"> |
| 866 | - '. $iconBug . ' |
|
| 866 | + '. $iconBug.' |
|
| 867 | 867 | </a> |
| 868 | 868 | </li>'; |
| 869 | 869 | } |
@@ -975,26 +975,26 @@ discard block |
||
| 975 | 975 | $socialMeta = ''; |
| 976 | 976 | $metaTitle = api_get_setting('meta_title'); |
| 977 | 977 | if (!empty($metaTitle)) { |
| 978 | - $socialMeta .= '<meta name="twitter:card" content="summary" />' . "\n"; |
|
| 979 | - $socialMeta .= '<meta property="og:title" content="' . $metaTitle . '" />' . "\n"; |
|
| 980 | - $socialMeta .= '<meta property="og:url" content="' . api_get_path(WEB_PATH) . '" />' . "\n"; |
|
| 978 | + $socialMeta .= '<meta name="twitter:card" content="summary" />'."\n"; |
|
| 979 | + $socialMeta .= '<meta property="og:title" content="'.$metaTitle.'" />'."\n"; |
|
| 980 | + $socialMeta .= '<meta property="og:url" content="'.api_get_path(WEB_PATH).'" />'."\n"; |
|
| 981 | 981 | $metaDescription = api_get_setting('meta_description'); |
| 982 | 982 | if (!empty($metaDescription)) { |
| 983 | - $socialMeta .= '<meta property="og:description" content="' . $metaDescription . '" />' . "\n"; |
|
| 983 | + $socialMeta .= '<meta property="og:description" content="'.$metaDescription.'" />'."\n"; |
|
| 984 | 984 | } |
| 985 | 985 | $metaSite = api_get_setting('meta_twitter_site'); |
| 986 | 986 | if (!empty($metaSite)) { |
| 987 | - $socialMeta .= '<meta name="twitter:site" content="' . $metaSite . '" />' . "\n"; |
|
| 987 | + $socialMeta .= '<meta name="twitter:site" content="'.$metaSite.'" />'."\n"; |
|
| 988 | 988 | $metaCreator = api_get_setting('meta_twitter_creator'); |
| 989 | 989 | if (!empty($metaCreator)) { |
| 990 | - $socialMeta .= '<meta name="twitter:creator" content="' . $metaCreator . '" />' . "\n"; |
|
| 990 | + $socialMeta .= '<meta name="twitter:creator" content="'.$metaCreator.'" />'."\n"; |
|
| 991 | 991 | } |
| 992 | 992 | } |
| 993 | 993 | $metaImage = api_get_setting('meta_image_path'); |
| 994 | 994 | if (!empty($metaImage)) { |
| 995 | - if (is_file(api_get_path(SYS_PATH) . $metaImage)) { |
|
| 996 | - $path = api_get_path(WEB_PATH) . $metaImage; |
|
| 997 | - $socialMeta .= '<meta property="og:image" content="' . $path . '" />' . "\n"; |
|
| 995 | + if (is_file(api_get_path(SYS_PATH).$metaImage)) { |
|
| 996 | + $path = api_get_path(WEB_PATH).$metaImage; |
|
| 997 | + $socialMeta .= '<meta property="og:image" content="'.$path.'" />'."\n"; |
|
| 998 | 998 | } |
| 999 | 999 | } |
| 1000 | 1000 | } |
@@ -1027,7 +1027,7 @@ discard block |
||
| 1027 | 1027 | // Tutor name |
| 1028 | 1028 | if (api_get_setting('show_tutor_data') == 'true') { |
| 1029 | 1029 | // Course manager |
| 1030 | - $courseId = api_get_course_int_id(); |
|
| 1030 | + $courseId = api_get_course_int_id(); |
|
| 1031 | 1031 | $id_session = api_get_session_id(); |
| 1032 | 1032 | if (!empty($courseId)) { |
| 1033 | 1033 | $tutor_data = ''; |
@@ -1059,7 +1059,7 @@ discard block |
||
| 1059 | 1059 | $courseId = api_get_course_int_id(); |
| 1060 | 1060 | if (!empty($courseId)) { |
| 1061 | 1061 | $teacher_data = ''; |
| 1062 | - $mail= CourseManager::get_emails_of_tutors_to_course($courseId); |
|
| 1062 | + $mail = CourseManager::get_emails_of_tutors_to_course($courseId); |
|
| 1063 | 1063 | if (!empty($mail)) { |
| 1064 | 1064 | $teachers_parsed = array(); |
| 1065 | 1065 | foreach ($mail as $value) { |
@@ -1293,7 +1293,7 @@ discard block |
||
| 1293 | 1293 | 'sessionVar' => basename(__FILE__, '.php'), |
| 1294 | 1294 | 'imageOptions' => array( |
| 1295 | 1295 | 'font_size' => 20, |
| 1296 | - 'font_path' => api_get_path(SYS_FONTS_PATH) . 'opensans/', |
|
| 1296 | + 'font_path' => api_get_path(SYS_FONTS_PATH).'opensans/', |
|
| 1297 | 1297 | 'font_file' => 'OpenSans-Regular.ttf', |
| 1298 | 1298 | //'output' => 'gif' |
| 1299 | 1299 | ) |