@@ -8,102 +8,102 @@ |
||
8 | 8 | */ |
9 | 9 | class DataForm extends FormValidator |
10 | 10 | { |
11 | - const TYPE_IMPORT = 1; |
|
12 | - const TYPE_EXPORT = 2; |
|
13 | - const TYPE_EXPORT_PDF = 3; |
|
11 | + const TYPE_IMPORT = 1; |
|
12 | + const TYPE_EXPORT = 2; |
|
13 | + const TYPE_EXPORT_PDF = 3; |
|
14 | 14 | |
15 | - /** |
|
16 | - * Builds a form containing form items based on a given parameter |
|
17 | - * @param int form_type 1=import, 2=export |
|
18 | - * @param obj cat_obj the category object |
|
19 | - * @param obj res_obj the result object |
|
20 | - * @param string form name |
|
21 | - * @param method |
|
22 | - * @param action |
|
23 | - */ |
|
24 | - public function __construct($form_type, $form_name, $method = 'post', $action = null, $target='', $locked_status) |
|
25 | - { |
|
26 | - parent :: __construct($form_name, $method, $action,$target); |
|
27 | - $this->form_type = $form_type; |
|
28 | - if ($this->form_type == self :: TYPE_IMPORT) { |
|
29 | - $this->build_import_form(); |
|
30 | - } elseif ($this->form_type == self :: TYPE_EXPORT) { |
|
31 | - if ($locked_status == 0) { |
|
32 | - $this->build_export_form_option(false); |
|
33 | - } else { |
|
34 | - $this->build_export_form(); |
|
35 | - } |
|
36 | - } elseif ($this->form_type == self :: TYPE_EXPORT_PDF) { |
|
37 | - $this->build_pdf_export_form(); |
|
38 | - } |
|
39 | - $this->setDefaults(); |
|
40 | - } |
|
15 | + /** |
|
16 | + * Builds a form containing form items based on a given parameter |
|
17 | + * @param int form_type 1=import, 2=export |
|
18 | + * @param obj cat_obj the category object |
|
19 | + * @param obj res_obj the result object |
|
20 | + * @param string form name |
|
21 | + * @param method |
|
22 | + * @param action |
|
23 | + */ |
|
24 | + public function __construct($form_type, $form_name, $method = 'post', $action = null, $target='', $locked_status) |
|
25 | + { |
|
26 | + parent :: __construct($form_name, $method, $action,$target); |
|
27 | + $this->form_type = $form_type; |
|
28 | + if ($this->form_type == self :: TYPE_IMPORT) { |
|
29 | + $this->build_import_form(); |
|
30 | + } elseif ($this->form_type == self :: TYPE_EXPORT) { |
|
31 | + if ($locked_status == 0) { |
|
32 | + $this->build_export_form_option(false); |
|
33 | + } else { |
|
34 | + $this->build_export_form(); |
|
35 | + } |
|
36 | + } elseif ($this->form_type == self :: TYPE_EXPORT_PDF) { |
|
37 | + $this->build_pdf_export_form(); |
|
38 | + } |
|
39 | + $this->setDefaults(); |
|
40 | + } |
|
41 | 41 | |
42 | - protected function build_pdf_export_form() |
|
43 | - { |
|
44 | - $renderer =& $this->defaultRenderer(); |
|
45 | - $renderer->setCustomElementTemplate('<span>{element}</span>'); |
|
46 | - $this->addElement('header', get_lang('ChooseOrientation')); |
|
47 | - $this->addElement('radio', 'orientation', null, get_lang('Portrait'), 'portrait'); |
|
48 | - $this->addElement('radio', 'orientation', null, get_lang('Landscape'), 'landscape'); |
|
49 | - $this->addButtonExport(get_lang('Export')); |
|
50 | - $this->setDefaults(array ( |
|
51 | - 'orientation' => 'portrait' |
|
52 | - )); |
|
53 | - } |
|
42 | + protected function build_pdf_export_form() |
|
43 | + { |
|
44 | + $renderer =& $this->defaultRenderer(); |
|
45 | + $renderer->setCustomElementTemplate('<span>{element}</span>'); |
|
46 | + $this->addElement('header', get_lang('ChooseOrientation')); |
|
47 | + $this->addElement('radio', 'orientation', null, get_lang('Portrait'), 'portrait'); |
|
48 | + $this->addElement('radio', 'orientation', null, get_lang('Landscape'), 'landscape'); |
|
49 | + $this->addButtonExport(get_lang('Export')); |
|
50 | + $this->setDefaults(array ( |
|
51 | + 'orientation' => 'portrait' |
|
52 | + )); |
|
53 | + } |
|
54 | 54 | |
55 | - protected function build_export_form() |
|
56 | - { |
|
57 | - $this->addElement('header', get_lang('ChooseFormat')); |
|
58 | - $this->addElement('radio', 'file_type', get_lang('OutputFileType'), 'CSV (Comma-Separated Values)', 'csv'); |
|
59 | - $this->addElement('radio', 'file_type', null, 'XML (Extensible Markup Language)', 'xml'); |
|
60 | - $this->addElement('radio', 'file_type', null, 'PDF (Portable Document Format)', 'pdf'); |
|
61 | - $this->addButtonExport(get_lang('Export')); |
|
62 | - $this->setDefaults(array ( |
|
63 | - 'file_type' => 'csv' |
|
64 | - )); |
|
65 | - } |
|
55 | + protected function build_export_form() |
|
56 | + { |
|
57 | + $this->addElement('header', get_lang('ChooseFormat')); |
|
58 | + $this->addElement('radio', 'file_type', get_lang('OutputFileType'), 'CSV (Comma-Separated Values)', 'csv'); |
|
59 | + $this->addElement('radio', 'file_type', null, 'XML (Extensible Markup Language)', 'xml'); |
|
60 | + $this->addElement('radio', 'file_type', null, 'PDF (Portable Document Format)', 'pdf'); |
|
61 | + $this->addButtonExport(get_lang('Export')); |
|
62 | + $this->setDefaults(array ( |
|
63 | + 'file_type' => 'csv' |
|
64 | + )); |
|
65 | + } |
|
66 | 66 | |
67 | - protected function build_export_form_option($show_pdf=true) |
|
68 | - { |
|
69 | - $this->addElement('header', get_lang('ChooseFormat')); |
|
70 | - $this->addElement('radio', 'file_type', get_lang('OutputFileType'), 'CSV (Comma-Separated Values)', 'csv'); |
|
71 | - $this->addElement('radio', 'file_type', null, 'XML (Extensible Markup Language)', 'xml'); |
|
72 | - $this->addElement('radio', 'file_type', Display::return_icon('info3.gif',get_lang('ToExportMustLockEvaluation')), 'PDF (Portable Document Format)', 'pdf', array('disabled')); |
|
73 | - $this->addButtonExport(get_lang('Export')); |
|
74 | - $this->setDefaults(array ( |
|
75 | - 'file_type' => 'csv' |
|
76 | - )); |
|
77 | - } |
|
67 | + protected function build_export_form_option($show_pdf=true) |
|
68 | + { |
|
69 | + $this->addElement('header', get_lang('ChooseFormat')); |
|
70 | + $this->addElement('radio', 'file_type', get_lang('OutputFileType'), 'CSV (Comma-Separated Values)', 'csv'); |
|
71 | + $this->addElement('radio', 'file_type', null, 'XML (Extensible Markup Language)', 'xml'); |
|
72 | + $this->addElement('radio', 'file_type', Display::return_icon('info3.gif',get_lang('ToExportMustLockEvaluation')), 'PDF (Portable Document Format)', 'pdf', array('disabled')); |
|
73 | + $this->addButtonExport(get_lang('Export')); |
|
74 | + $this->setDefaults(array ( |
|
75 | + 'file_type' => 'csv' |
|
76 | + )); |
|
77 | + } |
|
78 | 78 | |
79 | - protected function build_import_form() |
|
80 | - { |
|
81 | - $this->addElement('hidden', 'formSent'); |
|
82 | - $this->addElement('header', get_lang('ImportFileLocation')); |
|
83 | - $this->addElement('file', 'import_file',get_lang('Location')); |
|
84 | - $allowed_file_types = array ( |
|
85 | - 'xml', |
|
86 | - 'csv' |
|
87 | - ); |
|
88 | - //$this->addRule('file', get_lang('InvalidExtension') . ' (' . implode(',', $allowed_file_types) . ')', 'filetype', $allowed_file_types); |
|
89 | - $this->addElement('radio', 'file_type', get_lang('FileType'), 'CSV (<a href="docs/example_csv.html" target="_blank">' . get_lang('ExampleCSVFile') . '</a>)', 'csv'); |
|
90 | - $this->addElement('radio', 'file_type', null, 'XML (<a href="docs/example_xml.html" target="_blank">' . get_lang('ExampleXMLFile') . '</a>)', 'xml'); |
|
91 | - $this->addElement('checkbox','overwrite', null,get_lang('OverwriteScores')); |
|
92 | - $this->addElement('checkbox','ignoreerrors',null,get_lang('IgnoreErrors')); |
|
93 | - $this->addButtonImport(get_lang('Ok')); |
|
94 | - $this->setDefaults(array( |
|
95 | - 'formSent' => '1', |
|
96 | - 'file_type' => 'csv' |
|
97 | - )); |
|
98 | - } |
|
79 | + protected function build_import_form() |
|
80 | + { |
|
81 | + $this->addElement('hidden', 'formSent'); |
|
82 | + $this->addElement('header', get_lang('ImportFileLocation')); |
|
83 | + $this->addElement('file', 'import_file',get_lang('Location')); |
|
84 | + $allowed_file_types = array ( |
|
85 | + 'xml', |
|
86 | + 'csv' |
|
87 | + ); |
|
88 | + //$this->addRule('file', get_lang('InvalidExtension') . ' (' . implode(',', $allowed_file_types) . ')', 'filetype', $allowed_file_types); |
|
89 | + $this->addElement('radio', 'file_type', get_lang('FileType'), 'CSV (<a href="docs/example_csv.html" target="_blank">' . get_lang('ExampleCSVFile') . '</a>)', 'csv'); |
|
90 | + $this->addElement('radio', 'file_type', null, 'XML (<a href="docs/example_xml.html" target="_blank">' . get_lang('ExampleXMLFile') . '</a>)', 'xml'); |
|
91 | + $this->addElement('checkbox','overwrite', null,get_lang('OverwriteScores')); |
|
92 | + $this->addElement('checkbox','ignoreerrors',null,get_lang('IgnoreErrors')); |
|
93 | + $this->addButtonImport(get_lang('Ok')); |
|
94 | + $this->setDefaults(array( |
|
95 | + 'formSent' => '1', |
|
96 | + 'file_type' => 'csv' |
|
97 | + )); |
|
98 | + } |
|
99 | 99 | |
100 | - public function display() |
|
101 | - { |
|
102 | - parent :: display(); |
|
103 | - } |
|
100 | + public function display() |
|
101 | + { |
|
102 | + parent :: display(); |
|
103 | + } |
|
104 | 104 | |
105 | - public function setDefaults($defaults = array(), $filter = null) |
|
106 | - { |
|
107 | - parent :: setDefaults($defaults, $filter); |
|
108 | - } |
|
105 | + public function setDefaults($defaults = array(), $filter = null) |
|
106 | + { |
|
107 | + parent :: setDefaults($defaults, $filter); |
|
108 | + } |
|
109 | 109 | } |
@@ -10,128 +10,128 @@ |
||
10 | 10 | */ |
11 | 11 | class UserTable extends SortableTable |
12 | 12 | { |
13 | - private $userid; |
|
14 | - private $datagen; |
|
13 | + private $userid; |
|
14 | + private $datagen; |
|
15 | 15 | |
16 | - /** |
|
17 | - * Constructor |
|
18 | - */ |
|
19 | - public function __construct($userid, $evals = array(), $links = array(), $addparams = null) |
|
20 | - { |
|
21 | - parent :: __construct ('userlist', null, null, 0); |
|
22 | - $this->userid = $userid; |
|
23 | - $this->datagen = new UserDataGenerator($userid, $evals, $links); |
|
24 | - if (isset($addparams)) { |
|
25 | - $this->set_additional_parameters($addparams); |
|
26 | - } |
|
27 | - $column = 0; |
|
28 | - $this->set_header($column++, get_lang('Type')); |
|
29 | - $this->set_header($column++, get_lang('Evaluation')); |
|
30 | - $this->set_header($column++, get_lang('Course')); |
|
31 | - $this->set_header($column++, get_lang('Category')); |
|
32 | - $this->set_header($column++, get_lang('EvaluationAverage')); |
|
33 | - $this->set_header($column++, get_lang('Result')); |
|
16 | + /** |
|
17 | + * Constructor |
|
18 | + */ |
|
19 | + public function __construct($userid, $evals = array(), $links = array(), $addparams = null) |
|
20 | + { |
|
21 | + parent :: __construct ('userlist', null, null, 0); |
|
22 | + $this->userid = $userid; |
|
23 | + $this->datagen = new UserDataGenerator($userid, $evals, $links); |
|
24 | + if (isset($addparams)) { |
|
25 | + $this->set_additional_parameters($addparams); |
|
26 | + } |
|
27 | + $column = 0; |
|
28 | + $this->set_header($column++, get_lang('Type')); |
|
29 | + $this->set_header($column++, get_lang('Evaluation')); |
|
30 | + $this->set_header($column++, get_lang('Course')); |
|
31 | + $this->set_header($column++, get_lang('Category')); |
|
32 | + $this->set_header($column++, get_lang('EvaluationAverage')); |
|
33 | + $this->set_header($column++, get_lang('Result')); |
|
34 | 34 | |
35 | - $scoredisplay = ScoreDisplay :: instance(); |
|
36 | - if ($scoredisplay->is_custom()) { |
|
37 | - $this->set_header($column++, get_lang('Display')); |
|
38 | - } |
|
39 | - } |
|
35 | + $scoredisplay = ScoreDisplay :: instance(); |
|
36 | + if ($scoredisplay->is_custom()) { |
|
37 | + $this->set_header($column++, get_lang('Display')); |
|
38 | + } |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * Function used by SortableTable to get total number of items in the table |
|
43 | - */ |
|
44 | - function get_total_number_of_items() |
|
45 | - { |
|
46 | - return $this->datagen->get_total_items_count(); |
|
47 | - } |
|
41 | + /** |
|
42 | + * Function used by SortableTable to get total number of items in the table |
|
43 | + */ |
|
44 | + function get_total_number_of_items() |
|
45 | + { |
|
46 | + return $this->datagen->get_total_items_count(); |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * Function used by SortableTable to generate the data to display |
|
51 | - */ |
|
52 | - public function get_table_data($from = 1, $per_page = null, $column = null, $direction = null, $sort = null) |
|
53 | - { |
|
54 | - $scoredisplay = ScoreDisplay :: instance(); |
|
49 | + /** |
|
50 | + * Function used by SortableTable to generate the data to display |
|
51 | + */ |
|
52 | + public function get_table_data($from = 1, $per_page = null, $column = null, $direction = null, $sort = null) |
|
53 | + { |
|
54 | + $scoredisplay = ScoreDisplay :: instance(); |
|
55 | 55 | |
56 | - // determine sorting type |
|
57 | - switch ($this->column) { |
|
58 | - // Type |
|
59 | - case 0: |
|
60 | - $sorting = UserDataGenerator :: UDG_SORT_TYPE; |
|
61 | - break; |
|
62 | - case 1: |
|
63 | - $sorting = UserDataGenerator :: UDG_SORT_NAME; |
|
64 | - break; |
|
65 | - case 2: |
|
66 | - $sorting = UserDataGenerator :: UDG_SORT_COURSE; |
|
67 | - break; |
|
68 | - case 3: |
|
69 | - $sorting = UserDataGenerator :: UDG_SORT_CATEGORY; |
|
70 | - break; |
|
71 | - case 4: |
|
72 | - $sorting = UserDataGenerator :: UDG_SORT_AVERAGE; |
|
73 | - break; |
|
74 | - case 5: |
|
75 | - $sorting = UserDataGenerator :: UDG_SORT_SCORE; |
|
76 | - break; |
|
77 | - case 6: |
|
78 | - $sorting = UserDataGenerator :: UDG_SORT_MASK; |
|
79 | - break; |
|
80 | - } |
|
81 | - if ($this->direction == 'DESC') { |
|
82 | - $sorting |= UserDataGenerator :: UDG_SORT_DESC; |
|
83 | - } else { |
|
84 | - $sorting |= UserDataGenerator :: UDG_SORT_ASC; |
|
85 | - } |
|
86 | - $data_array = $this->datagen->get_data($sorting, $from, $this->per_page); |
|
87 | - // generate the data to display |
|
88 | - $sortable_data = array(); |
|
89 | - foreach ($data_array as $data) { |
|
90 | - if ($data[2]!="") {//filter by course removed |
|
91 | - $row = array (); |
|
92 | - $row[] = $this->build_type_column($data[0]); |
|
93 | - $row[] = $this->build_name_link($data[0]); |
|
94 | - $row[] = $data[2]; |
|
95 | - $row[] = $data[3]; |
|
96 | - $row[] = $data[4]; |
|
97 | - $row[] = $data[5]; |
|
98 | - if ($scoredisplay->is_custom()) |
|
99 | - $row[] = $data[6]; |
|
100 | - $sortable_data[] = $row; |
|
101 | - } |
|
102 | - } |
|
56 | + // determine sorting type |
|
57 | + switch ($this->column) { |
|
58 | + // Type |
|
59 | + case 0: |
|
60 | + $sorting = UserDataGenerator :: UDG_SORT_TYPE; |
|
61 | + break; |
|
62 | + case 1: |
|
63 | + $sorting = UserDataGenerator :: UDG_SORT_NAME; |
|
64 | + break; |
|
65 | + case 2: |
|
66 | + $sorting = UserDataGenerator :: UDG_SORT_COURSE; |
|
67 | + break; |
|
68 | + case 3: |
|
69 | + $sorting = UserDataGenerator :: UDG_SORT_CATEGORY; |
|
70 | + break; |
|
71 | + case 4: |
|
72 | + $sorting = UserDataGenerator :: UDG_SORT_AVERAGE; |
|
73 | + break; |
|
74 | + case 5: |
|
75 | + $sorting = UserDataGenerator :: UDG_SORT_SCORE; |
|
76 | + break; |
|
77 | + case 6: |
|
78 | + $sorting = UserDataGenerator :: UDG_SORT_MASK; |
|
79 | + break; |
|
80 | + } |
|
81 | + if ($this->direction == 'DESC') { |
|
82 | + $sorting |= UserDataGenerator :: UDG_SORT_DESC; |
|
83 | + } else { |
|
84 | + $sorting |= UserDataGenerator :: UDG_SORT_ASC; |
|
85 | + } |
|
86 | + $data_array = $this->datagen->get_data($sorting, $from, $this->per_page); |
|
87 | + // generate the data to display |
|
88 | + $sortable_data = array(); |
|
89 | + foreach ($data_array as $data) { |
|
90 | + if ($data[2]!="") {//filter by course removed |
|
91 | + $row = array (); |
|
92 | + $row[] = $this->build_type_column($data[0]); |
|
93 | + $row[] = $this->build_name_link($data[0]); |
|
94 | + $row[] = $data[2]; |
|
95 | + $row[] = $data[3]; |
|
96 | + $row[] = $data[4]; |
|
97 | + $row[] = $data[5]; |
|
98 | + if ($scoredisplay->is_custom()) |
|
99 | + $row[] = $data[6]; |
|
100 | + $sortable_data[] = $row; |
|
101 | + } |
|
102 | + } |
|
103 | 103 | |
104 | - return $sortable_data; |
|
105 | - } |
|
104 | + return $sortable_data; |
|
105 | + } |
|
106 | 106 | |
107 | - /** |
|
108 | - * @param $item |
|
109 | - * @return string |
|
110 | - */ |
|
111 | - private function build_type_column($item) |
|
112 | - { |
|
113 | - return GradebookUtils::build_type_icon_tag($item->get_icon_name()); |
|
114 | - } |
|
107 | + /** |
|
108 | + * @param $item |
|
109 | + * @return string |
|
110 | + */ |
|
111 | + private function build_type_column($item) |
|
112 | + { |
|
113 | + return GradebookUtils::build_type_icon_tag($item->get_icon_name()); |
|
114 | + } |
|
115 | 115 | |
116 | - /** |
|
117 | - * @param $item |
|
118 | - * @return string |
|
119 | - */ |
|
120 | - private function build_name_link($item) |
|
121 | - { |
|
122 | - switch ($item->get_item_type()) { |
|
123 | - // evaluation |
|
124 | - case 'E' : |
|
125 | - return ' ' |
|
126 | - . '<a href="gradebook_view_result.php?selecteval=' . $item->get_id() . '">' |
|
127 | - . $item->get_name() |
|
128 | - . '</a>'; |
|
129 | - // link |
|
130 | - case 'L' : |
|
131 | - return ' <a href="' . $item->get_link() . '">' |
|
132 | - . $item->get_name() |
|
133 | - . '</a>' |
|
134 | - . ' [' . $item->get_type_name() . ']'; |
|
135 | - } |
|
136 | - } |
|
116 | + /** |
|
117 | + * @param $item |
|
118 | + * @return string |
|
119 | + */ |
|
120 | + private function build_name_link($item) |
|
121 | + { |
|
122 | + switch ($item->get_item_type()) { |
|
123 | + // evaluation |
|
124 | + case 'E' : |
|
125 | + return ' ' |
|
126 | + . '<a href="gradebook_view_result.php?selecteval=' . $item->get_id() . '">' |
|
127 | + . $item->get_name() |
|
128 | + . '</a>'; |
|
129 | + // link |
|
130 | + case 'L' : |
|
131 | + return ' <a href="' . $item->get_link() . '">' |
|
132 | + . $item->get_name() |
|
133 | + . '</a>' |
|
134 | + . ' [' . $item->get_type_name() . ']'; |
|
135 | + } |
|
136 | + } |
|
137 | 137 | } |
@@ -27,22 +27,22 @@ |
||
27 | 27 | |
28 | 28 | if (!empty($_POST)) |
29 | 29 | { |
30 | - foreach ( $_POST as $key => $value ) |
|
31 | - { |
|
32 | - if ( ( !is_string($value) && !is_numeric($value) ) || !is_string($key) ) |
|
33 | - continue; |
|
30 | + foreach ( $_POST as $key => $value ) |
|
31 | + { |
|
32 | + if ( ( !is_string($value) && !is_numeric($value) ) || !is_string($key) ) |
|
33 | + continue; |
|
34 | 34 | |
35 | - if ( get_magic_quotes_gpc() ) |
|
36 | - $value = htmlspecialchars( stripslashes((string)$value) ); |
|
37 | - else |
|
38 | - $value = htmlspecialchars( (string)$value ); |
|
35 | + if ( get_magic_quotes_gpc() ) |
|
36 | + $value = htmlspecialchars( stripslashes((string)$value) ); |
|
37 | + else |
|
38 | + $value = htmlspecialchars( (string)$value ); |
|
39 | 39 | ?> |
40 | 40 | <tr> |
41 | 41 | <th style="vertical-align: top"><?php echo htmlspecialchars( (string)$key ); ?></th> |
42 | 42 | <td><pre class="samples"><?php echo $value; ?></pre></td> |
43 | 43 | </tr> |
44 | 44 | <?php |
45 | - } |
|
45 | + } |
|
46 | 46 | } |
47 | 47 | ?> |
48 | 48 | </table> |
@@ -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,115 +321,115 @@ 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); |
|
361 | - $content = str_replace('src=\"'.api_get_path(REL_HOME_PATH), 'src=\"'.api_get_path(WEB_PATH).api_get_path(REL_HOME_PATH), $content); |
|
362 | - $content = str_replace('file='.api_get_path(REL_HOME_PATH), 'file='.api_get_path(WEB_PATH).api_get_path(REL_HOME_PATH), $content); |
|
363 | - |
|
364 | - |
|
365 | - $lang = is_null($lang) ? '' : $lang; |
|
366 | - |
|
367 | - $current_access_url_id = 1; |
|
368 | - if (api_is_multiple_url_enabled()) { |
|
369 | - $current_access_url_id = api_get_current_access_url_id(); |
|
370 | - } |
|
371 | - |
|
372 | - $params = [ |
|
373 | - 'title' => $title, |
|
374 | - 'content' => $content, |
|
375 | - 'date_start' => $start, |
|
376 | - 'date_end' => $end, |
|
377 | - 'visible_teacher' => $visible_teacher, |
|
378 | - 'visible_student' => $visible_student, |
|
379 | - 'visible_guest' => $visible_guest, |
|
380 | - 'lang' => $lang, |
|
381 | - 'access_url_id' => $current_access_url_id, |
|
382 | - ]; |
|
383 | - |
|
384 | - $resultId = Database::insert($db_table, $params); |
|
385 | - |
|
386 | - if ($resultId) { |
|
387 | - |
|
388 | - if ($sendEmailTest) { |
|
389 | - SystemAnnouncementManager::send_system_announcement_by_email( |
|
390 | - $title, |
|
391 | - $content, |
|
392 | - $visible_teacher, |
|
393 | - $visible_student, |
|
394 | - $lang, |
|
395 | - true |
|
396 | - ); |
|
397 | - } else { |
|
398 | - if ($send_mail == 1) { |
|
399 | - SystemAnnouncementManager::send_system_announcement_by_email( |
|
400 | - $title, |
|
401 | - $content, |
|
402 | - $visible_teacher, |
|
403 | - $visible_student, |
|
404 | - $lang |
|
405 | - ); |
|
406 | - } |
|
407 | - } |
|
408 | - |
|
409 | - if ($add_to_calendar) { |
|
410 | - $agenda = new Agenda(); |
|
411 | - $agenda->setType('admin'); |
|
412 | - $agenda->addEvent( |
|
413 | - $date_start, |
|
414 | - $date_end, |
|
415 | - false, |
|
416 | - $title, |
|
417 | - $original_content |
|
418 | - ); |
|
419 | - } |
|
420 | - |
|
421 | - return $resultId; |
|
422 | - |
|
423 | - } |
|
424 | - |
|
425 | - return false; |
|
426 | - } |
|
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 | + $content = str_replace('src=\"'.api_get_path(REL_HOME_PATH), 'src=\"'.api_get_path(WEB_PATH).api_get_path(REL_HOME_PATH), $content); |
|
362 | + $content = str_replace('file='.api_get_path(REL_HOME_PATH), 'file='.api_get_path(WEB_PATH).api_get_path(REL_HOME_PATH), $content); |
|
363 | + |
|
364 | + |
|
365 | + $lang = is_null($lang) ? '' : $lang; |
|
366 | + |
|
367 | + $current_access_url_id = 1; |
|
368 | + if (api_is_multiple_url_enabled()) { |
|
369 | + $current_access_url_id = api_get_current_access_url_id(); |
|
370 | + } |
|
371 | + |
|
372 | + $params = [ |
|
373 | + 'title' => $title, |
|
374 | + 'content' => $content, |
|
375 | + 'date_start' => $start, |
|
376 | + 'date_end' => $end, |
|
377 | + 'visible_teacher' => $visible_teacher, |
|
378 | + 'visible_student' => $visible_student, |
|
379 | + 'visible_guest' => $visible_guest, |
|
380 | + 'lang' => $lang, |
|
381 | + 'access_url_id' => $current_access_url_id, |
|
382 | + ]; |
|
383 | + |
|
384 | + $resultId = Database::insert($db_table, $params); |
|
385 | + |
|
386 | + if ($resultId) { |
|
387 | + |
|
388 | + if ($sendEmailTest) { |
|
389 | + SystemAnnouncementManager::send_system_announcement_by_email( |
|
390 | + $title, |
|
391 | + $content, |
|
392 | + $visible_teacher, |
|
393 | + $visible_student, |
|
394 | + $lang, |
|
395 | + true |
|
396 | + ); |
|
397 | + } else { |
|
398 | + if ($send_mail == 1) { |
|
399 | + SystemAnnouncementManager::send_system_announcement_by_email( |
|
400 | + $title, |
|
401 | + $content, |
|
402 | + $visible_teacher, |
|
403 | + $visible_student, |
|
404 | + $lang |
|
405 | + ); |
|
406 | + } |
|
407 | + } |
|
408 | + |
|
409 | + if ($add_to_calendar) { |
|
410 | + $agenda = new Agenda(); |
|
411 | + $agenda->setType('admin'); |
|
412 | + $agenda->addEvent( |
|
413 | + $date_start, |
|
414 | + $date_end, |
|
415 | + false, |
|
416 | + $title, |
|
417 | + $original_content |
|
418 | + ); |
|
419 | + } |
|
420 | + |
|
421 | + return $resultId; |
|
422 | + |
|
423 | + } |
|
424 | + |
|
425 | + return false; |
|
426 | + } |
|
427 | 427 | |
428 | 428 | /** |
429 | - * Makes the announcement id visible only for groups in groups_array |
|
430 | - * @param int announcement id |
|
431 | - * @param array array of group id |
|
432 | - **/ |
|
429 | + * Makes the announcement id visible only for groups in groups_array |
|
430 | + * @param int announcement id |
|
431 | + * @param array array of group id |
|
432 | + **/ |
|
433 | 433 | public static function announcement_for_groups($announcement_id, $group_array) |
434 | 434 | { |
435 | 435 | $tbl_announcement_group = Database:: get_main_table( |
@@ -463,10 +463,10 @@ discard block |
||
463 | 463 | } |
464 | 464 | |
465 | 465 | /** |
466 | - * Gets the groups of this announce |
|
467 | - * @param int announcement id |
|
468 | - * @return array array of group id |
|
469 | - **/ |
|
466 | + * Gets the groups of this announce |
|
467 | + * @param int announcement id |
|
468 | + * @return array array of group id |
|
469 | + **/ |
|
470 | 470 | public static function get_announcement_groups($announcement_id) |
471 | 471 | { |
472 | 472 | $tbl_announcement_group = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS_GROUPS); |
@@ -485,15 +485,15 @@ discard block |
||
485 | 485 | return $groups; |
486 | 486 | } |
487 | 487 | |
488 | - /** |
|
489 | - * Updates an announcement to the database |
|
490 | - * @param integer $id : id of the announcement |
|
491 | - * @param string $title : title of the announcement |
|
492 | - * @param string $content : content of the announcement |
|
493 | - * @param array $date_start: start date of announcement (0 => day ; 1 => month ; 2 => year ; 3 => hour ; 4 => minute) |
|
494 | - * @param array $date_end : end date of announcement (0 => day ; 1 => month ; 2 => year ; 3 => hour ; 4 => minute) |
|
495 | - * @return bool True on success, false on failure |
|
496 | - */ |
|
488 | + /** |
|
489 | + * Updates an announcement to the database |
|
490 | + * @param integer $id : id of the announcement |
|
491 | + * @param string $title : title of the announcement |
|
492 | + * @param string $content : content of the announcement |
|
493 | + * @param array $date_start: start date of announcement (0 => day ; 1 => month ; 2 => year ; 3 => hour ; 4 => minute) |
|
494 | + * @param array $date_end : end date of announcement (0 => day ; 1 => month ; 2 => year ; 3 => hour ; 4 => minute) |
|
495 | + * @return bool True on success, false on failure |
|
496 | + */ |
|
497 | 497 | public static function update_announcement( |
498 | 498 | $id, |
499 | 499 | $title, |
@@ -509,43 +509,43 @@ discard block |
||
509 | 509 | ) { |
510 | 510 | $em = Database::getManager(); |
511 | 511 | |
512 | - $a_dateS = explode(' ',$date_start); |
|
513 | - $a_arraySD = explode('-',$a_dateS[0]); |
|
514 | - $a_arraySH = explode(':',$a_dateS[1]); |
|
515 | - $date_start_to_compare = array_merge($a_arraySD,$a_arraySH); |
|
512 | + $a_dateS = explode(' ',$date_start); |
|
513 | + $a_arraySD = explode('-',$a_dateS[0]); |
|
514 | + $a_arraySH = explode(':',$a_dateS[1]); |
|
515 | + $date_start_to_compare = array_merge($a_arraySD,$a_arraySH); |
|
516 | 516 | |
517 | - $a_dateE = explode(' ',$date_end); |
|
518 | - $a_arrayED = explode('-',$a_dateE[0]); |
|
519 | - $a_arrayEH = explode(':',$a_dateE[1]); |
|
520 | - $date_end_to_compare = array_merge($a_arrayED,$a_arrayEH); |
|
517 | + $a_dateE = explode(' ',$date_end); |
|
518 | + $a_arrayED = explode('-',$a_dateE[0]); |
|
519 | + $a_arrayEH = explode(':',$a_dateE[1]); |
|
520 | + $date_end_to_compare = array_merge($a_arrayED,$a_arrayEH); |
|
521 | 521 | |
522 | 522 | $lang = is_null($lang) ? '' : $lang; |
523 | 523 | |
524 | - if (!checkdate($date_start_to_compare[1], $date_start_to_compare[2], $date_start_to_compare[0])) { |
|
525 | - Display :: display_normal_message(get_lang('InvalidStartDate')); |
|
526 | - return false; |
|
527 | - } |
|
524 | + if (!checkdate($date_start_to_compare[1], $date_start_to_compare[2], $date_start_to_compare[0])) { |
|
525 | + Display :: display_normal_message(get_lang('InvalidStartDate')); |
|
526 | + return false; |
|
527 | + } |
|
528 | 528 | |
529 | - if (($date_end_to_compare[1] || |
|
529 | + if (($date_end_to_compare[1] || |
|
530 | 530 | $date_end_to_compare[2] || |
531 | 531 | $date_end_to_compare[0]) && |
532 | 532 | !checkdate($date_end_to_compare[1], $date_end_to_compare[2], $date_end_to_compare[0]) |
533 | 533 | ) { |
534 | - Display :: display_normal_message(get_lang('InvalidEndDate')); |
|
535 | - return false; |
|
536 | - } |
|
534 | + Display :: display_normal_message(get_lang('InvalidEndDate')); |
|
535 | + return false; |
|
536 | + } |
|
537 | 537 | |
538 | - if (strlen(trim($title)) == 0) { |
|
539 | - Display::display_normal_message(get_lang('InvalidTitle')); |
|
540 | - return false; |
|
541 | - } |
|
538 | + if (strlen(trim($title)) == 0) { |
|
539 | + Display::display_normal_message(get_lang('InvalidTitle')); |
|
540 | + return false; |
|
541 | + } |
|
542 | 542 | |
543 | - $start = api_get_utc_datetime($date_start); |
|
543 | + $start = api_get_utc_datetime($date_start); |
|
544 | 544 | $end = api_get_utc_datetime($date_end); |
545 | 545 | |
546 | - //Fixing urls that are sent by email |
|
547 | - //$content = str_replace('src=\"/home/', 'src=\"'.api_get_path(WEB_PATH).'home/', $content); |
|
548 | - //$content = str_replace('file=/home/', 'file='.api_get_path(WEB_PATH).'home/', $content); |
|
546 | + //Fixing urls that are sent by email |
|
547 | + //$content = str_replace('src=\"/home/', 'src=\"'.api_get_path(WEB_PATH).'home/', $content); |
|
548 | + //$content = str_replace('file=/home/', 'file='.api_get_path(WEB_PATH).'home/', $content); |
|
549 | 549 | $content = str_replace('src=\"'.api_get_path(REL_HOME_PATH), 'src=\"'.api_get_path(WEB_PATH).api_get_path(REL_HOME_PATH), $content); |
550 | 550 | $content = str_replace('file='.api_get_path(REL_HOME_PATH), 'file='.api_get_path(WEB_PATH).api_get_path(REL_HOME_PATH), $content); |
551 | 551 | |
@@ -595,84 +595,84 @@ discard block |
||
595 | 595 | $em->merge($announcement); |
596 | 596 | $em->flush(); |
597 | 597 | |
598 | - return true; |
|
599 | - } |
|
598 | + return true; |
|
599 | + } |
|
600 | 600 | |
601 | - /** |
|
602 | - * Deletes an announcement |
|
603 | - * @param int $id The identifier of the announcement that should be |
|
604 | - * @return bool True on success, false on failure |
|
605 | - */ |
|
606 | - public static function delete_announcement($id) |
|
601 | + /** |
|
602 | + * Deletes an announcement |
|
603 | + * @param int $id The identifier of the announcement that should be |
|
604 | + * @return bool True on success, false on failure |
|
605 | + */ |
|
606 | + public static function delete_announcement($id) |
|
607 | 607 | { |
608 | - $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
609 | - $id = intval($id); |
|
610 | - $sql = "DELETE FROM ".$db_table." WHERE id =".$id; |
|
611 | - $res = Database::query($sql); |
|
612 | - if ($res === false) { |
|
613 | - |
|
614 | - return false; |
|
615 | - } |
|
616 | - return true; |
|
617 | - } |
|
618 | - |
|
619 | - /** |
|
620 | - * Gets an announcement |
|
621 | - * @param int $id The identifier of the announcement that should be |
|
622 | - * @return object Object of class StdClass or the required class, containing the query result row |
|
623 | - */ |
|
624 | - public static function get_announcement($id) |
|
608 | + $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
609 | + $id = intval($id); |
|
610 | + $sql = "DELETE FROM ".$db_table." WHERE id =".$id; |
|
611 | + $res = Database::query($sql); |
|
612 | + if ($res === false) { |
|
613 | + |
|
614 | + return false; |
|
615 | + } |
|
616 | + return true; |
|
617 | + } |
|
618 | + |
|
619 | + /** |
|
620 | + * Gets an announcement |
|
621 | + * @param int $id The identifier of the announcement that should be |
|
622 | + * @return object Object of class StdClass or the required class, containing the query result row |
|
623 | + */ |
|
624 | + public static function get_announcement($id) |
|
625 | 625 | { |
626 | - $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
627 | - $id = intval($id); |
|
628 | - $sql = "SELECT * FROM ".$db_table." WHERE id = ".$id; |
|
629 | - $announcement = Database::fetch_object(Database::query($sql)); |
|
630 | - |
|
631 | - return $announcement; |
|
632 | - } |
|
633 | - |
|
634 | - /** |
|
635 | - * Change the visibility of an announcement |
|
636 | - * @param int $announcement_id |
|
637 | - * @param int $user For who should the visibility be changed |
|
626 | + $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
627 | + $id = intval($id); |
|
628 | + $sql = "SELECT * FROM ".$db_table." WHERE id = ".$id; |
|
629 | + $announcement = Database::fetch_object(Database::query($sql)); |
|
630 | + |
|
631 | + return $announcement; |
|
632 | + } |
|
633 | + |
|
634 | + /** |
|
635 | + * Change the visibility of an announcement |
|
636 | + * @param int $announcement_id |
|
637 | + * @param int $user For who should the visibility be changed |
|
638 | 638 | * (possible values are VISIBLE_TEACHER, VISIBLE_STUDENT, VISIBLE_GUEST) |
639 | - * @return bool True on success, false on failure |
|
640 | - */ |
|
641 | - public static function set_visibility($announcement_id, $user, $visible) |
|
639 | + * @return bool True on success, false on failure |
|
640 | + */ |
|
641 | + public static function set_visibility($announcement_id, $user, $visible) |
|
642 | 642 | { |
643 | - $db_table = Database::get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
644 | - $visible = intval($visible); |
|
645 | - $announcement_id = intval($announcement_id); |
|
643 | + $db_table = Database::get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
644 | + $visible = intval($visible); |
|
645 | + $announcement_id = intval($announcement_id); |
|
646 | 646 | |
647 | 647 | if (!in_array($user, array(self::VISIBLE_GUEST, self::VISIBLE_STUDENT, self::VISIBLE_TEACHER))) { |
648 | 648 | return false; |
649 | 649 | } |
650 | 650 | |
651 | - $field = ($user == self::VISIBLE_TEACHER ? 'visible_teacher' : ($user == self::VISIBLE_STUDENT ? 'visible_student' : 'visible_guest')); |
|
651 | + $field = ($user == self::VISIBLE_TEACHER ? 'visible_teacher' : ($user == self::VISIBLE_STUDENT ? 'visible_student' : 'visible_guest')); |
|
652 | 652 | |
653 | - $sql = "UPDATE ".$db_table." SET ".$field." = '".$visible."' |
|
653 | + $sql = "UPDATE ".$db_table." SET ".$field." = '".$visible."' |
|
654 | 654 | WHERE id='".$announcement_id."'"; |
655 | - $res = Database::query($sql); |
|
656 | - |
|
657 | - if ($res === false) { |
|
658 | - return false; |
|
659 | - } |
|
660 | - |
|
661 | - return true; |
|
662 | - } |
|
663 | - |
|
664 | - /** |
|
665 | - * Send a system announcement by e-mail to all teachers/students depending on parameters |
|
666 | - * @param string Title |
|
667 | - * @param string Content |
|
668 | - * @param int Whether to send to all teachers (1) or not (0) |
|
669 | - * @param int Whether to send to all students (1) or not (0) |
|
670 | - * @param string Language (optional, considered for all languages if left empty) |
|
655 | + $res = Database::query($sql); |
|
656 | + |
|
657 | + if ($res === false) { |
|
658 | + return false; |
|
659 | + } |
|
660 | + |
|
661 | + return true; |
|
662 | + } |
|
663 | + |
|
664 | + /** |
|
665 | + * Send a system announcement by e-mail to all teachers/students depending on parameters |
|
666 | + * @param string Title |
|
667 | + * @param string Content |
|
668 | + * @param int Whether to send to all teachers (1) or not (0) |
|
669 | + * @param int Whether to send to all students (1) or not (0) |
|
670 | + * @param string Language (optional, considered for all languages if left empty) |
|
671 | 671 | * @return bool True if the message was sent or there was no destination matching. False on database or e-mail sending error. |
672 | - */ |
|
673 | - public static function send_system_announcement_by_email($title, $content, $teacher, $student, $language = null, $sendEmailTest = false) |
|
672 | + */ |
|
673 | + public static function send_system_announcement_by_email($title, $content, $teacher, $student, $language = null, $sendEmailTest = false) |
|
674 | 674 | { |
675 | - global $charset; |
|
675 | + global $charset; |
|
676 | 676 | |
677 | 677 | $title = api_html_entity_decode(stripslashes($title), ENT_QUOTES, $charset); |
678 | 678 | $content = api_html_entity_decode(stripslashes(str_replace(array('\r\n', '\n', '\r'),'', $content)), ENT_QUOTES, $charset); |
@@ -691,22 +691,22 @@ discard block |
||
691 | 691 | } |
692 | 692 | |
693 | 693 | if ($teacher <> 0 AND $student == 0) { |
694 | - $sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE status = '1' "; |
|
695 | - } |
|
694 | + $sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE status = '1' "; |
|
695 | + } |
|
696 | 696 | |
697 | - if ($teacher == 0 AND $student <> 0) { |
|
698 | - $sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE status = '5' "; |
|
699 | - } |
|
697 | + if ($teacher == 0 AND $student <> 0) { |
|
698 | + $sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE status = '5' "; |
|
699 | + } |
|
700 | 700 | |
701 | - if ($teacher<> 0 AND $student <> 0) { |
|
702 | - $sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE 1 = 1 "; |
|
703 | - } |
|
701 | + if ($teacher<> 0 AND $student <> 0) { |
|
702 | + $sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE 1 = 1 "; |
|
703 | + } |
|
704 | 704 | |
705 | - if (!empty($language)) { //special condition because language was already treated for SQL insert before |
|
706 | - $sql .= " AND language = '".Database::escape_string($language)."' "; |
|
707 | - } |
|
705 | + if (!empty($language)) { //special condition because language was already treated for SQL insert before |
|
706 | + $sql .= " AND language = '".Database::escape_string($language)."' "; |
|
707 | + } |
|
708 | 708 | |
709 | - if (api_is_multiple_url_enabled()) { |
|
709 | + if (api_is_multiple_url_enabled()) { |
|
710 | 710 | $sql .= " AND access_url_id = '".$current_access_url_id."' "; |
711 | 711 | } |
712 | 712 | |
@@ -716,25 +716,25 @@ discard block |
||
716 | 716 | // Expiration date |
717 | 717 | $sql .= " AND (expiration_date = '' OR expiration_date IS NULL OR expiration_date > '$now') "; |
718 | 718 | |
719 | - if ((empty($teacher) or $teacher == '0') AND (empty($student) or $student == '0')) { |
|
720 | - return true; |
|
721 | - } |
|
719 | + if ((empty($teacher) or $teacher == '0') AND (empty($student) or $student == '0')) { |
|
720 | + return true; |
|
721 | + } |
|
722 | 722 | |
723 | - $result = Database::query($sql); |
|
724 | - if ($result === false) { |
|
725 | - return false; |
|
726 | - } |
|
723 | + $result = Database::query($sql); |
|
724 | + if ($result === false) { |
|
725 | + return false; |
|
726 | + } |
|
727 | 727 | |
728 | 728 | $message_sent = false; |
729 | 729 | |
730 | - while ($row = Database::fetch_array($result,'ASSOC')) { |
|
730 | + while ($row = Database::fetch_array($result,'ASSOC')) { |
|
731 | 731 | MessageManager::send_message_simple($row['user_id'], $title, $content); |
732 | 732 | $message_sent = true; |
733 | - } |
|
734 | - return $message_sent; //true if at least one e-mail was sent |
|
735 | - } |
|
733 | + } |
|
734 | + return $message_sent; //true if at least one e-mail was sent |
|
735 | + } |
|
736 | 736 | |
737 | - /** |
|
737 | + /** |
|
738 | 738 | * Displays announcements as an slideshow |
739 | 739 | * @param int $visible VISIBLE_GUEST, VISIBLE_STUDENT or VISIBLE_TEACHER |
740 | 740 | * @param int $id The identifier of the announcement to display |
@@ -77,13 +77,13 @@ discard block |
||
77 | 77 | $is_certificate_mode = false; |
78 | 78 | |
79 | 79 | if (isset($_REQUEST['certificate']) && $_REQUEST['certificate'] == 'true') { |
80 | - $is_certificate_mode = true; |
|
80 | + $is_certificate_mode = true; |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | if ($is_certificate_mode) { |
84 | - $nameTools = get_lang('CreateCertificate'); |
|
84 | + $nameTools = get_lang('CreateCertificate'); |
|
85 | 85 | } else { |
86 | - $nameTools = get_lang('CreateDocument'); |
|
86 | + $nameTools = get_lang('CreateDocument'); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /* Constants and variables */ |
@@ -136,26 +136,26 @@ discard block |
||
136 | 136 | |
137 | 137 | // Please, do not modify this dirname formatting |
138 | 138 | if (strstr($dir, '..')) { |
139 | - $dir = '/'; |
|
139 | + $dir = '/'; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | if ($dir[0] == '.') { |
143 | - $dir = substr($dir, 1); |
|
143 | + $dir = substr($dir, 1); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | if ($dir[0] != '/') { |
147 | - $dir = '/'.$dir; |
|
147 | + $dir = '/'.$dir; |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | if ($dir[strlen($dir) - 1] != '/') { |
151 | - $dir .= '/'; |
|
151 | + $dir .= '/'; |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | if ($is_certificate_mode) { |
155 | - $document_id = DocumentManager::get_document_id(api_get_course_info(), '/certificates'); |
|
156 | - $document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id(), true); |
|
157 | - $folder_id = $document_data['id']; |
|
158 | - $dir = '/certificates/'; |
|
155 | + $document_id = DocumentManager::get_document_id(api_get_course_info(), '/certificates'); |
|
156 | + $document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id(), true); |
|
157 | + $folder_id = $document_data['id']; |
|
158 | + $dir = '/certificates/'; |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | $doc_tree = explode('/', $dir); |
@@ -166,16 +166,16 @@ discard block |
||
166 | 166 | |
167 | 167 | // Level correction for group documents. |
168 | 168 | if (!empty($group_properties['directory'])) { |
169 | - $count_dir = $count_dir > 0 ? $count_dir - 1 : 0; |
|
169 | + $count_dir = $count_dir > 0 ? $count_dir - 1 : 0; |
|
170 | 170 | } |
171 | 171 | } |
172 | 172 | $relative_url = ''; |
173 | 173 | for ($i = 0; $i < ($count_dir); $i++) { |
174 | - $relative_url .= '../'; |
|
174 | + $relative_url .= '../'; |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | if ($relative_url== '') { |
178 | - $relative_url = '/'; |
|
178 | + $relative_url = '/'; |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | $is_allowed_to_edit = api_is_allowed_to_edit(null, true); |
@@ -187,11 +187,11 @@ discard block |
||
187 | 187 | 'cols-size' => [2, 10, 0], |
188 | 188 | 'FullPage' => true, |
189 | 189 | 'InDocument' => true, |
190 | - 'CreateDocumentDir' => $relative_url, |
|
191 | - 'CreateDocumentWebDir' => (empty($group_properties['directory'])) |
|
192 | - ? api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/' |
|
193 | - : api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document'.$group_properties['directory'].'/', |
|
194 | - 'BaseHref' => api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$dir |
|
190 | + 'CreateDocumentDir' => $relative_url, |
|
191 | + 'CreateDocumentWebDir' => (empty($group_properties['directory'])) |
|
192 | + ? api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/' |
|
193 | + : api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document'.$group_properties['directory'].'/', |
|
194 | + 'BaseHref' => api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$dir |
|
195 | 195 | ); |
196 | 196 | |
197 | 197 | if ($is_certificate_mode) { |
@@ -203,36 +203,36 @@ discard block |
||
203 | 203 | $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; |
204 | 204 | |
205 | 205 | if (!is_dir($filepath)) { |
206 | - $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/'; |
|
207 | - $dir = '/'; |
|
206 | + $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/'; |
|
207 | + $dir = '/'; |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | $to_group_id = 0; |
211 | 211 | |
212 | 212 | if (!$is_certificate_mode) { |
213 | - if (api_is_in_group()) { |
|
214 | - $interbreadcrumb[] = array ("url" => "../group/group_space.php?".api_get_cidreq(), "name" => get_lang('GroupSpace')); |
|
215 | - $noPHP_SELF = true; |
|
216 | - $to_group_id = api_get_group_id(); |
|
217 | - $path = explode('/', $dir); |
|
218 | - if ('/'.$path[1] != $group_properties['directory']) { |
|
219 | - api_not_allowed(true); |
|
220 | - } |
|
221 | - } |
|
222 | - $interbreadcrumb[] = array("url" => "./document.php?curdirpath=".urlencode($dir)."&".api_get_cidreq(), "name" => get_lang('Documents')); |
|
213 | + if (api_is_in_group()) { |
|
214 | + $interbreadcrumb[] = array ("url" => "../group/group_space.php?".api_get_cidreq(), "name" => get_lang('GroupSpace')); |
|
215 | + $noPHP_SELF = true; |
|
216 | + $to_group_id = api_get_group_id(); |
|
217 | + $path = explode('/', $dir); |
|
218 | + if ('/'.$path[1] != $group_properties['directory']) { |
|
219 | + api_not_allowed(true); |
|
220 | + } |
|
221 | + } |
|
222 | + $interbreadcrumb[] = array("url" => "./document.php?curdirpath=".urlencode($dir)."&".api_get_cidreq(), "name" => get_lang('Documents')); |
|
223 | 223 | } else { |
224 | - $interbreadcrumb[]= array('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook')); |
|
224 | + $interbreadcrumb[]= array('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook')); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | if (!$is_allowed_in_course) { |
228 | - api_not_allowed(true); |
|
228 | + api_not_allowed(true); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | if (!($is_allowed_to_edit || |
232 | 232 | $_SESSION['group_member_with_upload_rights'] || |
233 | 233 | DocumentManager::is_my_shared_folder($userId, $dir, api_get_session_id())) |
234 | 234 | ) { |
235 | - api_not_allowed(true); |
|
235 | + api_not_allowed(true); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | /* Header */ |
@@ -240,10 +240,10 @@ discard block |
||
240 | 240 | |
241 | 241 | $display_dir = $dir; |
242 | 242 | if (isset($group_properties)) { |
243 | - $display_dir = explode('/', $dir); |
|
244 | - unset($display_dir[0]); |
|
245 | - unset($display_dir[1]); |
|
246 | - $display_dir = implode('/', $display_dir); |
|
243 | + $display_dir = explode('/', $dir); |
|
244 | + unset($display_dir[0]); |
|
245 | + unset($display_dir[1]); |
|
246 | + $display_dir = implode('/', $display_dir); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | $select_cat = isset($_GET['selectcat']) ? intval($_GET['selectcat']) : null; |
@@ -260,9 +260,9 @@ discard block |
||
260 | 260 | $form->addElement('header', $nameTools); |
261 | 261 | |
262 | 262 | if ($is_certificate_mode) {//added condition for certicate in gradebook |
263 | - $form->addElement('hidden','certificate','true',array('id'=>'certificate')); |
|
264 | - if (isset($_GET['selectcat'])) { |
|
265 | - $form->addElement('hidden','selectcat', $select_cat); |
|
263 | + $form->addElement('hidden','certificate','true',array('id'=>'certificate')); |
|
264 | + if (isset($_GET['selectcat'])) { |
|
265 | + $form->addElement('hidden','selectcat', $select_cat); |
|
266 | 266 | } |
267 | 267 | } |
268 | 268 | |
@@ -297,12 +297,12 @@ discard block |
||
297 | 297 | if ($is_certificate_mode) { |
298 | 298 | $form->addText('title', get_lang('CertificateName'), true, array('cols-size' => [2, 10, 0], 'autofocus')); |
299 | 299 | } else { |
300 | - $form->addText('title', get_lang('Title'), true, array('cols-size' => [2, 10, 0], 'autofocus')); |
|
300 | + $form->addText('title', get_lang('Title'), true, array('cols-size' => [2, 10, 0], 'autofocus')); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | // Show read-only box only in groups |
304 | 304 | if (!empty($groupId)) { |
305 | - $group[]= $form->createElement('checkbox', 'readonly', '', get_lang('ReadOnly')); |
|
305 | + $group[]= $form->createElement('checkbox', 'readonly', '', get_lang('ReadOnly')); |
|
306 | 306 | } |
307 | 307 | $form->addRule('title', get_lang('ThisFieldIsRequired'), 'required'); |
308 | 308 | $form->addRule('title', get_lang('FileExists'), 'callback', 'document_exists'); |
@@ -317,14 +317,14 @@ discard block |
||
317 | 317 | // new document created |
318 | 318 | |
319 | 319 | if (!$is_certificate_mode && |
320 | - !DocumentManager::is_my_shared_folder($userId, $dir, $current_session_id) |
|
320 | + !DocumentManager::is_my_shared_folder($userId, $dir, $current_session_id) |
|
321 | 321 | ) { |
322 | - $folders = DocumentManager::get_all_document_folders($_course, $to_group_id, $is_allowed_to_edit); |
|
322 | + $folders = DocumentManager::get_all_document_folders($_course, $to_group_id, $is_allowed_to_edit); |
|
323 | 323 | |
324 | - //$parent_select = $form->addElement('select', 'curdirpath', array(null, get_lang('DestinationDirectory'))); |
|
324 | + //$parent_select = $form->addElement('select', 'curdirpath', array(null, get_lang('DestinationDirectory'))); |
|
325 | 325 | $parent_select = $form->addSelect('curdirpath', get_lang('DestinationDirectory'),null, array('cols-size' => [2, 10, 0]) ); |
326 | - // Following two conditions copied from document.inc.php::build_directory_selector() |
|
327 | - $folder_titles = array(); |
|
326 | + // Following two conditions copied from document.inc.php::build_directory_selector() |
|
327 | + $folder_titles = array(); |
|
328 | 328 | |
329 | 329 | if (is_array($folders)) { |
330 | 330 | $escaped_folders = array(); |
@@ -362,22 +362,22 @@ discard block |
||
362 | 362 | } |
363 | 363 | } |
364 | 364 | |
365 | - if (empty($group_dir)) { |
|
366 | - $parent_select -> addOption(get_lang('HomeDirectory'), '/'); |
|
367 | - if (is_array($folders)) { |
|
368 | - foreach ($folders as & $folder) { |
|
369 | - //Hide some folders |
|
370 | - if ($folder=='/HotPotatoes_files' || $folder=='/certificates' || basename($folder)=='css') { |
|
365 | + if (empty($group_dir)) { |
|
366 | + $parent_select -> addOption(get_lang('HomeDirectory'), '/'); |
|
367 | + if (is_array($folders)) { |
|
368 | + foreach ($folders as & $folder) { |
|
369 | + //Hide some folders |
|
370 | + if ($folder=='/HotPotatoes_files' || $folder=='/certificates' || basename($folder)=='css') { |
|
371 | 371 | continue; |
372 | - } |
|
373 | - //Admin setting for Hide/Show the folders of all users |
|
374 | - if (api_get_setting('show_users_folders') == 'false' && |
|
372 | + } |
|
373 | + //Admin setting for Hide/Show the folders of all users |
|
374 | + if (api_get_setting('show_users_folders') == 'false' && |
|
375 | 375 | (strstr($folder, '/shared_folder') || strstr($folder, 'shared_folder_session_')) |
376 | 376 | ){ |
377 | - continue; |
|
378 | - } |
|
379 | - //Admin setting for Hide/Show Default folders to all users |
|
380 | - if (api_get_setting('show_default_folders') == 'false' && |
|
377 | + continue; |
|
378 | + } |
|
379 | + //Admin setting for Hide/Show Default folders to all users |
|
380 | + if (api_get_setting('show_default_folders') == 'false' && |
|
381 | 381 | ( |
382 | 382 | $folder == '/images' || |
383 | 383 | $folder == '/flash' || |
@@ -387,80 +387,80 @@ discard block |
||
387 | 387 | $folder == '/video/flv' |
388 | 388 | ) |
389 | 389 | ){ |
390 | - continue; |
|
391 | - } |
|
392 | - //Admin setting for Hide/Show chat history folder |
|
393 | - if (api_get_setting('show_chat_folder') == 'false' && |
|
390 | + continue; |
|
391 | + } |
|
392 | + //Admin setting for Hide/Show chat history folder |
|
393 | + if (api_get_setting('show_chat_folder') == 'false' && |
|
394 | 394 | $folder=='/chat_files' |
395 | 395 | ){ |
396 | - continue; |
|
397 | - } |
|
396 | + continue; |
|
397 | + } |
|
398 | 398 | |
399 | - $selected = (substr($dir,0,-1) == $folder) ? ' selected="selected"' : ''; |
|
400 | - $path_parts = explode('/', $folder); |
|
401 | - $folder_titles[$folder] = cut($folder_titles[$folder], 80); |
|
399 | + $selected = (substr($dir,0,-1) == $folder) ? ' selected="selected"' : ''; |
|
400 | + $path_parts = explode('/', $folder); |
|
401 | + $folder_titles[$folder] = cut($folder_titles[$folder], 80); |
|
402 | 402 | $space_counter =count($path_parts) - 2; |
403 | 403 | if ($space_counter > 0) { |
404 | 404 | $label = str_repeat(' ', $space_counter).' — '.$folder_titles[$folder]; |
405 | 405 | } else { |
406 | 406 | $label = ' — '.$folder_titles[$folder]; |
407 | 407 | } |
408 | - $parent_select -> addOption($label, $folder); |
|
409 | - if ($selected != '') { |
|
410 | - $parent_select->setSelected($folder); |
|
411 | - } |
|
412 | - } |
|
413 | - } |
|
414 | - } else { |
|
415 | - foreach ($folders as & $folder) { |
|
416 | - $selected = (substr($dir,0,-1)==$folder) ? ' selected="selected"' : ''; |
|
417 | - $label = $folder_titles[$folder]; |
|
418 | - if ($folder == $group_dir) { |
|
419 | - $label = '/ ('.get_lang('HomeDirectory').')'; |
|
420 | - } else { |
|
421 | - $path_parts = explode('/', str_replace($group_dir, '', $folder)); |
|
422 | - $label = cut($label, 80); |
|
423 | - $label = str_repeat(' ', count($path_parts) - 2).' — '.$label; |
|
424 | - } |
|
425 | - $parent_select -> addOption($label, $folder); |
|
426 | - if ($selected != '') { |
|
427 | - $parent_select->setSelected($folder); |
|
428 | - } |
|
429 | - } |
|
430 | - } |
|
408 | + $parent_select -> addOption($label, $folder); |
|
409 | + if ($selected != '') { |
|
410 | + $parent_select->setSelected($folder); |
|
411 | + } |
|
412 | + } |
|
413 | + } |
|
414 | + } else { |
|
415 | + foreach ($folders as & $folder) { |
|
416 | + $selected = (substr($dir,0,-1)==$folder) ? ' selected="selected"' : ''; |
|
417 | + $label = $folder_titles[$folder]; |
|
418 | + if ($folder == $group_dir) { |
|
419 | + $label = '/ ('.get_lang('HomeDirectory').')'; |
|
420 | + } else { |
|
421 | + $path_parts = explode('/', str_replace($group_dir, '', $folder)); |
|
422 | + $label = cut($label, 80); |
|
423 | + $label = str_repeat(' ', count($path_parts) - 2).' — '.$label; |
|
424 | + } |
|
425 | + $parent_select -> addOption($label, $folder); |
|
426 | + if ($selected != '') { |
|
427 | + $parent_select->setSelected($folder); |
|
428 | + } |
|
429 | + } |
|
430 | + } |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | $form->addHidden('dirValue', ''); |
434 | 434 | |
435 | 435 | if ($is_certificate_mode) { |
436 | - $form->addButtonCreate(get_lang('CreateCertificate')); |
|
436 | + $form->addButtonCreate(get_lang('CreateCertificate')); |
|
437 | 437 | } else { |
438 | - $form->addButtonCreate(get_lang('CreateDoc')); |
|
438 | + $form->addButtonCreate(get_lang('CreateDoc')); |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | $form->setDefaults($defaults); |
442 | 442 | |
443 | 443 | // If form validates -> save the new document |
444 | 444 | if ($form->validate()) { |
445 | - $values = $form->exportValues(); |
|
446 | - $readonly = isset($values['readonly']) ? 1 : 0; |
|
447 | - $values['title'] = trim($values['title']); |
|
445 | + $values = $form->exportValues(); |
|
446 | + $readonly = isset($values['readonly']) ? 1 : 0; |
|
447 | + $values['title'] = trim($values['title']); |
|
448 | 448 | |
449 | 449 | if (!empty($values['dirValue'])) { |
450 | 450 | $dir = $values['dirValue']; |
451 | 451 | } |
452 | 452 | |
453 | 453 | if ($dir[strlen($dir) - 1] != '/') { |
454 | - $dir .= '/'; |
|
455 | - } |
|
454 | + $dir .= '/'; |
|
455 | + } |
|
456 | 456 | $filepath = $filepath.$dir; |
457 | 457 | |
458 | 458 | // Setting the filename |
459 | - $filename = $values['title']; |
|
460 | - $filename = addslashes(trim($filename)); |
|
461 | - $filename = Security::remove_XSS($filename); |
|
462 | - $filename = api_replace_dangerous_char($filename); |
|
463 | - $filename = disable_dangerous_file($filename); |
|
459 | + $filename = $values['title']; |
|
460 | + $filename = addslashes(trim($filename)); |
|
461 | + $filename = Security::remove_XSS($filename); |
|
462 | + $filename = api_replace_dangerous_char($filename); |
|
463 | + $filename = disable_dangerous_file($filename); |
|
464 | 464 | $filename .= DocumentManager::getDocumentSuffix( |
465 | 465 | $_course, |
466 | 466 | api_get_session_id(), |
@@ -468,14 +468,14 @@ discard block |
||
468 | 468 | ); |
469 | 469 | |
470 | 470 | // Setting the title |
471 | - $title = $values['title']; |
|
471 | + $title = $values['title']; |
|
472 | 472 | |
473 | 473 | // Setting the extension |
474 | - $extension = 'html'; |
|
474 | + $extension = 'html'; |
|
475 | 475 | |
476 | - $content = Security::remove_XSS($values['content'], COURSEMANAGERLOWSECURITY); |
|
476 | + $content = Security::remove_XSS($values['content'], COURSEMANAGERLOWSECURITY); |
|
477 | 477 | |
478 | - /*if (strpos($content, '/css/frames.css') == false) { |
|
478 | + /*if (strpos($content, '/css/frames.css') == false) { |
|
479 | 479 | $content = str_replace('</head>', '<link rel="stylesheet" href="./css/frames.css" type="text/css" /><style> body{margin:50px;}</style></head>', $content); |
480 | 480 | }*/ |
481 | 481 | |
@@ -488,13 +488,13 @@ discard block |
||
488 | 488 | exit; |
489 | 489 | } |
490 | 490 | |
491 | - if ($fp = @fopen($filepath.$filename.'.'.$extension, 'w')) { |
|
492 | - //$content = str_replace(api_get_path(WEB_COURSE_PATH), $_configuration['url_append'].'/courses/', $content); |
|
493 | - $content = str_replace(api_get_path(WEB_COURSE_PATH), $_configuration['url_append'].api_get_path(REL_COURSE_PATH), $content); |
|
491 | + if ($fp = @fopen($filepath.$filename.'.'.$extension, 'w')) { |
|
492 | + //$content = str_replace(api_get_path(WEB_COURSE_PATH), $_configuration['url_append'].'/courses/', $content); |
|
493 | + $content = str_replace(api_get_path(WEB_COURSE_PATH), $_configuration['url_append'].api_get_path(REL_COURSE_PATH), $content); |
|
494 | 494 | |
495 | - fputs($fp, $content); |
|
496 | - fclose($fp); |
|
497 | - chmod($filepath.$filename.'.'.$extension, api_get_permissions_for_new_files()); |
|
495 | + fputs($fp, $content); |
|
496 | + fclose($fp); |
|
497 | + chmod($filepath.$filename.'.'.$extension, api_get_permissions_for_new_files()); |
|
498 | 498 | |
499 | 499 | /* |
500 | 500 | if (!is_dir($filepath.'css')) { |
@@ -512,8 +512,8 @@ discard block |
||
512 | 512 | api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'invisible', $userId, null, null, null, null, $current_session_id); |
513 | 513 | }*/ |
514 | 514 | |
515 | - $file_size = filesize($filepath.$filename.'.'.$extension); |
|
516 | - $save_file_path = $dir.$filename.'.'.$extension; |
|
515 | + $file_size = filesize($filepath.$filename.'.'.$extension); |
|
516 | + $save_file_path = $dir.$filename.'.'.$extension; |
|
517 | 517 | |
518 | 518 | $document_id = add_document( |
519 | 519 | $_course, |
@@ -525,8 +525,8 @@ discard block |
||
525 | 525 | $readonly |
526 | 526 | ); |
527 | 527 | |
528 | - if ($document_id) { |
|
529 | - api_item_property_update( |
|
528 | + if ($document_id) { |
|
529 | + api_item_property_update( |
|
530 | 530 | $_course, |
531 | 531 | TOOL_DOCUMENT, |
532 | 532 | $document_id, |
@@ -538,13 +538,13 @@ discard block |
||
538 | 538 | null, |
539 | 539 | $current_session_id |
540 | 540 | ); |
541 | - // Update parent folders |
|
542 | - item_property_update_on_folder($_course, $dir, $userId); |
|
543 | - $new_comment = isset($_POST['comment']) ? trim($_POST['comment']) : ''; |
|
544 | - $new_title = isset($_POST['title']) ? trim($_POST['title']) : ''; |
|
541 | + // Update parent folders |
|
542 | + item_property_update_on_folder($_course, $dir, $userId); |
|
543 | + $new_comment = isset($_POST['comment']) ? trim($_POST['comment']) : ''; |
|
544 | + $new_title = isset($_POST['title']) ? trim($_POST['title']) : ''; |
|
545 | 545 | $new_title = htmlspecialchars($new_title); |
546 | - if ($new_comment || $new_title) { |
|
547 | - $ct = ''; |
|
546 | + if ($new_comment || $new_title) { |
|
547 | + $ct = ''; |
|
548 | 548 | $params = []; |
549 | 549 | if ($new_comment) { |
550 | 550 | $params['comment'] = $new_comment; |
@@ -559,38 +559,38 @@ discard block |
||
559 | 559 | ['c_id = ? AND id = ?' => [$course_id, $document_id]] |
560 | 560 | ); |
561 | 561 | } |
562 | - } |
|
563 | - $dir= substr($dir,0,-1); |
|
564 | - $selectcat = ''; |
|
565 | - if (isset($_REQUEST['selectcat'])) |
|
566 | - $selectcat = "&selectcat=".Security::remove_XSS($_REQUEST['selectcat']); |
|
567 | - $certificate_condition = ''; |
|
568 | - if ($is_certificate_mode) { |
|
569 | - $df = DocumentManager::get_default_certificate_id($_course['code']); |
|
562 | + } |
|
563 | + $dir= substr($dir,0,-1); |
|
564 | + $selectcat = ''; |
|
565 | + if (isset($_REQUEST['selectcat'])) |
|
566 | + $selectcat = "&selectcat=".Security::remove_XSS($_REQUEST['selectcat']); |
|
567 | + $certificate_condition = ''; |
|
568 | + if ($is_certificate_mode) { |
|
569 | + $df = DocumentManager::get_default_certificate_id($_course['code']); |
|
570 | 570 | if (!isset($df)) { |
571 | 571 | DocumentManager::attach_gradebook_certificate ($_course['code'],$document_id); |
572 | - } |
|
573 | - $certificate_condition = '&certificate=true&curdirpath=/certificates'; |
|
574 | - } |
|
575 | - |
|
576 | - header('Location: document.php?'.api_get_cidreq().'&id='.$folder_id.$selectcat.$certificate_condition); |
|
577 | - exit(); |
|
578 | - } else { |
|
579 | - Display :: display_header($nameTools, 'Doc'); |
|
580 | - Display :: display_error_message(get_lang('Impossible')); |
|
581 | - Display :: display_footer(); |
|
582 | - } |
|
583 | - } else { |
|
584 | - Display :: display_header($nameTools, 'Doc'); |
|
585 | - Display :: display_error_message(get_lang('Impossible')); |
|
586 | - Display :: display_footer(); |
|
587 | - } |
|
572 | + } |
|
573 | + $certificate_condition = '&certificate=true&curdirpath=/certificates'; |
|
574 | + } |
|
575 | + |
|
576 | + header('Location: document.php?'.api_get_cidreq().'&id='.$folder_id.$selectcat.$certificate_condition); |
|
577 | + exit(); |
|
578 | + } else { |
|
579 | + Display :: display_header($nameTools, 'Doc'); |
|
580 | + Display :: display_error_message(get_lang('Impossible')); |
|
581 | + Display :: display_footer(); |
|
582 | + } |
|
583 | + } else { |
|
584 | + Display :: display_header($nameTools, 'Doc'); |
|
585 | + Display :: display_error_message(get_lang('Impossible')); |
|
586 | + Display :: display_footer(); |
|
587 | + } |
|
588 | 588 | } else { |
589 | - // Copied from document.php |
|
590 | - $dir_array = explode('/', $dir); |
|
591 | - $array_len = count($dir_array); |
|
589 | + // Copied from document.php |
|
590 | + $dir_array = explode('/', $dir); |
|
591 | + $array_len = count($dir_array); |
|
592 | 592 | |
593 | - // Breadcrumb for the current directory root path |
|
593 | + // Breadcrumb for the current directory root path |
|
594 | 594 | if (!empty($document_data)) { |
595 | 595 | if (empty($document_data['parents'])) { |
596 | 596 | $interbreadcrumb[] = array( |
@@ -607,31 +607,31 @@ discard block |
||
607 | 607 | } |
608 | 608 | } |
609 | 609 | |
610 | - Display :: display_header($nameTools, "Doc"); |
|
611 | - // actions |
|
610 | + Display :: display_header($nameTools, "Doc"); |
|
611 | + // actions |
|
612 | 612 | |
613 | - // link back to the documents overview |
|
614 | - if ($is_certificate_mode) { |
|
615 | - $actionsLeft = '<a href="document.php?certificate=true&id='.$folder_id.'&selectcat=' . Security::remove_XSS($_GET['selectcat']).'">'. |
|
613 | + // link back to the documents overview |
|
614 | + if ($is_certificate_mode) { |
|
615 | + $actionsLeft = '<a href="document.php?certificate=true&id='.$folder_id.'&selectcat=' . Security::remove_XSS($_GET['selectcat']).'">'. |
|
616 | 616 | Display::return_icon('back.png',get_lang('Back').' '.get_lang('To').' '.get_lang('CertificateOverview'),'',ICON_SIZE_MEDIUM).'</a>'; |
617 | 617 | } else { |
618 | - $actionsLeft = '<a href="document.php?curdirpath='.Security::remove_XSS($dir).'">'. |
|
618 | + $actionsLeft = '<a href="document.php?curdirpath='.Security::remove_XSS($dir).'">'. |
|
619 | 619 | Display::return_icon('back.png',get_lang('Back').' '.get_lang('To').' '.get_lang('DocumentsOverview'),'',ICON_SIZE_MEDIUM).'</a>'; |
620 | 620 | } |
621 | 621 | |
622 | 622 | echo $toolbar = Display::toolbarAction('actions-documents', array(0 => $actionsLeft, 1 => '')); |
623 | 623 | |
624 | 624 | |
625 | - if ($is_certificate_mode) { |
|
626 | - $all_information_by_create_certificate = DocumentManager::get_all_info_to_certificate(api_get_user_id(), api_get_course_id()); |
|
625 | + if ($is_certificate_mode) { |
|
626 | + $all_information_by_create_certificate = DocumentManager::get_all_info_to_certificate(api_get_user_id(), api_get_course_id()); |
|
627 | 627 | |
628 | - $str_info = ''; |
|
629 | - foreach ($all_information_by_create_certificate[0] as $info_value) { |
|
630 | - $str_info.=$info_value.'<br/>'; |
|
631 | - } |
|
632 | - $create_certificate = get_lang('CreateCertificateWithTags'); |
|
633 | - Display::display_normal_message($create_certificate.': <br /><br/>'.$str_info,false); |
|
634 | - } |
|
628 | + $str_info = ''; |
|
629 | + foreach ($all_information_by_create_certificate[0] as $info_value) { |
|
630 | + $str_info.=$info_value.'<br/>'; |
|
631 | + } |
|
632 | + $create_certificate = get_lang('CreateCertificateWithTags'); |
|
633 | + Display::display_normal_message($create_certificate.': <br /><br/>'.$str_info,false); |
|
634 | + } |
|
635 | 635 | // HTML-editor |
636 | 636 | echo '<div class="row" style="overflow:hidden"> |
637 | 637 | <div id="template_col" class="col-md-2"> |
@@ -648,5 +648,5 @@ discard block |
||
648 | 648 | '.$form->returnForm().' |
649 | 649 | </div> |
650 | 650 | </div>'; |
651 | - Display :: display_footer(); |
|
651 | + Display :: display_footer(); |
|
652 | 652 | } |
@@ -26,7 +26,7 @@ |
||
26 | 26 | parent::__construct('1.1', 'Valery Fremaux'); |
27 | 27 | } |
28 | 28 | |
29 | - function pix_url($pixname, $size = 16) { |
|
29 | + function pix_url($pixname, $size = 16) { |
|
30 | 30 | global $_configuration; |
31 | 31 | |
32 | 32 | if (file_exists($_configuration['root_sys'].'/plugin/customplugin/pix/'.$pixname.'.png')){ |
@@ -50,26 +50,26 @@ discard block |
||
50 | 50 | // Please, do not modify this dirname formatting |
51 | 51 | |
52 | 52 | if (strstr($dir, '..')) { |
53 | - $dir = '/'; |
|
53 | + $dir = '/'; |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | if ($dir[0] == '.') { |
57 | - $dir = substr($dir, 1); |
|
57 | + $dir = substr($dir, 1); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | if ($dir[0] != '/') { |
61 | - $dir = '/'.$dir; |
|
61 | + $dir = '/'.$dir; |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | if ($dir[strlen($dir) - 1] != '/') { |
65 | - $dir .= '/'; |
|
65 | + $dir .= '/'; |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$dir; |
69 | 69 | |
70 | 70 | if (!is_dir($filepath)) { |
71 | - $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/'; |
|
72 | - $dir = '/'; |
|
71 | + $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/'; |
|
72 | + $dir = '/'; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | $groupId = api_get_group_id(); |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | } |
98 | 98 | |
99 | 99 | if (!($is_allowed_to_edit || $_SESSION['group_member_with_upload_rights'] || |
100 | - DocumentManager::is_my_shared_folder($_user['user_id'], Security::remove_XSS($dir), api_get_session_id())) |
|
100 | + DocumentManager::is_my_shared_folder($_user['user_id'], Security::remove_XSS($dir), api_get_session_id())) |
|
101 | 101 | ) { |
102 | 102 | api_not_allowed(true); |
103 | 103 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | |
115 | 115 | // Interbreadcrumb for the current directory root path |
116 | 116 | if (empty($document_data['parents'])) { |
117 | - $interbreadcrumb[] = array('url' => '#', 'name' => $document_data['title']); |
|
117 | + $interbreadcrumb[] = array('url' => '#', 'name' => $document_data['title']); |
|
118 | 118 | } else { |
119 | 119 | foreach ($document_data['parents'] as $document_sub_data) { |
120 | 120 | $interbreadcrumb[] = array('url' => $document_sub_data['document_url'], 'name' => $document_sub_data['title']); |
@@ -147,17 +147,17 @@ discard block |
||
147 | 147 | $locktitle="false"; |
148 | 148 | |
149 | 149 | if ($_SERVER['HTTP_HOST']=="localhost") { |
150 | - $path_and_file= api_get_path(SYS_PATH).'/crossdomain.xml'; |
|
151 | - if (!file_exists($path_and_file)) { |
|
152 | - $crossdomain='<?xml version="1.0"?> |
|
150 | + $path_and_file= api_get_path(SYS_PATH).'/crossdomain.xml'; |
|
151 | + if (!file_exists($path_and_file)) { |
|
152 | + $crossdomain='<?xml version="1.0"?> |
|
153 | 153 | <!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd"> |
154 | 154 | <cross-domain-policy> |
155 | 155 | <allow-access-from domain="cdn.pixlr.com" /> |
156 | 156 | <site-control permitted-cross-domain-policies="master-only"/> |
157 | 157 | <allow-http-request-headers-from domain="cnd.pixlr.com" headers="*" secure="true"/> |
158 | 158 | </cross-domain-policy>';//more open domain="*" |
159 | - @file_put_contents($path_and_file, $crossdomain); |
|
160 | - } |
|
159 | + @file_put_contents($path_and_file, $crossdomain); |
|
160 | + } |
|
161 | 161 | $credentials = "true"; |
162 | 162 | } else { |
163 | 163 | $credentials = "false"; |
@@ -10,166 +10,166 @@ |
||
10 | 10 | */ |
11 | 11 | class ResultTable extends SortableTable |
12 | 12 | { |
13 | - private $datagen; |
|
14 | - private $evaluation; |
|
15 | - private $allresults; |
|
16 | - private $iscourse; |
|
17 | - |
|
18 | - /** |
|
19 | - * Constructor |
|
20 | - */ |
|
13 | + private $datagen; |
|
14 | + private $evaluation; |
|
15 | + private $allresults; |
|
16 | + private $iscourse; |
|
17 | + |
|
18 | + /** |
|
19 | + * Constructor |
|
20 | + */ |
|
21 | 21 | public function __construct($evaluation, $results = array(), $iscourse, $addparams = null,$forprint = false) |
22 | - { |
|
23 | - parent :: __construct('resultlist', null, null, (api_is_western_name_order() xor api_sort_by_first_name()) ? 2 : 1); |
|
24 | - |
|
25 | - $this->datagen = new ResultsDataGenerator($evaluation, $results, true); |
|
26 | - |
|
27 | - $this->evaluation = $evaluation; |
|
28 | - $this->iscourse = $iscourse; |
|
29 | - $this->forprint = $forprint; |
|
30 | - |
|
31 | - if (isset ($addparams)) { |
|
32 | - $this->set_additional_parameters($addparams); |
|
33 | - } |
|
34 | - $scoredisplay = ScoreDisplay :: instance(); |
|
35 | - $column= 0; |
|
36 | - if ($this->iscourse == '1') { |
|
37 | - $this->set_header($column++, '', false); |
|
38 | - $this->set_form_actions(array ( |
|
39 | - 'delete' => get_lang('Delete') |
|
40 | - )); |
|
41 | - } |
|
42 | - if (api_is_western_name_order()) { |
|
43 | - $this->set_header($column++, get_lang('FirstName')); |
|
44 | - $this->set_header($column++, get_lang('LastName')); |
|
45 | - } else { |
|
46 | - $this->set_header($column++, get_lang('LastName')); |
|
47 | - $this->set_header($column++, get_lang('FirstName')); |
|
48 | - } |
|
49 | - $this->set_header($column++, get_lang('Score')); |
|
50 | - if ($scoredisplay->is_custom()) { |
|
51 | - $this->set_header($column++, get_lang('Display')); |
|
52 | - } |
|
53 | - if (!$this->forprint) { |
|
54 | - $this->set_header($column++, get_lang('Modify'),false); |
|
55 | - } |
|
22 | + { |
|
23 | + parent :: __construct('resultlist', null, null, (api_is_western_name_order() xor api_sort_by_first_name()) ? 2 : 1); |
|
24 | + |
|
25 | + $this->datagen = new ResultsDataGenerator($evaluation, $results, true); |
|
26 | + |
|
27 | + $this->evaluation = $evaluation; |
|
28 | + $this->iscourse = $iscourse; |
|
29 | + $this->forprint = $forprint; |
|
30 | + |
|
31 | + if (isset ($addparams)) { |
|
32 | + $this->set_additional_parameters($addparams); |
|
33 | + } |
|
34 | + $scoredisplay = ScoreDisplay :: instance(); |
|
35 | + $column= 0; |
|
36 | + if ($this->iscourse == '1') { |
|
37 | + $this->set_header($column++, '', false); |
|
38 | + $this->set_form_actions(array ( |
|
39 | + 'delete' => get_lang('Delete') |
|
40 | + )); |
|
41 | + } |
|
42 | + if (api_is_western_name_order()) { |
|
43 | + $this->set_header($column++, get_lang('FirstName')); |
|
44 | + $this->set_header($column++, get_lang('LastName')); |
|
45 | + } else { |
|
46 | + $this->set_header($column++, get_lang('LastName')); |
|
47 | + $this->set_header($column++, get_lang('FirstName')); |
|
48 | + } |
|
49 | + $this->set_header($column++, get_lang('Score')); |
|
50 | + if ($scoredisplay->is_custom()) { |
|
51 | + $this->set_header($column++, get_lang('Display')); |
|
52 | + } |
|
53 | + if (!$this->forprint) { |
|
54 | + $this->set_header($column++, get_lang('Modify'),false); |
|
55 | + } |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | |
59 | - /** |
|
60 | - * Function used by SortableTable to get total number of items in the table |
|
61 | - */ |
|
62 | - public function get_total_number_of_items () |
|
59 | + /** |
|
60 | + * Function used by SortableTable to get total number of items in the table |
|
61 | + */ |
|
62 | + public function get_total_number_of_items () |
|
63 | 63 | { |
64 | - return $this->datagen->get_total_results_count(); |
|
65 | - } |
|
66 | - |
|
67 | - /** |
|
68 | - * Function used by SortableTable to generate the data to display |
|
69 | - */ |
|
70 | - public function get_table_data($from = 1, $per_page = null, $column = null, $direction = null, $sort = null) { |
|
71 | - |
|
72 | - $is_western_name_order = api_is_western_name_order(); |
|
73 | - $scoredisplay = ScoreDisplay :: instance(); |
|
74 | - |
|
75 | - // determine sorting type |
|
76 | - $col_adjust = $this->iscourse == '1' ? 1 : 0; |
|
77 | - |
|
78 | - switch ($this->column) { |
|
79 | - // first name or last name |
|
80 | - case (0 + $col_adjust): |
|
81 | - if ($is_western_name_order) { |
|
82 | - $sorting = ResultsDataGenerator :: RDG_SORT_FIRSTNAME; |
|
83 | - } else { |
|
84 | - $sorting = ResultsDataGenerator :: RDG_SORT_LASTNAME; |
|
85 | - } |
|
86 | - break; |
|
64 | + return $this->datagen->get_total_results_count(); |
|
65 | + } |
|
66 | + |
|
67 | + /** |
|
68 | + * Function used by SortableTable to generate the data to display |
|
69 | + */ |
|
70 | + public function get_table_data($from = 1, $per_page = null, $column = null, $direction = null, $sort = null) { |
|
71 | + |
|
72 | + $is_western_name_order = api_is_western_name_order(); |
|
73 | + $scoredisplay = ScoreDisplay :: instance(); |
|
74 | + |
|
75 | + // determine sorting type |
|
76 | + $col_adjust = $this->iscourse == '1' ? 1 : 0; |
|
77 | + |
|
78 | + switch ($this->column) { |
|
87 | 79 | // first name or last name |
88 | - case (1 + $col_adjust): |
|
89 | - if ($is_western_name_order) { |
|
90 | - $sorting = ResultsDataGenerator :: RDG_SORT_LASTNAME; |
|
91 | - } else { |
|
92 | - $sorting = ResultsDataGenerator :: RDG_SORT_FIRSTNAME; |
|
93 | - } |
|
94 | - break; |
|
80 | + case (0 + $col_adjust): |
|
81 | + if ($is_western_name_order) { |
|
82 | + $sorting = ResultsDataGenerator :: RDG_SORT_FIRSTNAME; |
|
83 | + } else { |
|
84 | + $sorting = ResultsDataGenerator :: RDG_SORT_LASTNAME; |
|
85 | + } |
|
86 | + break; |
|
87 | + // first name or last name |
|
88 | + case (1 + $col_adjust): |
|
89 | + if ($is_western_name_order) { |
|
90 | + $sorting = ResultsDataGenerator :: RDG_SORT_LASTNAME; |
|
91 | + } else { |
|
92 | + $sorting = ResultsDataGenerator :: RDG_SORT_FIRSTNAME; |
|
93 | + } |
|
94 | + break; |
|
95 | 95 | //Score |
96 | - case (2 + $col_adjust): |
|
97 | - $sorting = ResultsDataGenerator :: RDG_SORT_SCORE; |
|
98 | - break; |
|
99 | - case (3 + $col_adjust): |
|
100 | - $sorting = ResultsDataGenerator :: RDG_SORT_MASK; |
|
101 | - break; |
|
102 | - } |
|
103 | - |
|
104 | - if ($this->direction == 'DESC') { |
|
105 | - $sorting |= ResultsDataGenerator :: RDG_SORT_DESC; |
|
106 | - } else { |
|
107 | - $sorting |= ResultsDataGenerator :: RDG_SORT_ASC; |
|
108 | - } |
|
109 | - |
|
110 | - $data_array = $this->datagen->get_data($sorting, $from, $this->per_page); |
|
111 | - |
|
112 | - // generate the data to display |
|
113 | - $sortable_data = array(); |
|
114 | - foreach ($data_array as $item) { |
|
115 | - $row = array (); |
|
116 | - if ($this->iscourse == '1') { |
|
117 | - $row[] = $item['result_id']; |
|
118 | - } |
|
119 | - if ($is_western_name_order) { |
|
120 | - $row[] = $item['firstname']; |
|
121 | - $row[] = $item['lastname']; |
|
122 | - } else { |
|
123 | - $row[] = $item['lastname']; |
|
124 | - $row[] = $item['firstname']; |
|
125 | - } |
|
126 | - |
|
127 | - $row[] = Display::bar_progress($item['percentage_score'], false, $item['score']); |
|
96 | + case (2 + $col_adjust): |
|
97 | + $sorting = ResultsDataGenerator :: RDG_SORT_SCORE; |
|
98 | + break; |
|
99 | + case (3 + $col_adjust): |
|
100 | + $sorting = ResultsDataGenerator :: RDG_SORT_MASK; |
|
101 | + break; |
|
102 | + } |
|
103 | + |
|
104 | + if ($this->direction == 'DESC') { |
|
105 | + $sorting |= ResultsDataGenerator :: RDG_SORT_DESC; |
|
106 | + } else { |
|
107 | + $sorting |= ResultsDataGenerator :: RDG_SORT_ASC; |
|
108 | + } |
|
109 | + |
|
110 | + $data_array = $this->datagen->get_data($sorting, $from, $this->per_page); |
|
111 | + |
|
112 | + // generate the data to display |
|
113 | + $sortable_data = array(); |
|
114 | + foreach ($data_array as $item) { |
|
115 | + $row = array (); |
|
116 | + if ($this->iscourse == '1') { |
|
117 | + $row[] = $item['result_id']; |
|
118 | + } |
|
119 | + if ($is_western_name_order) { |
|
120 | + $row[] = $item['firstname']; |
|
121 | + $row[] = $item['lastname']; |
|
122 | + } else { |
|
123 | + $row[] = $item['lastname']; |
|
124 | + $row[] = $item['firstname']; |
|
125 | + } |
|
126 | + |
|
127 | + $row[] = Display::bar_progress($item['percentage_score'], false, $item['score']); |
|
128 | 128 | //$row[] = Display::bar_progress($item['percentage_score'], true); |
129 | - if ($scoredisplay->is_custom()) { |
|
130 | - $row[] = $item['display']; |
|
131 | - } |
|
132 | - if (!$this->forprint) { |
|
133 | - $row[] = $this->build_edit_column ($item); |
|
134 | - } |
|
135 | - $sortable_data[] = $row; |
|
136 | - } |
|
137 | - |
|
138 | - return $sortable_data; |
|
139 | - } |
|
140 | - |
|
141 | - private function build_edit_column ($item) |
|
142 | - { |
|
143 | - $status = CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id()); |
|
144 | - $locked_status = $this->evaluation->get_locked(); |
|
145 | - if (api_is_allowed_to_edit(null, true) && $locked_status == 0) { |
|
146 | - //api_is_course_admin() |
|
147 | - $edit_column = '<a href="' . api_get_self() . '?editres=' . $item['result_id'] . '&selecteval=' . $this->evaluation->get_id().'&'.api_get_cidreq().'">'. |
|
148 | - Display::return_icon('edit.png', get_lang('Modify'),'','22').'</a>'; |
|
149 | - $edit_column .= ' <a href="' . api_get_self() . '?delete_mark=' . $item['result_id'] . '&selecteval=' . $this->evaluation->get_id().'&'.api_get_cidreq().'">'. |
|
150 | - Display::return_icon('delete.png', get_lang('Delete'),'','22').'</a>'; |
|
151 | - } |
|
152 | - |
|
153 | - if ($this->evaluation->get_course_code() == null) { |
|
154 | - $edit_column .= ' <a href="' . api_get_self() . '?resultdelete=' . $item['result_id'] . '&selecteval=' . $this->evaluation->get_id() . '" onclick="return confirmationuser();">'; |
|
155 | - $edit_column .= Display::return_icon('delete.png', get_lang('Delete')); |
|
156 | - $edit_column .= '</a>'; |
|
157 | - $edit_column .= ' <a href="user_stats.php?userid=' . $item['id'] . '&selecteval=' . $this->evaluation->get_id() . '&'.api_get_cidreq().'">'; |
|
158 | - $edit_column .= Display::return_icon('statistics.gif', get_lang('Statistics')); |
|
159 | - $edit_column .= '</a>'; |
|
160 | - } |
|
161 | - |
|
162 | - // Evaluation's origin is a link |
|
163 | - if ($this->evaluation->get_category_id() < 0) { |
|
164 | - $link = LinkFactory::get_evaluation_link($this->evaluation->get_id()); |
|
165 | - $doc_url = $link->get_view_url($item['id']); |
|
166 | - |
|
167 | - if ($doc_url != null) { |
|
168 | - $edit_column .= ' <a href="'. $doc_url . '" target="_blank">'; |
|
169 | - $edit_column .= Display::return_icon('link.gif', get_lang('OpenDocument')).'</a>'; |
|
170 | - } |
|
171 | - } |
|
172 | - |
|
173 | - return $edit_column; |
|
174 | - } |
|
129 | + if ($scoredisplay->is_custom()) { |
|
130 | + $row[] = $item['display']; |
|
131 | + } |
|
132 | + if (!$this->forprint) { |
|
133 | + $row[] = $this->build_edit_column ($item); |
|
134 | + } |
|
135 | + $sortable_data[] = $row; |
|
136 | + } |
|
137 | + |
|
138 | + return $sortable_data; |
|
139 | + } |
|
140 | + |
|
141 | + private function build_edit_column ($item) |
|
142 | + { |
|
143 | + $status = CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id()); |
|
144 | + $locked_status = $this->evaluation->get_locked(); |
|
145 | + if (api_is_allowed_to_edit(null, true) && $locked_status == 0) { |
|
146 | + //api_is_course_admin() |
|
147 | + $edit_column = '<a href="' . api_get_self() . '?editres=' . $item['result_id'] . '&selecteval=' . $this->evaluation->get_id().'&'.api_get_cidreq().'">'. |
|
148 | + Display::return_icon('edit.png', get_lang('Modify'),'','22').'</a>'; |
|
149 | + $edit_column .= ' <a href="' . api_get_self() . '?delete_mark=' . $item['result_id'] . '&selecteval=' . $this->evaluation->get_id().'&'.api_get_cidreq().'">'. |
|
150 | + Display::return_icon('delete.png', get_lang('Delete'),'','22').'</a>'; |
|
151 | + } |
|
152 | + |
|
153 | + if ($this->evaluation->get_course_code() == null) { |
|
154 | + $edit_column .= ' <a href="' . api_get_self() . '?resultdelete=' . $item['result_id'] . '&selecteval=' . $this->evaluation->get_id() . '" onclick="return confirmationuser();">'; |
|
155 | + $edit_column .= Display::return_icon('delete.png', get_lang('Delete')); |
|
156 | + $edit_column .= '</a>'; |
|
157 | + $edit_column .= ' <a href="user_stats.php?userid=' . $item['id'] . '&selecteval=' . $this->evaluation->get_id() . '&'.api_get_cidreq().'">'; |
|
158 | + $edit_column .= Display::return_icon('statistics.gif', get_lang('Statistics')); |
|
159 | + $edit_column .= '</a>'; |
|
160 | + } |
|
161 | + |
|
162 | + // Evaluation's origin is a link |
|
163 | + if ($this->evaluation->get_category_id() < 0) { |
|
164 | + $link = LinkFactory::get_evaluation_link($this->evaluation->get_id()); |
|
165 | + $doc_url = $link->get_view_url($item['id']); |
|
166 | + |
|
167 | + if ($doc_url != null) { |
|
168 | + $edit_column .= ' <a href="'. $doc_url . '" target="_blank">'; |
|
169 | + $edit_column .= Display::return_icon('link.gif', get_lang('OpenDocument')).'</a>'; |
|
170 | + } |
|
171 | + } |
|
172 | + |
|
173 | + return $edit_column; |
|
174 | + } |
|
175 | 175 | } |
@@ -61,44 +61,44 @@ discard block |
||
61 | 61 | /* Please, do not modify this dirname formatting */ |
62 | 62 | |
63 | 63 | if (strstr($dir, '..')) { |
64 | - $dir = '/'; |
|
64 | + $dir = '/'; |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | if ($dir[0] == '.') { |
68 | - $dir = substr($dir, 1); |
|
68 | + $dir = substr($dir, 1); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | if ($dir[0] != '/') { |
72 | - $dir = '/'.$dir; |
|
72 | + $dir = '/'.$dir; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | if ($dir[strlen($dir) - 1] != '/') { |
76 | - $dir .= '/'; |
|
76 | + $dir .= '/'; |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$dir; |
80 | 80 | |
81 | 81 | if (!is_dir($filepath)) { |
82 | - $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/'; |
|
83 | - $dir = '/'; |
|
82 | + $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/'; |
|
83 | + $dir = '/'; |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | //groups //TODO:clean |
87 | 87 | if (!empty($groupId)) { |
88 | - $interbreadcrumb[] = array( |
|
89 | - 'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(), |
|
90 | - 'name' => get_lang('GroupSpace'), |
|
91 | - ); |
|
92 | - $group_document = true; |
|
93 | - $noPHP_SELF = true; |
|
88 | + $interbreadcrumb[] = array( |
|
89 | + 'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(), |
|
90 | + 'name' => get_lang('GroupSpace'), |
|
91 | + ); |
|
92 | + $group_document = true; |
|
93 | + $noPHP_SELF = true; |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | $is_certificate_mode = DocumentManager::is_certificate_mode($dir); |
97 | 97 | |
98 | 98 | if (!$is_certificate_mode) |
99 | - $interbreadcrumb[]= array("url" => "./document.php?curdirpath=".urlencode($my_cur_dir_path).'&'.api_get_cidreq(), "name"=> get_lang('Documents')); |
|
99 | + $interbreadcrumb[]= array("url" => "./document.php?curdirpath=".urlencode($my_cur_dir_path).'&'.api_get_cidreq(), "name"=> get_lang('Documents')); |
|
100 | 100 | else |
101 | - $interbreadcrumb[]= array ('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook')); |
|
101 | + $interbreadcrumb[]= array ('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook')); |
|
102 | 102 | |
103 | 103 | // Interbreadcrumb for the current directory root path |
104 | 104 | if (empty($document_data['parents'])) { |
@@ -113,10 +113,10 @@ discard block |
||
113 | 113 | } |
114 | 114 | |
115 | 115 | $is_allowedToEdit = api_is_allowed_to_edit(null, true) || $_SESSION['group_member_with_upload_rights'] || |
116 | - DocumentManager::is_my_shared_folder(api_get_user_id(), $dir, $current_session_id); |
|
116 | + DocumentManager::is_my_shared_folder(api_get_user_id(), $dir, $current_session_id); |
|
117 | 117 | |
118 | 118 | if (!$is_allowedToEdit) { |
119 | - api_not_allowed(true); |
|
119 | + api_not_allowed(true); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | Event::event_access_tool(TOOL_DOCUMENT); |
@@ -148,21 +148,21 @@ discard block |
||
148 | 148 | $locktitle="false"; |
149 | 149 | |
150 | 150 | if ($_SERVER['HTTP_HOST']=="localhost") { |
151 | - $path_and_file= api_get_path(SYS_PATH).'/crossdomain.xml'; |
|
152 | - if (!file_exists($path_and_file)) { |
|
153 | - $crossdomain='<?xml version="1.0"?> |
|
151 | + $path_and_file= api_get_path(SYS_PATH).'/crossdomain.xml'; |
|
152 | + if (!file_exists($path_and_file)) { |
|
153 | + $crossdomain='<?xml version="1.0"?> |
|
154 | 154 | <!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd"> |
155 | 155 | <cross-domain-policy> |
156 | 156 | <allow-access-from domain="cdn.pixlr.com" /> |
157 | 157 | <site-control permitted-cross-domain-policies="master-only"/> |
158 | 158 | <allow-http-request-headers-from domain="cnd.pixlr.com" headers="*" secure="true"/> |
159 | 159 | </cross-domain-policy>';//more open domain="*" |
160 | - @file_put_contents($path_and_file, $crossdomain); |
|
161 | - } |
|
162 | - $credentials="true"; |
|
160 | + @file_put_contents($path_and_file, $crossdomain); |
|
161 | + } |
|
162 | + $credentials="true"; |
|
163 | 163 | } |
164 | 164 | else { |
165 | - $credentials="false"; |
|
165 | + $credentials="false"; |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | //make temp images |
@@ -175,23 +175,23 @@ discard block |
||
175 | 175 | $htaccess=api_get_path(SYS_ARCHIVE_PATH).'temp/images/.htaccess'; |
176 | 176 | if (!file_exists($htaccess)) { |
177 | 177 | |
178 | - $htaccess_content="order deny,allow\r\nallow from all\r\nOptions -Indexes"; |
|
178 | + $htaccess_content="order deny,allow\r\nallow from all\r\nOptions -Indexes"; |
|
179 | 179 | |
180 | - $fp = @ fopen(api_get_path(SYS_ARCHIVE_PATH).'temp/images/.htaccess', 'w'); |
|
181 | - if ($fp) { |
|
182 | - fwrite($fp, $htaccess_content); |
|
183 | - fclose($fp); |
|
184 | - } |
|
180 | + $fp = @ fopen(api_get_path(SYS_ARCHIVE_PATH).'temp/images/.htaccess', 'w'); |
|
181 | + if ($fp) { |
|
182 | + fwrite($fp, $htaccess_content); |
|
183 | + fclose($fp); |
|
184 | + } |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | $html_index=api_get_path(SYS_ARCHIVE_PATH).'temp/images/index.html'; |
188 | 188 | if (!file_exists($html_index)) { |
189 | - $html_index_content="<html><head></head><body></body></html>"; |
|
190 | - $fp = @ fopen(api_get_path(SYS_ARCHIVE_PATH).'temp/images/index.html', 'w'); |
|
191 | - if ($fp) { |
|
192 | - fwrite($fp, $html_index_content); |
|
193 | - fclose($fp); |
|
194 | - } |
|
189 | + $html_index_content="<html><head></head><body></body></html>"; |
|
190 | + $fp = @ fopen(api_get_path(SYS_ARCHIVE_PATH).'temp/images/index.html', 'w'); |
|
191 | + if ($fp) { |
|
192 | + fwrite($fp, $html_index_content); |
|
193 | + fclose($fp); |
|
194 | + } |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | //encript temp name file |