@@ -34,21 +34,21 @@ discard block |
||
34 | 34 | } |
35 | 35 | $categories[ADD_BLOCK] = get_lang('NewBloc'); |
36 | 36 | |
37 | -$i=1; |
|
37 | +$i = 1; |
|
38 | 38 | echo '<div class="actions" style="margin-bottom:30px">'; |
39 | 39 | echo '<a href="index.php?'.api_get_cidreq().'">'. |
40 | - Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('ToolCourseDescription'),'',ICON_SIZE_MEDIUM). |
|
40 | + Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('ToolCourseDescription'), '', ICON_SIZE_MEDIUM). |
|
41 | 41 | '</a>'; |
42 | 42 | |
43 | 43 | ksort($categories); |
44 | 44 | foreach ($categories as $id => $title) { |
45 | - if ($i==ADD_BLOCK) { |
|
45 | + if ($i == ADD_BLOCK) { |
|
46 | 46 | echo '<a href="index.php?'.api_get_cidreq().'&action=add">'. |
47 | - Display::return_icon($default_description_icon[$id], $title,'',ICON_SIZE_MEDIUM).'</a>'; |
|
47 | + Display::return_icon($default_description_icon[$id], $title, '', ICON_SIZE_MEDIUM).'</a>'; |
|
48 | 48 | break; |
49 | 49 | } else { |
50 | 50 | echo '<a href="index.php?action=edit&'.api_get_cidreq().'&description_type='.$id.'">'. |
51 | - Display::return_icon($default_description_icon[$id], $title,'',ICON_SIZE_MEDIUM).'</a>'; |
|
51 | + Display::return_icon($default_description_icon[$id], $title, '', ICON_SIZE_MEDIUM).'</a>'; |
|
52 | 52 | $i++; |
53 | 53 | } |
54 | 54 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | |
57 | 57 | // error messages |
58 | 58 | if (isset($error) && intval($error) == 1) { |
59 | - Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'),false); |
|
59 | + Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'), false); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | // default header title form |
@@ -10,67 +10,67 @@ discard block |
||
10 | 10 | // protect a course script |
11 | 11 | api_protect_course_script(true); |
12 | 12 | if (empty($id)) { |
13 | - $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : ''; |
|
14 | - if (empty($id)) { |
|
15 | - // If the ID was not provided, find the first matching description item given the item type |
|
16 | - $course_description = new CourseDescription(); |
|
17 | - $description = $course_description->get_data_by_description_type($description_type); |
|
18 | - if (count($description) > 0) { |
|
19 | - $id = $description['id']; |
|
20 | - } |
|
21 | - // If no corresponding description is found, edit a new one |
|
22 | - unset($course_description); |
|
23 | - } |
|
13 | + $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : ''; |
|
14 | + if (empty($id)) { |
|
15 | + // If the ID was not provided, find the first matching description item given the item type |
|
16 | + $course_description = new CourseDescription(); |
|
17 | + $description = $course_description->get_data_by_description_type($description_type); |
|
18 | + if (count($description) > 0) { |
|
19 | + $id = $description['id']; |
|
20 | + } |
|
21 | + // If no corresponding description is found, edit a new one |
|
22 | + unset($course_description); |
|
23 | + } |
|
24 | 24 | } |
25 | 25 | $original_id = $id; |
26 | 26 | |
27 | 27 | if (empty($error)) { |
28 | - $token = Security::get_token(); |
|
28 | + $token = Security::get_token(); |
|
29 | 29 | } |
30 | 30 | // display categories |
31 | 31 | $categories = array(); |
32 | 32 | foreach ($default_description_titles as $id => $title) { |
33 | - $categories[$id] = $title; |
|
33 | + $categories[$id] = $title; |
|
34 | 34 | } |
35 | 35 | $categories[ADD_BLOCK] = get_lang('NewBloc'); |
36 | 36 | |
37 | 37 | $i=1; |
38 | 38 | echo '<div class="actions" style="margin-bottom:30px">'; |
39 | 39 | echo '<a href="index.php?'.api_get_cidreq().'">'. |
40 | - Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('ToolCourseDescription'),'',ICON_SIZE_MEDIUM). |
|
41 | - '</a>'; |
|
40 | + Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('ToolCourseDescription'),'',ICON_SIZE_MEDIUM). |
|
41 | + '</a>'; |
|
42 | 42 | |
43 | 43 | ksort($categories); |
44 | 44 | foreach ($categories as $id => $title) { |
45 | - if ($i==ADD_BLOCK) { |
|
46 | - echo '<a href="index.php?'.api_get_cidreq().'&action=add">'. |
|
47 | - Display::return_icon($default_description_icon[$id], $title,'',ICON_SIZE_MEDIUM).'</a>'; |
|
48 | - break; |
|
49 | - } else { |
|
50 | - echo '<a href="index.php?action=edit&'.api_get_cidreq().'&description_type='.$id.'">'. |
|
51 | - Display::return_icon($default_description_icon[$id], $title,'',ICON_SIZE_MEDIUM).'</a>'; |
|
52 | - $i++; |
|
53 | - } |
|
45 | + if ($i==ADD_BLOCK) { |
|
46 | + echo '<a href="index.php?'.api_get_cidreq().'&action=add">'. |
|
47 | + Display::return_icon($default_description_icon[$id], $title,'',ICON_SIZE_MEDIUM).'</a>'; |
|
48 | + break; |
|
49 | + } else { |
|
50 | + echo '<a href="index.php?action=edit&'.api_get_cidreq().'&description_type='.$id.'">'. |
|
51 | + Display::return_icon($default_description_icon[$id], $title,'',ICON_SIZE_MEDIUM).'</a>'; |
|
52 | + $i++; |
|
53 | + } |
|
54 | 54 | } |
55 | 55 | echo '</div>'; |
56 | 56 | |
57 | 57 | // error messages |
58 | 58 | if (isset($error) && intval($error) == 1) { |
59 | - Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'),false); |
|
59 | + Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'),false); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | // default header title form |
63 | 63 | $description_type = intval($description_type); |
64 | 64 | $header = $default_description_titles[$description_type]; |
65 | 65 | if ($description_type >= ADD_BLOCK) { |
66 | - $header = $default_description_titles[ADD_BLOCK]; |
|
66 | + $header = $default_description_titles[ADD_BLOCK]; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | // display form |
70 | 70 | $form = new FormValidator( |
71 | - 'course_description', |
|
72 | - 'POST', |
|
73 | - 'index.php?action=edit&id='.$original_id.'&description_type='.$description_type.'&'.api_get_cidreq() |
|
71 | + 'course_description', |
|
72 | + 'POST', |
|
73 | + 'index.php?action=edit&id='.$original_id.'&description_type='.$description_type.'&'.api_get_cidreq() |
|
74 | 74 | ); |
75 | 75 | |
76 | 76 | $form->addElement('header', $header); |
@@ -80,15 +80,15 @@ discard block |
||
80 | 80 | $form->addText('title', get_lang('Title'), true, array('size' => '50')); |
81 | 81 | $form->applyFilter('title', 'html_filter'); |
82 | 82 | $form->addHtmlEditor( |
83 | - 'contentDescription', |
|
84 | - get_lang('Content'), |
|
85 | - true, |
|
86 | - false, |
|
87 | - array( |
|
88 | - 'ToolbarSet' => 'TrainingDescription', |
|
89 | - 'Width' => '100%', |
|
90 | - 'Height' => '200', |
|
91 | - ) |
|
83 | + 'contentDescription', |
|
84 | + get_lang('Content'), |
|
85 | + true, |
|
86 | + false, |
|
87 | + array( |
|
88 | + 'ToolbarSet' => 'TrainingDescription', |
|
89 | + 'Width' => '100%', |
|
90 | + 'Height' => '200', |
|
91 | + ) |
|
92 | 92 | ); |
93 | 93 | $form->addButtonCreate(get_lang('Save')); |
94 | 94 | |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | $form->setDefaults($default); |
105 | 105 | |
106 | 106 | if (isset ($question[$description_type])) { |
107 | - $message = '<strong>'.get_lang('QuestionPlan').'</strong><br />'; |
|
108 | - $message .= $question[$description_type]; |
|
109 | - Display::display_normal_message($message, false); |
|
107 | + $message = '<strong>'.get_lang('QuestionPlan').'</strong><br />'; |
|
108 | + $message .= $question[$description_type]; |
|
109 | + Display::display_normal_message($message, false); |
|
110 | 110 | } |
111 | 111 | $form->display(); |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * @param string tool name (optional) |
17 | 17 | * @param string $template_path |
18 | 18 | */ |
19 | - public function __construct($toolname = '', $template_path=null) |
|
19 | + public function __construct($toolname = '', $template_path = null) |
|
20 | 20 | { |
21 | 21 | if (!empty($toolname)) { |
22 | 22 | if (isset($template_path)) { |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | if (is_dir($path)) { |
28 | 28 | $this->tool_path = $path; |
29 | 29 | } else { |
30 | - throw new Exception('View::__construct() $path directory does not exist ' . $path); |
|
30 | + throw new Exception('View::__construct() $path directory does not exist '.$path); |
|
31 | 31 | } |
32 | 32 | } |
33 | 33 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | public function set_data($data) |
40 | 40 | { |
41 | 41 | if (!is_array($data)) { |
42 | - throw new Exception('View::set_data() $data must to be an array, you have sent a' . gettype( $data )); |
|
42 | + throw new Exception('View::set_data() $data must to be an array, you have sent a'.gettype($data)); |
|
43 | 43 | } |
44 | 44 | $this->data = $data; |
45 | 45 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @param string layout view |
50 | 50 | * @param string $layout |
51 | 51 | */ |
52 | - public function set_layout( $layout ) |
|
52 | + public function set_layout($layout) |
|
53 | 53 | { |
54 | 54 | $this->layout = $layout; |
55 | 55 | } |
@@ -25,29 +25,29 @@ |
||
25 | 25 | function search_courses($needle,$type) |
26 | 26 | { |
27 | 27 | $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION); |
28 | - $xajax_response = new xajaxResponse(); |
|
29 | - $return = ''; |
|
30 | - if(!empty($needle) && !empty($type)) { |
|
31 | - // xajax send utf8 datas... datas in db can be non-utf8 datas |
|
32 | - $charset = api_get_system_encoding(); |
|
33 | - $needle = api_convert_encoding($needle, $charset, 'utf-8'); |
|
34 | - $needle = Database::escape_string($needle); |
|
28 | + $xajax_response = new xajaxResponse(); |
|
29 | + $return = ''; |
|
30 | + if(!empty($needle) && !empty($type)) { |
|
31 | + // xajax send utf8 datas... datas in db can be non-utf8 datas |
|
32 | + $charset = api_get_system_encoding(); |
|
33 | + $needle = api_convert_encoding($needle, $charset, 'utf-8'); |
|
34 | + $needle = Database::escape_string($needle); |
|
35 | 35 | |
36 | - $sql = 'SELECT * FROM '.$tbl_session.' WHERE name LIKE "'.$needle.'%" ORDER BY id'; |
|
36 | + $sql = 'SELECT * FROM '.$tbl_session.' WHERE name LIKE "'.$needle.'%" ORDER BY id'; |
|
37 | 37 | |
38 | - $rs = Database::query($sql); |
|
39 | - $course_list = array(); |
|
38 | + $rs = Database::query($sql); |
|
39 | + $course_list = array(); |
|
40 | 40 | |
41 | - $return .= '<select id="origin" name="NoSessionCategoryList[]" multiple="multiple" size="20" style="width:340px;">'; |
|
42 | - while($course = Database :: fetch_array($rs)) { |
|
43 | - $course_list[] = $course['id']; |
|
44 | - $return .= '<option value="'.$course['id'].'" title="'.htmlspecialchars($course['name'],ENT_QUOTES).'">'.$course['name'].'</option>'; |
|
45 | - } |
|
46 | - $return .= '</select>'; |
|
47 | - $xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return)); |
|
48 | - } |
|
49 | - $_SESSION['course_list'] = $course_list; |
|
41 | + $return .= '<select id="origin" name="NoSessionCategoryList[]" multiple="multiple" size="20" style="width:340px;">'; |
|
42 | + while($course = Database :: fetch_array($rs)) { |
|
43 | + $course_list[] = $course['id']; |
|
44 | + $return .= '<option value="'.$course['id'].'" title="'.htmlspecialchars($course['name'],ENT_QUOTES).'">'.$course['name'].'</option>'; |
|
45 | + } |
|
46 | + $return .= '</select>'; |
|
47 | + $xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return)); |
|
48 | + } |
|
49 | + $_SESSION['course_list'] = $course_list; |
|
50 | 50 | |
51 | - return $xajax_response; |
|
52 | - } |
|
51 | + return $xajax_response; |
|
52 | + } |
|
53 | 53 | } |
@@ -22,12 +22,12 @@ discard block |
||
22 | 22 | * @assert () !== '' |
23 | 23 | * @assert ('abc','single') !== '' |
24 | 24 | */ |
25 | - function search_courses($needle,$type) |
|
25 | + function search_courses($needle, $type) |
|
26 | 26 | { |
27 | 27 | $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION); |
28 | 28 | $xajax_response = new xajaxResponse(); |
29 | 29 | $return = ''; |
30 | - if(!empty($needle) && !empty($type)) { |
|
30 | + if (!empty($needle) && !empty($type)) { |
|
31 | 31 | // xajax send utf8 datas... datas in db can be non-utf8 datas |
32 | 32 | $charset = api_get_system_encoding(); |
33 | 33 | $needle = api_convert_encoding($needle, $charset, 'utf-8'); |
@@ -39,12 +39,12 @@ discard block |
||
39 | 39 | $course_list = array(); |
40 | 40 | |
41 | 41 | $return .= '<select id="origin" name="NoSessionCategoryList[]" multiple="multiple" size="20" style="width:340px;">'; |
42 | - while($course = Database :: fetch_array($rs)) { |
|
42 | + while ($course = Database :: fetch_array($rs)) { |
|
43 | 43 | $course_list[] = $course['id']; |
44 | - $return .= '<option value="'.$course['id'].'" title="'.htmlspecialchars($course['name'],ENT_QUOTES).'">'.$course['name'].'</option>'; |
|
44 | + $return .= '<option value="'.$course['id'].'" title="'.htmlspecialchars($course['name'], ENT_QUOTES).'">'.$course['name'].'</option>'; |
|
45 | 45 | } |
46 | 46 | $return .= '</select>'; |
47 | - $xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return)); |
|
47 | + $xajax_response -> addAssign('ajax_list_courses_multiple', 'innerHTML', api_utf8_encode($return)); |
|
48 | 48 | } |
49 | 49 | $_SESSION['course_list'] = $course_list; |
50 | 50 |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | * This function saves a change in a wiki page |
259 | 259 | * @author Patrick Cool <[email protected]>, Ghent University |
260 | 260 | * @param array $values |
261 | - * @return language string saying that the changes are stored |
|
261 | + * @return string string saying that the changes are stored |
|
262 | 262 | **/ |
263 | 263 | public function save_wiki($values) |
264 | 264 | { |
@@ -1196,6 +1196,7 @@ discard block |
||
1196 | 1196 | * Checks if this navigation tab has to be set to active |
1197 | 1197 | * @author Patrick Cool <[email protected]>, Ghent University |
1198 | 1198 | * |
1199 | + * @param string $paramwk |
|
1199 | 1200 | * @return string html code |
1200 | 1201 | */ |
1201 | 1202 | public function is_active_navigation_tab($paramwk) |
@@ -1711,6 +1712,7 @@ discard block |
||
1711 | 1712 | |
1712 | 1713 | /** |
1713 | 1714 | * Sends pending e-mails |
1715 | + * @param string $type |
|
1714 | 1716 | */ |
1715 | 1717 | public function check_emailcue($id_or_ref, $type, $lastime='', $lastuser='') |
1716 | 1718 | { |
@@ -2011,6 +2013,7 @@ discard block |
||
2011 | 2013 | |
2012 | 2014 | /** |
2013 | 2015 | * Exports the wiki page to PDF |
2016 | + * @param string $course_code |
|
2014 | 2017 | */ |
2015 | 2018 | public function export_to_pdf($id, $course_code) |
2016 | 2019 | { |
@@ -2478,6 +2481,7 @@ discard block |
||
2478 | 2481 | /** |
2479 | 2482 | * Draws an HTML form select with the given options |
2480 | 2483 | * |
2484 | + * @param string $name |
|
2481 | 2485 | */ |
2482 | 2486 | public function make_select($name,$values,$checked='') |
2483 | 2487 | { |
@@ -2514,7 +2518,7 @@ discard block |
||
2514 | 2518 | /** |
2515 | 2519 | * Get wiki information |
2516 | 2520 | * @param int|bool wiki id |
2517 | - * @return array wiki data |
|
2521 | + * @return string wiki data |
|
2518 | 2522 | */ |
2519 | 2523 | public function getWikiDataFromDb($id) |
2520 | 2524 | { |
@@ -2561,6 +2565,7 @@ discard block |
||
2561 | 2565 | * Get wiki information |
2562 | 2566 | * @param string wiki id |
2563 | 2567 | * @param int $courseId |
2568 | + * @param string $title |
|
2564 | 2569 | * @return array wiki data |
2565 | 2570 | */ |
2566 | 2571 | public function getPageByTitle($title, $courseId = null) |
@@ -2593,6 +2598,8 @@ discard block |
||
2593 | 2598 | * @param int $courseId |
2594 | 2599 | * @param string |
2595 | 2600 | * @param string |
2601 | + * @param string $groupfilter |
|
2602 | + * @param string $condition_session |
|
2596 | 2603 | * @return bool |
2597 | 2604 | */ |
2598 | 2605 | public function deletePage($title, $courseId, $groupfilter = null, $condition_session = null) |
@@ -3644,6 +3651,7 @@ discard block |
||
3644 | 3651 | |
3645 | 3652 | /** |
3646 | 3653 | * Show all pages |
3654 | + * @param string $action |
|
3647 | 3655 | */ |
3648 | 3656 | public function allPages($action) |
3649 | 3657 | { |
@@ -4200,7 +4208,7 @@ discard block |
||
4200 | 4208 | |
4201 | 4209 | /** |
4202 | 4210 | * Restore page |
4203 | - * @return bool |
|
4211 | + * @return false|null |
|
4204 | 4212 | */ |
4205 | 4213 | public function restorePage() |
4206 | 4214 | { |
@@ -4302,7 +4310,7 @@ discard block |
||
4302 | 4310 | } |
4303 | 4311 | |
4304 | 4312 | /** |
4305 | - * @param int|bool $wikiId |
|
4313 | + * @param false|string $wikiId |
|
4306 | 4314 | */ |
4307 | 4315 | public function setWikiData($wikiId) |
4308 | 4316 | { |
@@ -99,12 +99,12 @@ discard block |
||
99 | 99 | **/ |
100 | 100 | public function links_to($input) |
101 | 101 | { |
102 | - $input_array = preg_split("/(\[\[|\]\])/",$input,-1, PREG_SPLIT_DELIM_CAPTURE); |
|
102 | + $input_array = preg_split("/(\[\[|\]\])/", $input, -1, PREG_SPLIT_DELIM_CAPTURE); |
|
103 | 103 | $all_links = array(); |
104 | 104 | |
105 | 105 | foreach ($input_array as $key=>$value) { |
106 | - if (isset($input_array[$key-1]) && $input_array[$key-1] == '[[' && |
|
107 | - isset($input_array[$key+1]) && $input_array[$key+1] == ']]' |
|
106 | + if (isset($input_array[$key - 1]) && $input_array[$key - 1] == '[[' && |
|
107 | + isset($input_array[$key + 1]) && $input_array[$key + 1] == ']]' |
|
108 | 108 | ) { |
109 | 109 | if (api_strpos($value, "|") !== false) { |
110 | 110 | $full_link_array = explode("|", $value); |
@@ -114,10 +114,10 @@ discard block |
||
114 | 114 | $link = trim($value); |
115 | 115 | $title = trim($value); |
116 | 116 | } |
117 | - unset($input_array[$key-1]); |
|
118 | - unset($input_array[$key+1]); |
|
117 | + unset($input_array[$key - 1]); |
|
118 | + unset($input_array[$key + 1]); |
|
119 | 119 | //replace blank spaces by _ within the links. But to remove links at the end add a blank space |
120 | - $all_links[]= Database::escape_string(str_replace(' ','_',$link)).' '; |
|
120 | + $all_links[] = Database::escape_string(str_replace(' ', '_', $link)).' '; |
|
121 | 121 | } |
122 | 122 | } |
123 | 123 | $output = implode($all_links); |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | **/ |
171 | 171 | public function detect_ftp_link($input) |
172 | 172 | { |
173 | - $ftplink='href="ftp'; |
|
173 | + $ftplink = 'href="ftp'; |
|
174 | 174 | $ftplinkStyle = 'class="wiki_ftp_link" href="ftp'; |
175 | 175 | $output = str_replace($ftplink, $ftplinkStyle, $input); |
176 | 176 | |
@@ -215,21 +215,21 @@ discard block |
||
215 | 215 | { |
216 | 216 | $groupId = api_get_group_id(); |
217 | 217 | //now doubles brackets |
218 | - $input_array = preg_split("/(\[\[|\]\])/",$input,-1, PREG_SPLIT_DELIM_CAPTURE); |
|
218 | + $input_array = preg_split("/(\[\[|\]\])/", $input, -1, PREG_SPLIT_DELIM_CAPTURE); |
|
219 | 219 | |
220 | 220 | foreach ($input_array as $key => $value) { |
221 | 221 | //now doubles brackets |
222 | - if (isset($input_array[$key-1]) && $input_array[$key-1] == '[[' AND |
|
223 | - $input_array[$key+1] == ']]' |
|
222 | + if (isset($input_array[$key - 1]) && $input_array[$key - 1] == '[[' AND |
|
223 | + $input_array[$key + 1] == ']]' |
|
224 | 224 | ) { |
225 | 225 | // now full wikilink |
226 | - if (api_strpos($value, "|") !== false){ |
|
227 | - $full_link_array=explode("|", $value); |
|
228 | - $link=trim(strip_tags($full_link_array[0])); |
|
229 | - $title=trim($full_link_array[1]); |
|
226 | + if (api_strpos($value, "|") !== false) { |
|
227 | + $full_link_array = explode("|", $value); |
|
228 | + $link = trim(strip_tags($full_link_array[0])); |
|
229 | + $title = trim($full_link_array[1]); |
|
230 | 230 | } else { |
231 | - $link=trim(strip_tags($value)); |
|
232 | - $title=trim($value); |
|
231 | + $link = trim(strip_tags($value)); |
|
232 | + $title = trim($value); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | //if wikilink is homepage |
@@ -241,14 +241,14 @@ discard block |
||
241 | 241 | } |
242 | 242 | |
243 | 243 | // note: checkreflink checks if the link is still free. If it is not used then it returns true, if it is used, then it returns false. Now the title may be different |
244 | - if (self::checktitle(strtolower(str_replace(' ','_',$link)))) { |
|
244 | + if (self::checktitle(strtolower(str_replace(' ', '_', $link)))) { |
|
245 | 245 | $link = api_html_entity_decode($link); |
246 | - $input_array[$key]='<a href="'.api_get_path(WEB_PATH).'main/wiki/index.php?'.api_get_cidreq().'&action=addnew&title='.Security::remove_XSS($link).'&group_id='.$groupId.'" class="new_wiki_link">'.$title.'</a>'; |
|
246 | + $input_array[$key] = '<a href="'.api_get_path(WEB_PATH).'main/wiki/index.php?'.api_get_cidreq().'&action=addnew&title='.Security::remove_XSS($link).'&group_id='.$groupId.'" class="new_wiki_link">'.$title.'</a>'; |
|
247 | 247 | } else { |
248 | - $input_array[$key]='<a href="'.api_get_path(WEB_PATH).'main/wiki/index.php?'.api_get_cidreq().'&action=showpage&title='.urlencode(strtolower(str_replace(' ','_',$link))).'&group_id='.$groupId.'" class="wiki_link">'.$title.'</a>'; |
|
248 | + $input_array[$key] = '<a href="'.api_get_path(WEB_PATH).'main/wiki/index.php?'.api_get_cidreq().'&action=showpage&title='.urlencode(strtolower(str_replace(' ', '_', $link))).'&group_id='.$groupId.'" class="wiki_link">'.$title.'</a>'; |
|
249 | 249 | } |
250 | - unset($input_array[$key-1]); |
|
251 | - unset($input_array[$key+1]); |
|
250 | + unset($input_array[$key - 1]); |
|
251 | + unset($input_array[$key + 1]); |
|
252 | 252 | } |
253 | 253 | } |
254 | 254 | $output = implode('', $input_array); |
@@ -294,11 +294,11 @@ discard block |
||
294 | 294 | // are not made here, but through the interce buttons |
295 | 295 | |
296 | 296 | // cleaning the variables |
297 | - if (api_get_setting('htmlpurifier_wiki') == 'true'){ |
|
297 | + if (api_get_setting('htmlpurifier_wiki') == 'true') { |
|
298 | 298 | //$purifier = new HTMLPurifier(); |
299 | 299 | $values['content'] = Security::remove_XSS($values['content']); |
300 | 300 | } |
301 | - $version = intval($values['version']) + 1 ; |
|
301 | + $version = intval($values['version']) + 1; |
|
302 | 302 | $linkTo = self::links_to($values['content']); //and check links content |
303 | 303 | |
304 | 304 | //cleaning config variables |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | $_clean['startdate_assig'] = null; |
322 | 322 | } |
323 | 323 | |
324 | - if (isset($values['initenddate']) && $values['initenddate']==1) { |
|
324 | + if (isset($values['initenddate']) && $values['initenddate'] == 1) { |
|
325 | 325 | $_clean['enddate_assig'] = $values['enddate_assig']; |
326 | 326 | } else { |
327 | 327 | $_clean['enddate_assig'] = null; |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | } |
333 | 333 | |
334 | 334 | if (!empty($values['max_text']) || !empty($values['max_version'])) { |
335 | - $_clean['max_text'] = $values['max_text']; |
|
335 | + $_clean['max_text'] = $values['max_text']; |
|
336 | 336 | $_clean['max_version'] = $values['max_version']; |
337 | 337 | } |
338 | 338 | |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | $groupId |
384 | 384 | ); |
385 | 385 | |
386 | - if ($values['page_id']== 0) { |
|
386 | + if ($values['page_id'] == 0) { |
|
387 | 387 | $sql = 'UPDATE '.$tbl_wiki.' SET page_id="'.$id.'" |
388 | 388 | WHERE c_id = '.$course_id.' AND iid ="'.$id.'"'; |
389 | 389 | Database::query($sql); |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | $_course = $this->courseInfo; |
468 | 468 | $r_user_id = api_get_user_id(); |
469 | 469 | $r_dtime = api_get_utc_datetime(); |
470 | - $r_version = $r_version+1; |
|
470 | + $r_version = $r_version + 1; |
|
471 | 471 | $r_comment = get_lang('RestoredFromVersion').': '.$c_version; |
472 | 472 | $session_id = api_get_session_id(); |
473 | 473 | $course_id = api_get_course_int_id(); |
@@ -572,9 +572,9 @@ discard block |
||
572 | 572 | // Unlike ordinary pages of pages of assignments. |
573 | 573 | // Allow create a ordinary page although there is a assignment with the same name |
574 | 574 | if ($_clean['assignment'] == 2 || $_clean['assignment'] == 1) { |
575 | - $page = str_replace(' ','_',$values['title']."_uass".$assig_user_id); |
|
575 | + $page = str_replace(' ', '_', $values['title']."_uass".$assig_user_id); |
|
576 | 576 | } else { |
577 | - $page = str_replace(' ','_',$values['title']); |
|
577 | + $page = str_replace(' ', '_', $values['title']); |
|
578 | 578 | } |
579 | 579 | $_clean['reflink'] = $page; |
580 | 580 | $_clean['title'] = trim($values['title']); |
@@ -728,7 +728,7 @@ discard block |
||
728 | 728 | */ |
729 | 729 | public function setForm($form, $row = array()) |
730 | 730 | { |
731 | - $toolBar = api_is_allowed_to_edit(null,true) |
|
731 | + $toolBar = api_is_allowed_to_edit(null, true) |
|
732 | 732 | ? array('ToolbarSet' => 'Wiki', 'Width' => '100%', 'Height' => '400') |
733 | 733 | : array('ToolbarSet' => 'WikiStudent', 'Width' => '100%', 'Height' => '400', 'UserStatus' => 'student'); |
734 | 734 | |
@@ -739,7 +739,7 @@ discard block |
||
739 | 739 | |
740 | 740 | $form->addElement('select', 'progress', get_lang('Progress'), $progress); |
741 | 741 | |
742 | - if ((api_is_allowed_to_edit(false,true) || |
|
742 | + if ((api_is_allowed_to_edit(false, true) || |
|
743 | 743 | api_is_platform_admin()) && |
744 | 744 | isset($row['reflink']) && $row['reflink'] != 'index' |
745 | 745 | ) { |
@@ -879,13 +879,13 @@ discard block |
||
879 | 879 | if ($newtitle) { |
880 | 880 | $pageMIX = $newtitle; //display the page after it is created |
881 | 881 | } else { |
882 | - $pageMIX = $page;//display current page |
|
882 | + $pageMIX = $page; //display current page |
|
883 | 883 | } |
884 | 884 | |
885 | 885 | $filter = null; |
886 | 886 | if (isset($_GET['view']) && $_GET['view']) { |
887 | 887 | $_clean['view'] = Database::escape_string($_GET['view']); |
888 | - $filter =' AND w.id="'.$_clean['view'].'"'; |
|
888 | + $filter = ' AND w.id="'.$_clean['view'].'"'; |
|
889 | 889 | } |
890 | 890 | |
891 | 891 | // First, check page visibility in the first page version |
@@ -929,7 +929,7 @@ discard block |
||
929 | 929 | $groupInfo = GroupManager::get_group_properties(api_get_group_id()); |
930 | 930 | |
931 | 931 | // if both are empty and we are displaying the index page then we display the default text. |
932 | - if ($row['content']=='' && $row['title']=='' && $page=='index') { |
|
932 | + if ($row['content'] == '' && $row['title'] == '' && $page == 'index') { |
|
933 | 933 | |
934 | 934 | if (api_is_allowed_to_edit(false, true) || |
935 | 935 | api_is_platform_admin() || |
@@ -937,8 +937,8 @@ discard block |
||
937 | 937 | api_is_allowed_in_course() |
938 | 938 | ) { |
939 | 939 | //Table structure for better export to pdf |
940 | - $default_table_for_content_Start='<table align="center" border="0"><tr><td align="center">'; |
|
941 | - $default_table_for_content_End='</td></tr></table>'; |
|
940 | + $default_table_for_content_Start = '<table align="center" border="0"><tr><td align="center">'; |
|
941 | + $default_table_for_content_End = '</td></tr></table>'; |
|
942 | 942 | $content = $default_table_for_content_Start. |
943 | 943 | sprintf(get_lang('DefaultContent'), api_get_path(WEB_IMG_PATH)). |
944 | 944 | $default_table_for_content_End; |
@@ -953,23 +953,23 @@ discard block |
||
953 | 953 | |
954 | 954 | //assignment mode: identify page type |
955 | 955 | $icon_assignment = null; |
956 | - if ($row['assignment']==1) { |
|
957 | - $icon_assignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'),'',ICON_SIZE_SMALL); |
|
958 | - } elseif($row['assignment']==2) { |
|
959 | - $icon_assignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL); |
|
956 | + if ($row['assignment'] == 1) { |
|
957 | + $icon_assignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'), '', ICON_SIZE_SMALL); |
|
958 | + } elseif ($row['assignment'] == 2) { |
|
959 | + $icon_assignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL); |
|
960 | 960 | } |
961 | 961 | |
962 | 962 | //task mode |
963 | 963 | $icon_task = null; |
964 | 964 | if (!empty($row['task'])) { |
965 | - $icon_task=Display::return_icon('wiki_task.png', get_lang('StandardTask'),'',ICON_SIZE_SMALL); |
|
965 | + $icon_task = Display::return_icon('wiki_task.png', get_lang('StandardTask'), '', ICON_SIZE_SMALL); |
|
966 | 966 | } |
967 | 967 | |
968 | 968 | // Show page. Show page to all users if isn't hide page. Mode assignments: if student is the author, can view |
969 | 969 | if ($KeyVisibility == "1" || |
970 | 970 | api_is_allowed_to_edit(false, true) || |
971 | 971 | api_is_platform_admin() || |
972 | - ($row['assignment'] == 2 && $KeyVisibility=="0" && (api_get_user_id() == $row['user_id'])) || |
|
972 | + ($row['assignment'] == 2 && $KeyVisibility == "0" && (api_get_user_id() == $row['user_id'])) || |
|
973 | 973 | api_is_allowed_in_course() |
974 | 974 | ) { |
975 | 975 | $actionsLeft = ''; |
@@ -995,13 +995,13 @@ discard block |
||
995 | 995 | $protect_page = null; |
996 | 996 | $lock_unlock_protect = null; |
997 | 997 | // page action: protecting (locking) the page |
998 | - if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { |
|
999 | - if (self::check_protect_page()==1) { |
|
998 | + if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { |
|
999 | + if (self::check_protect_page() == 1) { |
|
1000 | 1000 | $protect_page = Display::return_icon('lock.png', get_lang('PageLockedExtra'), '', ICON_SIZE_MEDIUM); |
1001 | - $lock_unlock_protect='unlock'; |
|
1001 | + $lock_unlock_protect = 'unlock'; |
|
1002 | 1002 | } else { |
1003 | 1003 | $protect_page = Display::return_icon('unlock.png', get_lang('PageUnlockedExtra'), '', ICON_SIZE_MEDIUM); |
1004 | - $lock_unlock_protect='lock'; |
|
1004 | + $lock_unlock_protect = 'lock'; |
|
1005 | 1005 | } |
1006 | 1006 | } |
1007 | 1007 | |
@@ -1013,13 +1013,13 @@ discard block |
||
1013 | 1013 | $visibility_page = null; |
1014 | 1014 | $lock_unlock_visibility = null; |
1015 | 1015 | //page action: visibility |
1016 | - if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { |
|
1016 | + if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { |
|
1017 | 1017 | if (self::check_visibility_page() == 1) { |
1018 | - $visibility_page = Display::return_icon('visible.png', get_lang('ShowPageExtra'),'', ICON_SIZE_MEDIUM); |
|
1018 | + $visibility_page = Display::return_icon('visible.png', get_lang('ShowPageExtra'), '', ICON_SIZE_MEDIUM); |
|
1019 | 1019 | $lock_unlock_visibility = 'invisible'; |
1020 | 1020 | |
1021 | 1021 | } else { |
1022 | - $visibility_page = Display::return_icon('invisible.png', get_lang('HidePageExtra'),'', ICON_SIZE_MEDIUM); |
|
1022 | + $visibility_page = Display::return_icon('invisible.png', get_lang('HidePageExtra'), '', ICON_SIZE_MEDIUM); |
|
1023 | 1023 | $lock_unlock_visibility = 'visible'; |
1024 | 1024 | } |
1025 | 1025 | } |
@@ -1031,11 +1031,11 @@ discard block |
||
1031 | 1031 | |
1032 | 1032 | //page action: notification |
1033 | 1033 | if (api_is_allowed_to_session_edit()) { |
1034 | - if (self::check_notify_page($page)==1) { |
|
1035 | - $notify_page = Display::return_icon('messagebox_info.png', get_lang('NotifyByEmail'),'',ICON_SIZE_MEDIUM); |
|
1034 | + if (self::check_notify_page($page) == 1) { |
|
1035 | + $notify_page = Display::return_icon('messagebox_info.png', get_lang('NotifyByEmail'), '', ICON_SIZE_MEDIUM); |
|
1036 | 1036 | $lock_unlock_notify_page = 'unlocknotify'; |
1037 | 1037 | } else { |
1038 | - $notify_page = Display::return_icon('mail.png', get_lang('CancelNotifyByEmail'),'',ICON_SIZE_MEDIUM); |
|
1038 | + $notify_page = Display::return_icon('mail.png', get_lang('CancelNotifyByEmail'), '', ICON_SIZE_MEDIUM); |
|
1039 | 1039 | $lock_unlock_notify_page = 'locknotify'; |
1040 | 1040 | } |
1041 | 1041 | } |
@@ -1047,33 +1047,33 @@ discard block |
||
1047 | 1047 | ) { |
1048 | 1048 | // menu discuss page |
1049 | 1049 | $actionsRight .= '<a href="index.php?'.api_get_cidreq().'&action=discuss&title='.api_htmlentities(urlencode($page)).'" '.self::is_active_navigation_tab('discuss').'>'. |
1050 | - Display::return_icon('discuss.png',get_lang('DiscussThisPage'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
1050 | + Display::return_icon('discuss.png', get_lang('DiscussThisPage'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
1051 | 1051 | } |
1052 | 1052 | |
1053 | 1053 | //menu history |
1054 | 1054 | $actionsRight .= '<a href="index.php?'.api_get_cidreq().'&action=history&title='.api_htmlentities(urlencode($page)).'" '.self::is_active_navigation_tab('history').'>'. |
1055 | - Display::return_icon('history.png',get_lang('ShowPageHistory'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
1055 | + Display::return_icon('history.png', get_lang('ShowPageHistory'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
1056 | 1056 | //menu linkspages |
1057 | 1057 | $actionsRight .= '<a href="index.php?'.api_get_cidreq().'action=links&title='.api_htmlentities(urlencode($page)).'" '.self::is_active_navigation_tab('links').'>'. |
1058 | - Display::return_icon('what_link_here.png',get_lang('LinksPages'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
1058 | + Display::return_icon('what_link_here.png', get_lang('LinksPages'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
1059 | 1059 | |
1060 | 1060 | //menu delete wikipage |
1061 | - if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { |
|
1061 | + if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { |
|
1062 | 1062 | $actionsRight .= '<a href="index.php?action=delete&'.api_get_cidreq().'&title='.api_htmlentities(urlencode($page)).'"'.self::is_active_navigation_tab('delete').'>'. |
1063 | - Display::return_icon('delete.png',get_lang('DeleteThisPage'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
1063 | + Display::return_icon('delete.png', get_lang('DeleteThisPage'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
1064 | 1064 | } |
1065 | 1065 | |
1066 | 1066 | $actionsRight .= '<a href="index.php?'.api_get_cidreq().'&action=showpage&actionpage='.$lock_unlock_notify_page.'&title='.api_htmlentities(urlencode($page)).'">'. |
1067 | 1067 | $notify_page.'</a>'; |
1068 | 1068 | |
1069 | 1069 | // Page action: copy last version to doc area |
1070 | - if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { |
|
1070 | + if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { |
|
1071 | 1071 | $actionsRight .= '<a href="index.php?'.api_get_cidreq().'&action=export2doc&wiki_id='.$row['id'].'">'. |
1072 | 1072 | Display::return_icon('export_to_documents.png', get_lang('ExportToDocArea'), '', ICON_SIZE_MEDIUM).'</a>'; |
1073 | 1073 | } |
1074 | 1074 | |
1075 | 1075 | $actionsRight .= '<a href="index.php?'.api_get_cidreq().'&action=export_to_pdf&wiki_id='.$row['id'].'">'. |
1076 | - Display::return_icon('pdf.png',get_lang('ExportToPDF'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
1076 | + Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
1077 | 1077 | |
1078 | 1078 | $unoconv = api_get_configuration_value('unoconv.binaries'); |
1079 | 1079 | if ($unoconv) { |
@@ -1126,7 +1126,7 @@ discard block |
||
1126 | 1126 | ) |
1127 | 1127 | ); |
1128 | 1128 | |
1129 | - $footerWiki = '<div id="wikifooter">'.get_lang('Progress').': '.($row['progress']*10).'% '.get_lang('Rating').': '.$row['score'].' '.get_lang('Words').': '.self::word_count($content).'</div>'; |
|
1129 | + $footerWiki = '<div id="wikifooter">'.get_lang('Progress').': '.($row['progress'] * 10).'% '.get_lang('Rating').': '.$row['score'].' '.get_lang('Words').': '.self::word_count($content).'</div>'; |
|
1130 | 1130 | |
1131 | 1131 | echo Display::panel($pageWiki, $pageTitle, $footerWiki); |
1132 | 1132 | } //end filter visibility |
@@ -1150,7 +1150,7 @@ discard block |
||
1150 | 1150 | |
1151 | 1151 | # strip all html tags |
1152 | 1152 | $wc = strip_tags($document); |
1153 | - $wc = html_entity_decode($wc, ENT_NOQUOTES, 'UTF-8');// TODO:test also old html_entity_decode(utf8_encode($wc)) |
|
1153 | + $wc = html_entity_decode($wc, ENT_NOQUOTES, 'UTF-8'); // TODO:test also old html_entity_decode(utf8_encode($wc)) |
|
1154 | 1154 | |
1155 | 1155 | # remove 'words' that don't consist of alphanumerical characters or punctuation. And fix accents and some letters |
1156 | 1156 | $pattern = "#[^(\w|\d|\'|\"|\.|\!|\?|;|,|\\|\/|\-|:|\&|@|á|é|í|ó|ú|à|è|ì|ò|ù|ä|ë|ï|ö|ü|Á|É|Í|Ó|Ú|À|È|Ò|Ù|Ä|Ë|Ï|Ö|Ü|â|ê|î|ô|û|Â|Ê|Î|Ô|Û|ñ|Ñ|ç|Ç)]+#"; |
@@ -1183,15 +1183,15 @@ discard block |
||
1183 | 1183 | |
1184 | 1184 | $course_id = api_get_course_int_id(); |
1185 | 1185 | |
1186 | - $sql='SELECT id FROM '.$tbl_wiki.' |
|
1186 | + $sql = 'SELECT id FROM '.$tbl_wiki.' |
|
1187 | 1187 | WHERE |
1188 | 1188 | c_id = '.$course_id.' AND |
1189 | 1189 | title="'.Database::escape_string($title).'" AND |
1190 | 1190 | '.$groupfilter.$condition_session.' |
1191 | 1191 | ORDER BY id ASC'; |
1192 | - $result=Database::query($sql); |
|
1193 | - $cant=Database::num_rows($result); |
|
1194 | - if ($cant>0) { |
|
1192 | + $result = Database::query($sql); |
|
1193 | + $cant = Database::num_rows($result); |
|
1194 | + if ($cant > 0) { |
|
1195 | 1195 | return true; |
1196 | 1196 | } else { |
1197 | 1197 | return false; |
@@ -1273,20 +1273,20 @@ discard block |
||
1273 | 1273 | $page = $this->page; |
1274 | 1274 | |
1275 | 1275 | $course_id = api_get_course_int_id(); |
1276 | - $sql='SELECT * FROM '.$tbl_wiki.' |
|
1276 | + $sql = 'SELECT * FROM '.$tbl_wiki.' |
|
1277 | 1277 | WHERE |
1278 | 1278 | c_id = '.$course_id.' AND |
1279 | 1279 | reflink="'.Database::escape_string($page).'" AND |
1280 | 1280 | '.$groupfilter.$condition_session.' |
1281 | 1281 | ORDER BY id ASC'; |
1282 | 1282 | |
1283 | - $result=Database::query($sql); |
|
1284 | - $row=Database::fetch_array($result); |
|
1283 | + $result = Database::query($sql); |
|
1284 | + $row = Database::fetch_array($result); |
|
1285 | 1285 | $status_editlock = $row['editlock']; |
1286 | 1286 | $id = $row['page_id']; |
1287 | 1287 | |
1288 | 1288 | ///change status |
1289 | - if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { |
|
1289 | + if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { |
|
1290 | 1290 | if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'lock' && $status_editlock == 0) { |
1291 | 1291 | $status_editlock = 1; |
1292 | 1292 | } |
@@ -1298,13 +1298,13 @@ discard block |
||
1298 | 1298 | WHERE c_id = '.$course_id.' AND page_id="'.$id.'"'; |
1299 | 1299 | Database::query($sql); |
1300 | 1300 | |
1301 | - $sql='SELECT * FROM '.$tbl_wiki.' |
|
1301 | + $sql = 'SELECT * FROM '.$tbl_wiki.' |
|
1302 | 1302 | WHERE |
1303 | 1303 | c_id = '.$course_id.' AND |
1304 | 1304 | reflink="'.Database::escape_string($page).'" AND |
1305 | 1305 | '.$groupfilter.$condition_session.' |
1306 | 1306 | ORDER BY id ASC'; |
1307 | - $result=Database::query($sql); |
|
1307 | + $result = Database::query($sql); |
|
1308 | 1308 | $row = Database::fetch_array($result); |
1309 | 1309 | } |
1310 | 1310 | |
@@ -1335,13 +1335,13 @@ discard block |
||
1335 | 1335 | $row = Database::fetch_array($result); |
1336 | 1336 | $status_visibility = $row['visibility']; |
1337 | 1337 | //change status |
1338 | - if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { |
|
1339 | - if (isset($_GET['actionpage']) && $_GET['actionpage']=='visible' && $status_visibility==0) { |
|
1340 | - $status_visibility=1; |
|
1338 | + if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { |
|
1339 | + if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'visible' && $status_visibility == 0) { |
|
1340 | + $status_visibility = 1; |
|
1341 | 1341 | |
1342 | 1342 | } |
1343 | - if (isset($_GET['actionpage']) && $_GET['actionpage']=='invisible' && $status_visibility==1) { |
|
1344 | - $status_visibility=0; |
|
1343 | + if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'invisible' && $status_visibility == 1) { |
|
1344 | + $status_visibility = 0; |
|
1345 | 1345 | } |
1346 | 1346 | |
1347 | 1347 | $sql = 'UPDATE '.$tbl_wiki.' SET visibility="'.Database::escape_string($status_visibility).'" |
@@ -1358,12 +1358,12 @@ discard block |
||
1358 | 1358 | reflink="'.Database::escape_string($page).'" AND |
1359 | 1359 | '.$groupfilter.$condition_session.' |
1360 | 1360 | ORDER BY id ASC'; |
1361 | - $result=Database::query($sql); |
|
1361 | + $result = Database::query($sql); |
|
1362 | 1362 | $row = Database::fetch_array($result); |
1363 | 1363 | } |
1364 | 1364 | |
1365 | 1365 | if (empty($row['id'])) { |
1366 | - $row['visibility']= 1; |
|
1366 | + $row['visibility'] = 1; |
|
1367 | 1367 | } |
1368 | 1368 | |
1369 | 1369 | //show status |
@@ -1390,18 +1390,18 @@ discard block |
||
1390 | 1390 | reflink="'.Database::escape_string($page).'" AND |
1391 | 1391 | '.$groupfilter.$condition_session.' |
1392 | 1392 | ORDER BY id ASC'; |
1393 | - $result=Database::query($sql); |
|
1394 | - $row=Database::fetch_array($result); |
|
1393 | + $result = Database::query($sql); |
|
1394 | + $row = Database::fetch_array($result); |
|
1395 | 1395 | |
1396 | 1396 | $status_visibility_disc = $row['visibility_disc']; |
1397 | 1397 | |
1398 | 1398 | //change status |
1399 | - if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { |
|
1400 | - if (isset($_GET['actionpage']) && $_GET['actionpage'] =='showdisc' && $status_visibility_disc==0) { |
|
1401 | - $status_visibility_disc=1; |
|
1399 | + if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { |
|
1400 | + if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'showdisc' && $status_visibility_disc == 0) { |
|
1401 | + $status_visibility_disc = 1; |
|
1402 | 1402 | } |
1403 | - if (isset($_GET['actionpage']) && $_GET['actionpage'] =='hidedisc' && $status_visibility_disc==1) { |
|
1404 | - $status_visibility_disc=0; |
|
1403 | + if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'hidedisc' && $status_visibility_disc == 1) { |
|
1404 | + $status_visibility_disc = 0; |
|
1405 | 1405 | } |
1406 | 1406 | |
1407 | 1407 | $sql = 'UPDATE '.$tbl_wiki.' SET visibility_disc="'.Database::escape_string($status_visibility_disc).'" |
@@ -1449,14 +1449,14 @@ discard block |
||
1449 | 1449 | $result = Database::query($sql); |
1450 | 1450 | $row = Database::fetch_array($result); |
1451 | 1451 | |
1452 | - $status_addlock_disc=$row['addlock_disc']; |
|
1452 | + $status_addlock_disc = $row['addlock_disc']; |
|
1453 | 1453 | |
1454 | 1454 | //change status |
1455 | 1455 | if (api_is_allowed_to_edit() || api_is_platform_admin()) { |
1456 | - if (isset($_GET['actionpage']) && $_GET['actionpage'] =='lockdisc' && $status_addlock_disc==0) { |
|
1456 | + if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'lockdisc' && $status_addlock_disc == 0) { |
|
1457 | 1457 | $status_addlock_disc = 1; |
1458 | 1458 | } |
1459 | - if (isset($_GET['actionpage']) && $_GET['actionpage'] =='unlockdisc' && $status_addlock_disc==1) { |
|
1459 | + if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'unlockdisc' && $status_addlock_disc == 1) { |
|
1460 | 1460 | $status_addlock_disc = 0; |
1461 | 1461 | } |
1462 | 1462 | |
@@ -1478,8 +1478,8 @@ discard block |
||
1478 | 1478 | reflink="'.Database::escape_string($page).'" AND |
1479 | 1479 | '.$groupfilter.$condition_session.' |
1480 | 1480 | ORDER BY id ASC'; |
1481 | - $result=Database::query($sql); |
|
1482 | - $row=Database::fetch_array($result); |
|
1481 | + $result = Database::query($sql); |
|
1482 | + $row = Database::fetch_array($result); |
|
1483 | 1483 | } |
1484 | 1484 | |
1485 | 1485 | return $row['addlock_disc']; |
@@ -1504,17 +1504,17 @@ discard block |
||
1504 | 1504 | reflink="'.Database::escape_string($page).'" AND |
1505 | 1505 | '.$groupfilter.$condition_session.' |
1506 | 1506 | ORDER BY id ASC'; |
1507 | - $result=Database::query($sql); |
|
1508 | - $row=Database::fetch_array($result); |
|
1509 | - $status_ratinglock_disc=$row['ratinglock_disc']; |
|
1507 | + $result = Database::query($sql); |
|
1508 | + $row = Database::fetch_array($result); |
|
1509 | + $status_ratinglock_disc = $row['ratinglock_disc']; |
|
1510 | 1510 | |
1511 | 1511 | //change status |
1512 | - if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { |
|
1513 | - if (isset($_GET['actionpage']) && $_GET['actionpage'] =='lockrating' && $status_ratinglock_disc==0) { |
|
1514 | - $status_ratinglock_disc=1; |
|
1512 | + if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { |
|
1513 | + if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'lockrating' && $status_ratinglock_disc == 0) { |
|
1514 | + $status_ratinglock_disc = 1; |
|
1515 | 1515 | } |
1516 | - if (isset($_GET['actionpage']) && $_GET['actionpage'] =='unlockrating' && $status_ratinglock_disc==1) { |
|
1517 | - $status_ratinglock_disc=0; |
|
1516 | + if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'unlockrating' && $status_ratinglock_disc == 1) { |
|
1517 | + $status_ratinglock_disc = 0; |
|
1518 | 1518 | } |
1519 | 1519 | |
1520 | 1520 | $sql = 'UPDATE '.$tbl_wiki.' |
@@ -1530,14 +1530,14 @@ discard block |
||
1530 | 1530 | // these three lines remain necessary. They do that by changing the |
1531 | 1531 | // page state is made when you press the button and not have to wait |
1532 | 1532 | // to change his page |
1533 | - $sql='SELECT * FROM '.$tbl_wiki.' |
|
1533 | + $sql = 'SELECT * FROM '.$tbl_wiki.' |
|
1534 | 1534 | WHERE |
1535 | 1535 | c_id = '.$course_id.' AND |
1536 | 1536 | reflink="'.Database::escape_string($page).'" AND |
1537 | 1537 | '.$groupfilter.$condition_session.' |
1538 | 1538 | ORDER BY id ASC'; |
1539 | - $result=Database::query($sql); |
|
1540 | - $row=Database::fetch_array($result); |
|
1539 | + $result = Database::query($sql); |
|
1540 | + $row = Database::fetch_array($result); |
|
1541 | 1541 | } |
1542 | 1542 | |
1543 | 1543 | return $row['ratinglock_disc']; |
@@ -1562,24 +1562,24 @@ discard block |
||
1562 | 1562 | $sql = 'SELECT * FROM '.$tbl_wiki.' |
1563 | 1563 | WHERE c_id = '.$course_id.' AND reflink="'.$reflink.'" AND '.$groupfilter.$condition_session.' |
1564 | 1564 | ORDER BY id ASC'; |
1565 | - $result=Database::query($sql); |
|
1566 | - $row=Database::fetch_array($result); |
|
1565 | + $result = Database::query($sql); |
|
1566 | + $row = Database::fetch_array($result); |
|
1567 | 1567 | $id = $row['id']; |
1568 | - $sql='SELECT * FROM '.$tbl_wiki_mailcue.' |
|
1568 | + $sql = 'SELECT * FROM '.$tbl_wiki_mailcue.' |
|
1569 | 1569 | WHERE c_id = '.$course_id.' AND id="'.$id.'" AND user_id="'.api_get_user_id().'" AND type="P"'; |
1570 | - $result=Database::query($sql); |
|
1571 | - $row=Database::fetch_array($result); |
|
1570 | + $result = Database::query($sql); |
|
1571 | + $row = Database::fetch_array($result); |
|
1572 | 1572 | |
1573 | 1573 | $idm = $row['id']; |
1574 | 1574 | |
1575 | 1575 | if (empty($idm)) { |
1576 | - $status_notify=0; |
|
1576 | + $status_notify = 0; |
|
1577 | 1577 | } else { |
1578 | - $status_notify=1; |
|
1578 | + $status_notify = 1; |
|
1579 | 1579 | } |
1580 | 1580 | |
1581 | 1581 | // Change status |
1582 | - if (isset($_GET['actionpage']) && $_GET['actionpage'] =='locknotify' && $status_notify==0) { |
|
1582 | + if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'locknotify' && $status_notify == 0) { |
|
1583 | 1583 | $sql = "SELECT id FROM $tbl_wiki_mailcue |
1584 | 1584 | WHERE c_id = $course_id AND id = $id AND user_id = $userId"; |
1585 | 1585 | $result = Database::query($sql); |
@@ -1588,18 +1588,18 @@ discard block |
||
1588 | 1588 | $exist = true; |
1589 | 1589 | } |
1590 | 1590 | if ($exist == false) { |
1591 | - $sql="INSERT INTO ".$tbl_wiki_mailcue." (c_id, id, user_id, type, group_id, session_id) VALUES |
|
1591 | + $sql = "INSERT INTO ".$tbl_wiki_mailcue." (c_id, id, user_id, type, group_id, session_id) VALUES |
|
1592 | 1592 | ($course_id, '".$id."','".api_get_user_id()."','P','".$groupId."','".$session_id."')"; |
1593 | 1593 | Database::query($sql); |
1594 | 1594 | } |
1595 | - $status_notify=1; |
|
1595 | + $status_notify = 1; |
|
1596 | 1596 | } |
1597 | 1597 | |
1598 | - if (isset($_GET['actionpage']) && $_GET['actionpage'] =='unlocknotify' && $status_notify==1) { |
|
1598 | + if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'unlocknotify' && $status_notify == 1) { |
|
1599 | 1599 | $sql = 'DELETE FROM '.$tbl_wiki_mailcue.' |
1600 | 1600 | WHERE id="'.$id.'" AND user_id="'.api_get_user_id().'" AND type="P" AND c_id = '.$course_id; |
1601 | 1601 | Database::query($sql); |
1602 | - $status_notify=0; |
|
1602 | + $status_notify = 0; |
|
1603 | 1603 | } |
1604 | 1604 | |
1605 | 1605 | return $status_notify; |
@@ -1625,9 +1625,9 @@ discard block |
||
1625 | 1625 | $sql = 'SELECT * FROM '.$tbl_wiki.' |
1626 | 1626 | WHERE c_id = '.$course_id.' AND reflink="'.$reflink.'" AND '.$groupfilter.$condition_session.' |
1627 | 1627 | ORDER BY id ASC'; |
1628 | - $result=Database::query($sql); |
|
1629 | - $row=Database::fetch_array($result); |
|
1630 | - $id=$row['id']; |
|
1628 | + $result = Database::query($sql); |
|
1629 | + $row = Database::fetch_array($result); |
|
1630 | + $id = $row['id']; |
|
1631 | 1631 | $sql = 'SELECT * FROM '.$tbl_wiki_mailcue.' |
1632 | 1632 | WHERE c_id = '.$course_id.' AND id="'.$id.'" AND user_id="'.api_get_user_id().'" AND type="D"'; |
1633 | 1633 | $result = Database::query($sql); |
@@ -1635,23 +1635,23 @@ discard block |
||
1635 | 1635 | $idm = $row['id']; |
1636 | 1636 | |
1637 | 1637 | if (empty($idm)) { |
1638 | - $status_notify_disc=0; |
|
1638 | + $status_notify_disc = 0; |
|
1639 | 1639 | } else { |
1640 | - $status_notify_disc=1; |
|
1640 | + $status_notify_disc = 1; |
|
1641 | 1641 | } |
1642 | 1642 | |
1643 | 1643 | //change status |
1644 | - if (isset($_GET['actionpage']) && $_GET['actionpage'] =='locknotifydisc' && $status_notify_disc==0) { |
|
1645 | - $sql="INSERT INTO ".$tbl_wiki_mailcue." (c_id, id, user_id, type, group_id, session_id) VALUES |
|
1644 | + if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'locknotifydisc' && $status_notify_disc == 0) { |
|
1645 | + $sql = "INSERT INTO ".$tbl_wiki_mailcue." (c_id, id, user_id, type, group_id, session_id) VALUES |
|
1646 | 1646 | ($course_id, '".$id."','".api_get_user_id()."','D','".$groupId."','".$session_id."')"; |
1647 | 1647 | Database::query($sql); |
1648 | - $status_notify_disc=1; |
|
1648 | + $status_notify_disc = 1; |
|
1649 | 1649 | } |
1650 | - if (isset($_GET['actionpage']) && $_GET['actionpage'] =='unlocknotifydisc' && $status_notify_disc==1) { |
|
1650 | + if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'unlocknotifydisc' && $status_notify_disc == 1) { |
|
1651 | 1651 | $sql = 'DELETE FROM '.$tbl_wiki_mailcue.' |
1652 | 1652 | WHERE c_id = '.$course_id.' AND id="'.$id.'" AND user_id="'.api_get_user_id().'" AND type="D" AND c_id = '.$course_id; |
1653 | 1653 | Database::query($sql); |
1654 | - $status_notify_disc=0; |
|
1654 | + $status_notify_disc = 0; |
|
1655 | 1655 | } |
1656 | 1656 | |
1657 | 1657 | return $status_notify_disc; |
@@ -1666,7 +1666,7 @@ discard block |
||
1666 | 1666 | $tbl_wiki_mailcue = $this->tbl_wiki_mailcue; |
1667 | 1667 | $course_id = api_get_course_int_id(); |
1668 | 1668 | $groupId = api_get_group_id(); |
1669 | - $session_id=api_get_session_id(); |
|
1669 | + $session_id = api_get_session_id(); |
|
1670 | 1670 | |
1671 | 1671 | $sql = 'SELECT * FROM '.$tbl_wiki_mailcue.' |
1672 | 1672 | WHERE |
@@ -1675,31 +1675,31 @@ discard block |
||
1675 | 1675 | type="F" AND |
1676 | 1676 | group_id="'.$groupId.'" AND |
1677 | 1677 | session_id="'.$session_id.'"'; |
1678 | - $result=Database::query($sql); |
|
1679 | - $row=Database::fetch_array($result); |
|
1678 | + $result = Database::query($sql); |
|
1679 | + $row = Database::fetch_array($result); |
|
1680 | 1680 | |
1681 | - $idm=$row['user_id']; |
|
1681 | + $idm = $row['user_id']; |
|
1682 | 1682 | |
1683 | 1683 | if (empty($idm)) { |
1684 | - $status_notify_all=0; |
|
1684 | + $status_notify_all = 0; |
|
1685 | 1685 | } else { |
1686 | - $status_notify_all=1; |
|
1686 | + $status_notify_all = 1; |
|
1687 | 1687 | } |
1688 | 1688 | |
1689 | 1689 | //change status |
1690 | - if (isset($_GET['actionpage']) && $_GET['actionpage'] =='locknotifyall' && $status_notify_all==0) { |
|
1691 | - $sql="INSERT INTO ".$tbl_wiki_mailcue." (c_id, user_id, type, group_id, session_id) VALUES |
|
1690 | + if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'locknotifyall' && $status_notify_all == 0) { |
|
1691 | + $sql = "INSERT INTO ".$tbl_wiki_mailcue." (c_id, user_id, type, group_id, session_id) VALUES |
|
1692 | 1692 | ($course_id, '".api_get_user_id()."','F','".$groupId."','".$session_id."')"; |
1693 | 1693 | Database::query($sql); |
1694 | - $status_notify_all=1; |
|
1694 | + $status_notify_all = 1; |
|
1695 | 1695 | } |
1696 | 1696 | |
1697 | 1697 | if (isset($_GET['actionpage']) && |
1698 | 1698 | isset($_GET['actionpage']) && |
1699 | - $_GET['actionpage'] =='unlocknotifyall' && |
|
1699 | + $_GET['actionpage'] == 'unlocknotifyall' && |
|
1700 | 1700 | $status_notify_all == 1 |
1701 | 1701 | ) { |
1702 | - $sql ='DELETE FROM '.$tbl_wiki_mailcue.' |
|
1702 | + $sql = 'DELETE FROM '.$tbl_wiki_mailcue.' |
|
1703 | 1703 | WHERE |
1704 | 1704 | c_id = '.$course_id.' AND |
1705 | 1705 | user_id="'.api_get_user_id().'" AND |
@@ -1708,7 +1708,7 @@ discard block |
||
1708 | 1708 | session_id="'.$session_id.'" AND |
1709 | 1709 | c_id = '.$course_id; |
1710 | 1710 | Database::query($sql); |
1711 | - $status_notify_all=0; |
|
1711 | + $status_notify_all = 0; |
|
1712 | 1712 | } |
1713 | 1713 | |
1714 | 1714 | //show status |
@@ -1718,7 +1718,7 @@ discard block |
||
1718 | 1718 | /** |
1719 | 1719 | * Sends pending e-mails |
1720 | 1720 | */ |
1721 | - public function check_emailcue($id_or_ref, $type, $lastime='', $lastuser='') |
|
1721 | + public function check_emailcue($id_or_ref, $type, $lastime = '', $lastuser = '') |
|
1722 | 1722 | { |
1723 | 1723 | $tbl_wiki_mailcue = $this->tbl_wiki_mailcue; |
1724 | 1724 | $tbl_wiki = $this->tbl_wiki; |
@@ -1726,14 +1726,14 @@ discard block |
||
1726 | 1726 | $groupfilter = $this->groupfilter; |
1727 | 1727 | $_course = $this->courseInfo; |
1728 | 1728 | $groupId = api_get_group_id(); |
1729 | - $session_id=api_get_session_id(); |
|
1729 | + $session_id = api_get_session_id(); |
|
1730 | 1730 | $course_id = api_get_course_int_id(); |
1731 | 1731 | |
1732 | - $group_properties = GroupManager :: get_group_properties($groupId); |
|
1732 | + $group_properties = GroupManager :: get_group_properties($groupId); |
|
1733 | 1733 | $group_name = $group_properties['name']; |
1734 | 1734 | $allow_send_mail = false; //define the variable to below |
1735 | 1735 | $email_assignment = null; |
1736 | - if ($type=='P') { |
|
1736 | + if ($type == 'P') { |
|
1737 | 1737 | //if modifying a wiki page |
1738 | 1738 | //first, current author and time |
1739 | 1739 | //Who is the author? |
@@ -1744,22 +1744,22 @@ discard block |
||
1744 | 1744 | $year = substr($lastime, 0, 4); |
1745 | 1745 | $month = substr($lastime, 5, 2); |
1746 | 1746 | $day = substr($lastime, 8, 2); |
1747 | - $hours=substr($lastime, 11,2); |
|
1748 | - $minutes=substr($lastime, 14,2); |
|
1749 | - $seconds=substr($lastime, 17,2); |
|
1750 | - $email_date_changes=$day.' '.$month.' '.$year.' '.$hours.":".$minutes.":".$seconds; |
|
1747 | + $hours = substr($lastime, 11, 2); |
|
1748 | + $minutes = substr($lastime, 14, 2); |
|
1749 | + $seconds = substr($lastime, 17, 2); |
|
1750 | + $email_date_changes = $day.' '.$month.' '.$year.' '.$hours.":".$minutes.":".$seconds; |
|
1751 | 1751 | |
1752 | 1752 | //second, extract data from first reg |
1753 | 1753 | $sql = 'SELECT * FROM '.$tbl_wiki.' |
1754 | 1754 | WHERE c_id = '.$course_id.' AND reflink="'.$id_or_ref.'" AND '.$groupfilter.$condition_session.' |
1755 | 1755 | ORDER BY id ASC'; |
1756 | - $result=Database::query($sql); |
|
1757 | - $row=Database::fetch_array($result); |
|
1756 | + $result = Database::query($sql); |
|
1757 | + $row = Database::fetch_array($result); |
|
1758 | 1758 | |
1759 | - $id=$row['id']; |
|
1760 | - $email_page_name=$row['title']; |
|
1761 | - if ($row['visibility']==1) { |
|
1762 | - $allow_send_mail=true; //if visibility off - notify off |
|
1759 | + $id = $row['id']; |
|
1760 | + $email_page_name = $row['title']; |
|
1761 | + if ($row['visibility'] == 1) { |
|
1762 | + $allow_send_mail = true; //if visibility off - notify off |
|
1763 | 1763 | $sql = 'SELECT * FROM '.$tbl_wiki_mailcue.' |
1764 | 1764 | WHERE |
1765 | 1765 | c_id = '.$course_id.' AND |
@@ -1769,10 +1769,10 @@ discard block |
||
1769 | 1769 | group_id="'.$groupId.'" AND |
1770 | 1770 | session_id="'.$session_id.'"'; |
1771 | 1771 | //type: P=page, D=discuss, F=full. |
1772 | - $result=Database::query($sql); |
|
1773 | - $emailtext=get_lang('EmailWikipageModified').' <strong>'.$email_page_name.'</strong> '.get_lang('Wiki'); |
|
1772 | + $result = Database::query($sql); |
|
1773 | + $emailtext = get_lang('EmailWikipageModified').' <strong>'.$email_page_name.'</strong> '.get_lang('Wiki'); |
|
1774 | 1774 | } |
1775 | - } elseif ($type=='D') { |
|
1775 | + } elseif ($type == 'D') { |
|
1776 | 1776 | //if added a post to discuss |
1777 | 1777 | |
1778 | 1778 | //first, current author and time |
@@ -1784,25 +1784,25 @@ discard block |
||
1784 | 1784 | $year = substr($lastime, 0, 4); |
1785 | 1785 | $month = substr($lastime, 5, 2); |
1786 | 1786 | $day = substr($lastime, 8, 2); |
1787 | - $hours=substr($lastime, 11,2); |
|
1788 | - $minutes=substr($lastime, 14,2); |
|
1789 | - $seconds=substr($lastime, 17,2); |
|
1790 | - $email_date_changes=$day.' '.$month.' '.$year.' '.$hours.":".$minutes.":".$seconds; |
|
1787 | + $hours = substr($lastime, 11, 2); |
|
1788 | + $minutes = substr($lastime, 14, 2); |
|
1789 | + $seconds = substr($lastime, 17, 2); |
|
1790 | + $email_date_changes = $day.' '.$month.' '.$year.' '.$hours.":".$minutes.":".$seconds; |
|
1791 | 1791 | |
1792 | 1792 | //second, extract data from first reg |
1793 | 1793 | |
1794 | - $id=$id_or_ref; //$id_or_ref is id from tblwiki |
|
1794 | + $id = $id_or_ref; //$id_or_ref is id from tblwiki |
|
1795 | 1795 | |
1796 | 1796 | $sql = 'SELECT * FROM '.$tbl_wiki.' |
1797 | 1797 | WHERE c_id = '.$course_id.' AND id="'.$id.'" |
1798 | 1798 | ORDER BY id ASC'; |
1799 | 1799 | |
1800 | - $result=Database::query($sql); |
|
1801 | - $row=Database::fetch_array($result); |
|
1800 | + $result = Database::query($sql); |
|
1801 | + $row = Database::fetch_array($result); |
|
1802 | 1802 | |
1803 | - $email_page_name=$row['title']; |
|
1804 | - if ($row['visibility_disc']==1) { |
|
1805 | - $allow_send_mail=true; //if visibility off - notify off |
|
1803 | + $email_page_name = $row['title']; |
|
1804 | + if ($row['visibility_disc'] == 1) { |
|
1805 | + $allow_send_mail = true; //if visibility off - notify off |
|
1806 | 1806 | $sql = 'SELECT * FROM '.$tbl_wiki_mailcue.' |
1807 | 1807 | WHERE |
1808 | 1808 | c_id = '.$course_id.' AND |
@@ -1813,22 +1813,22 @@ discard block |
||
1813 | 1813 | session_id="'.$session_id.'"'; |
1814 | 1814 | //type: P=page, D=discuss, F=full |
1815 | 1815 | $result = Database::query($sql); |
1816 | - $emailtext=get_lang('EmailWikiPageDiscAdded').' <strong>'.$email_page_name.'</strong> '.get_lang('Wiki'); |
|
1816 | + $emailtext = get_lang('EmailWikiPageDiscAdded').' <strong>'.$email_page_name.'</strong> '.get_lang('Wiki'); |
|
1817 | 1817 | } |
1818 | - } elseif($type=='A') { |
|
1818 | + } elseif ($type == 'A') { |
|
1819 | 1819 | //for added pages |
1820 | - $id=0; //for tbl_wiki_mailcue |
|
1820 | + $id = 0; //for tbl_wiki_mailcue |
|
1821 | 1821 | $sql = 'SELECT * FROM '.$tbl_wiki.' |
1822 | 1822 | WHERE c_id = '.$course_id.' |
1823 | 1823 | ORDER BY id DESC'; //the added is always the last |
1824 | 1824 | |
1825 | - $result=Database::query($sql); |
|
1826 | - $row=Database::fetch_array($result); |
|
1827 | - $email_page_name=$row['title']; |
|
1825 | + $result = Database::query($sql); |
|
1826 | + $row = Database::fetch_array($result); |
|
1827 | + $email_page_name = $row['title']; |
|
1828 | 1828 | |
1829 | 1829 | //Who is the author? |
1830 | 1830 | $userinfo = api_get_user_info($row['user_id']); |
1831 | - $email_user_author= get_lang('AddedBy').': '.$userinfo['complete_name']; |
|
1831 | + $email_user_author = get_lang('AddedBy').': '.$userinfo['complete_name']; |
|
1832 | 1832 | |
1833 | 1833 | //When ? |
1834 | 1834 | $year = substr($row['dtime'], 0, 4); |
@@ -1837,33 +1837,33 @@ discard block |
||
1837 | 1837 | $hours = substr($row['dtime'], 11, 2); |
1838 | 1838 | $minutes = substr($row['dtime'], 14, 2); |
1839 | 1839 | $seconds = substr($row['dtime'], 17, 2); |
1840 | - $email_date_changes=$day.' '.$month.' '.$year.' '.$hours.":".$minutes.":".$seconds; |
|
1841 | - |
|
1842 | - if($row['assignment']==0) { |
|
1843 | - $allow_send_mail=true; |
|
1844 | - } elseif($row['assignment']==1) { |
|
1845 | - $email_assignment=get_lang('AssignmentDescExtra').' ('.get_lang('AssignmentMode').')'; |
|
1846 | - $allow_send_mail=true; |
|
1847 | - } elseif($row['assignment']==2) { |
|
1848 | - $allow_send_mail=false; //Mode tasks: avoids notifications to all users about all users |
|
1840 | + $email_date_changes = $day.' '.$month.' '.$year.' '.$hours.":".$minutes.":".$seconds; |
|
1841 | + |
|
1842 | + if ($row['assignment'] == 0) { |
|
1843 | + $allow_send_mail = true; |
|
1844 | + } elseif ($row['assignment'] == 1) { |
|
1845 | + $email_assignment = get_lang('AssignmentDescExtra').' ('.get_lang('AssignmentMode').')'; |
|
1846 | + $allow_send_mail = true; |
|
1847 | + } elseif ($row['assignment'] == 2) { |
|
1848 | + $allow_send_mail = false; //Mode tasks: avoids notifications to all users about all users |
|
1849 | 1849 | } |
1850 | 1850 | |
1851 | 1851 | $sql = 'SELECT * FROM '.$tbl_wiki_mailcue.' |
1852 | 1852 | WHERE c_id = '.$course_id.' AND id="'.$id.'" AND type="F" AND group_id="'.$groupId.'" AND session_id="'.$session_id.'"'; |
1853 | 1853 | //type: P=page, D=discuss, F=full |
1854 | - $result=Database::query($sql); |
|
1854 | + $result = Database::query($sql); |
|
1855 | 1855 | |
1856 | - $emailtext = get_lang('EmailWikiPageAdded').' <strong>'.$email_page_name.'</strong> '.get_lang('In').' '. get_lang('Wiki'); |
|
1857 | - } elseif ($type=='E') { |
|
1858 | - $id=0; |
|
1859 | - $allow_send_mail=true; |
|
1856 | + $emailtext = get_lang('EmailWikiPageAdded').' <strong>'.$email_page_name.'</strong> '.get_lang('In').' '.get_lang('Wiki'); |
|
1857 | + } elseif ($type == 'E') { |
|
1858 | + $id = 0; |
|
1859 | + $allow_send_mail = true; |
|
1860 | 1860 | |
1861 | 1861 | //Who is the author? |
1862 | - $userinfo = api_get_user_info(api_get_user_id()); //current user |
|
1862 | + $userinfo = api_get_user_info(api_get_user_id()); //current user |
|
1863 | 1863 | $email_user_author = get_lang('DeletedBy').': '.$userinfo['complete_name']; |
1864 | 1864 | //When ? |
1865 | - $today = date('r'); //current time |
|
1866 | - $email_date_changes=$today; |
|
1865 | + $today = date('r'); //current time |
|
1866 | + $email_date_changes = $today; |
|
1867 | 1867 | |
1868 | 1868 | $sql = 'SELECT * FROM '.$tbl_wiki_mailcue.' |
1869 | 1869 | WHERE |
@@ -1877,16 +1877,16 @@ discard block |
||
1877 | 1877 | ///make and send email |
1878 | 1878 | if ($allow_send_mail) { |
1879 | 1879 | while ($row = Database::fetch_array($result)) { |
1880 | - $userinfo = api_get_user_info($row['user_id']); //$row['user_id'] obtained from tbl_wiki_mailcue |
|
1880 | + $userinfo = api_get_user_info($row['user_id']); //$row['user_id'] obtained from tbl_wiki_mailcue |
|
1881 | 1881 | $name_to = $userinfo['complete_name']; |
1882 | 1882 | $email_to = $userinfo['email']; |
1883 | 1883 | $sender_name = api_get_setting('emailAdministrator'); |
1884 | 1884 | $sender_email = api_get_setting('emailAdministrator'); |
1885 | 1885 | $email_subject = get_lang('EmailWikiChanges').' - '.$_course['official_code']; |
1886 | 1886 | $email_body = get_lang('DearUser').' '.api_get_person_name($userinfo['firstname'], $userinfo['lastname']).',<br /><br />'; |
1887 | - if($session_id==0){ |
|
1887 | + if ($session_id == 0) { |
|
1888 | 1888 | $email_body .= $emailtext.' <strong>'.$_course['name'].' - '.$group_name.'</strong><br /><br /><br />'; |
1889 | - }else{ |
|
1889 | + } else { |
|
1890 | 1890 | $email_body .= $emailtext.' <strong>'.$_course['name'].' ('.api_get_session_name(api_get_session_id()).') - '.$group_name.'</strong><br /><br /><br />'; |
1891 | 1891 | } |
1892 | 1892 | $email_body .= $email_user_author.' ('.$email_date_changes.')<br /><br /><br />'; |
@@ -1964,23 +1964,23 @@ discard block |
||
1964 | 1964 | $template); |
1965 | 1965 | |
1966 | 1966 | if (0 != $groupId) { |
1967 | - $groupPart = '_group' . $groupId; // and add groupId to put the same document title in different groups |
|
1968 | - $group_properties = GroupManager :: get_group_properties($groupId); |
|
1967 | + $groupPart = '_group'.$groupId; // and add groupId to put the same document title in different groups |
|
1968 | + $group_properties = GroupManager :: get_group_properties($groupId); |
|
1969 | 1969 | $groupPath = $group_properties['directory']; |
1970 | 1970 | } else { |
1971 | 1971 | $groupPart = ''; |
1972 | - $groupPath =''; |
|
1972 | + $groupPath = ''; |
|
1973 | 1973 | } |
1974 | 1974 | |
1975 | - $exportDir = api_get_path(SYS_COURSE_PATH).api_get_course_path(). '/document'.$groupPath; |
|
1976 | - $exportFile = api_replace_dangerous_char($wikiTitle) . $groupPart; |
|
1975 | + $exportDir = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/document'.$groupPath; |
|
1976 | + $exportFile = api_replace_dangerous_char($wikiTitle).$groupPart; |
|
1977 | 1977 | $wikiContents = trim(preg_replace("/\[[\[]?([^\]|]*)[|]?([^|\]]*)\][\]]?/", "$1", $wikiContents)); |
1978 | 1978 | //TODO: put link instead of title |
1979 | 1979 | |
1980 | 1980 | $wikiContents = str_replace('{CONTENT}', $wikiContents, $template); |
1981 | 1981 | |
1982 | 1982 | // replace relative path by absolute path for courses, so you can see items into this page wiki (images, mp3, etc..) exported in documents |
1983 | - if (api_strpos($wikiContents,'../..'.api_get_path(REL_COURSE_PATH)) !== false) { |
|
1983 | + if (api_strpos($wikiContents, '../..'.api_get_path(REL_COURSE_PATH)) !== false) { |
|
1984 | 1984 | $web_course_path = api_get_path(WEB_COURSE_PATH); |
1985 | 1985 | $wikiContents = str_replace('../..'.api_get_path(REL_COURSE_PATH), $web_course_path, $wikiContents); |
1986 | 1986 | } |
@@ -1991,8 +1991,8 @@ discard block |
||
1991 | 1991 | $i++; |
1992 | 1992 | } |
1993 | 1993 | |
1994 | - $wikiFileName = $exportFile . '_' . $i . '.html'; |
|
1995 | - $exportPath = $exportDir . '/' . $wikiFileName; |
|
1994 | + $wikiFileName = $exportFile.'_'.$i.'.html'; |
|
1995 | + $exportPath = $exportDir.'/'.$wikiFileName; |
|
1996 | 1996 | |
1997 | 1997 | file_put_contents($exportPath, $wikiContents); |
1998 | 1998 | $doc_id = add_document( |
@@ -2037,14 +2037,14 @@ discard block |
||
2037 | 2037 | $content_pdf = api_html_entity_decode($data['content'], ENT_QUOTES, api_get_system_encoding()); |
2038 | 2038 | |
2039 | 2039 | //clean wiki links |
2040 | - $content_pdf=trim(preg_replace("/\[[\[]?([^\]|]*)[|]?([^|\]]*)\][\]]?/", "$1", $content_pdf)); |
|
2040 | + $content_pdf = trim(preg_replace("/\[[\[]?([^\]|]*)[|]?([^|\]]*)\][\]]?/", "$1", $content_pdf)); |
|
2041 | 2041 | //TODO: It should be better to display the link insted of the tile but it is hard for [[title]] links |
2042 | 2042 | |
2043 | 2043 | $title_pdf = api_html_entity_decode($data['title'], ENT_QUOTES, api_get_system_encoding()); |
2044 | 2044 | $title_pdf = api_utf8_encode($title_pdf, api_get_system_encoding()); |
2045 | 2045 | $content_pdf = api_utf8_encode($content_pdf, api_get_system_encoding()); |
2046 | 2046 | |
2047 | - $html=' |
|
2047 | + $html = ' |
|
2048 | 2048 | <!-- defines the headers/footers - this must occur before the headers/footers are set --> |
2049 | 2049 | |
2050 | 2050 | <!--mpdf |
@@ -2103,9 +2103,9 @@ discard block |
||
2103 | 2103 | $groupId = api_get_group_id(); |
2104 | 2104 | $groupInfo = GroupManager::get_group_properties($groupId); |
2105 | 2105 | |
2106 | - if ($groupId==0) { |
|
2106 | + if ($groupId == 0) { |
|
2107 | 2107 | //extract course members |
2108 | - if(!empty($session_id)) { |
|
2108 | + if (!empty($session_id)) { |
|
2109 | 2109 | $a_users_to_add = CourseManager::get_user_list_from_course_code(api_get_course_id(), $session_id); |
2110 | 2110 | } else { |
2111 | 2111 | $a_users_to_add = CourseManager::get_user_list_from_course_code(api_get_course_id(), 0); |
@@ -2131,7 +2131,7 @@ discard block |
||
2131 | 2131 | $username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username'], ENT_QUOTES)); |
2132 | 2132 | $name = $userinfo['complete_name']." - ".$username; |
2133 | 2133 | |
2134 | - $photo = '<img src="' . $userinfo['avatar'] . '" alt="' . $name . '" width="40" height="50" align="top" title="' . $name . '" />'; |
|
2134 | + $photo = '<img src="'.$userinfo['avatar'].'" alt="'.$name.'" width="40" height="50" align="top" title="'.$name.'" />'; |
|
2135 | 2135 | |
2136 | 2136 | // teacher assignment title |
2137 | 2137 | $title_orig = $values['title']; |
@@ -2161,7 +2161,7 @@ discard block |
||
2161 | 2161 | $userPicture = UserManager::getUserPicture($assig_user_id); |
2162 | 2162 | $username = api_htmlentities(sprintf(get_lang('LoginX'), $o_user_to_add['username'], ENT_QUOTES)); |
2163 | 2163 | $name = api_get_person_name($o_user_to_add['firstname'], $o_user_to_add['lastname'])." . ".$username; |
2164 | - $photo= '<img src="'.$userPicture.'" alt="'.$name.'" width="40" height="50" align="bottom" title="'.$name.'" />'; |
|
2164 | + $photo = '<img src="'.$userPicture.'" alt="'.$name.'" width="40" height="50" align="bottom" title="'.$name.'" />'; |
|
2165 | 2165 | |
2166 | 2166 | $is_tutor_of_group = GroupManager::is_tutor_of_group($assig_user_id, $groupInfo['iid']); //student is tutor |
2167 | 2167 | $is_tutor_and_member = GroupManager::is_tutor_of_group($assig_user_id, $groupInfo['iid']) && |
@@ -2169,17 +2169,17 @@ discard block |
||
2169 | 2169 | // student is tutor and member |
2170 | 2170 | |
2171 | 2171 | if ($is_tutor_and_member) { |
2172 | - $status_in_group=get_lang('GroupTutorAndMember'); |
|
2172 | + $status_in_group = get_lang('GroupTutorAndMember'); |
|
2173 | 2173 | } else { |
2174 | - if($is_tutor_of_group) { |
|
2175 | - $status_in_group=get_lang('GroupTutor'); |
|
2174 | + if ($is_tutor_of_group) { |
|
2175 | + $status_in_group = get_lang('GroupTutor'); |
|
2176 | 2176 | } else { |
2177 | - $status_in_group=" "; //get_lang('GroupStandardMember') |
|
2177 | + $status_in_group = " "; //get_lang('GroupStandardMember') |
|
2178 | 2178 | } |
2179 | 2179 | } |
2180 | 2180 | |
2181 | - if ($assignment_type==1) { |
|
2182 | - $values['title']= $title_orig; |
|
2181 | + if ($assignment_type == 1) { |
|
2182 | + $values['title'] = $title_orig; |
|
2183 | 2183 | $values['content'] = '<div align="center" style="background-color: #F5F8FB; border:solid; border-color: #E6E6E6"> |
2184 | 2184 | <table border="0"> |
2185 | 2185 | <tr><td style="font-size:24px">'.get_lang('AssignmentWork').'</td></tr> |
@@ -2195,7 +2195,7 @@ discard block |
||
2195 | 2195 | ). |
2196 | 2196 | ' [['.Security::remove_XSS($_POST['title'])."_uass".$assig_user_id.' | '.$photo.']] '.$status_in_group.'</li>'; |
2197 | 2197 | //don't change this line without guaranteeing that users will be ordered by last names in the following format (surname, name) |
2198 | - $values['assignment']=2; |
|
2198 | + $values['assignment'] = 2; |
|
2199 | 2199 | } |
2200 | 2200 | $this->assig_user_id = $assig_user_id; |
2201 | 2201 | self::save_new_wiki($values); |
@@ -2204,12 +2204,12 @@ discard block |
||
2204 | 2204 | |
2205 | 2205 | foreach ($a_users_to_add as $o_user_to_add) { |
2206 | 2206 | if ($o_user_to_add['user_id'] == $userId) { |
2207 | - $assig_user_id=$o_user_to_add['user_id']; |
|
2207 | + $assig_user_id = $o_user_to_add['user_id']; |
|
2208 | 2208 | if ($assignment_type == 1) { |
2209 | - $values['title']= $title_orig; |
|
2210 | - $values['comment']=get_lang('AssignmentDesc'); |
|
2209 | + $values['title'] = $title_orig; |
|
2210 | + $values['comment'] = get_lang('AssignmentDesc'); |
|
2211 | 2211 | sort($all_students_pages); |
2212 | - $values['content']=$content_orig_A.$content_orig_B.'<br/> |
|
2212 | + $values['content'] = $content_orig_A.$content_orig_B.'<br/> |
|
2213 | 2213 | <div align="center" style="font-size:18px; background-color: #F5F8FB; border:solid; border-color:#E6E6E6"> |
2214 | 2214 | '.get_lang('AssignmentLinkstoStudentsPage').' |
2215 | 2215 | </div><br/> |
@@ -2217,7 +2217,7 @@ discard block |
||
2217 | 2217 | <ol>'.implode($all_students_pages).'</ol> |
2218 | 2218 | </div> |
2219 | 2219 | <br/>'; |
2220 | - $values['assignment']=1; |
|
2220 | + $values['assignment'] = 1; |
|
2221 | 2221 | } |
2222 | 2222 | $this->assig_user_id = $assig_user_id; |
2223 | 2223 | self::save_new_wiki($values); |
@@ -2231,7 +2231,7 @@ discard block |
||
2231 | 2231 | * @param int Whether to search the contents (1) or just the titles (0) |
2232 | 2232 | * @param int |
2233 | 2233 | */ |
2234 | - public function display_wiki_search_results($search_term, $search_content=0, $all_vers=0) |
|
2234 | + public function display_wiki_search_results($search_term, $search_content = 0, $all_vers = 0) |
|
2235 | 2235 | { |
2236 | 2236 | $tbl_wiki = $this->tbl_wiki; |
2237 | 2237 | $condition_session = $this->condition_session; |
@@ -2243,9 +2243,9 @@ discard block |
||
2243 | 2243 | echo '</legend>'; |
2244 | 2244 | |
2245 | 2245 | //only by professors when page is hidden |
2246 | - if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { |
|
2247 | - if ($all_vers=='1') { |
|
2248 | - if ($search_content=='1') { |
|
2246 | + if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { |
|
2247 | + if ($all_vers == '1') { |
|
2248 | + if ($search_content == '1') { |
|
2249 | 2249 | $sql = "SELECT * FROM ".$tbl_wiki." |
2250 | 2250 | WHERE |
2251 | 2251 | c_id = $course_id AND |
@@ -2262,7 +2262,7 @@ discard block |
||
2262 | 2262 | //search all pages and all versions |
2263 | 2263 | } |
2264 | 2264 | } else { |
2265 | - if ($search_content=='1') { |
|
2265 | + if ($search_content == '1') { |
|
2266 | 2266 | $sql = "SELECT * FROM ".$tbl_wiki." s1 |
2267 | 2267 | WHERE |
2268 | 2268 | s1.c_id = $course_id AND |
@@ -2313,7 +2313,7 @@ discard block |
||
2313 | 2313 | //search all pages and all versions |
2314 | 2314 | } |
2315 | 2315 | } else { |
2316 | - if($search_content=='1') { |
|
2316 | + if ($search_content == '1') { |
|
2317 | 2317 | $sql = "SELECT * FROM ".$tbl_wiki." s1 |
2318 | 2318 | WHERE |
2319 | 2319 | s1.c_id = $course_id AND |
@@ -2361,17 +2361,17 @@ discard block |
||
2361 | 2361 | $seconds = substr($obj->dtime, 17, 2); |
2362 | 2362 | |
2363 | 2363 | //get type assignment icon |
2364 | - if($obj->assignment==1) { |
|
2365 | - $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL); |
|
2366 | - } elseif ($obj->assignment==2) { |
|
2367 | - $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL); |
|
2368 | - } elseif ($obj->assignment==0) { |
|
2364 | + if ($obj->assignment == 1) { |
|
2365 | + $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'), '', ICON_SIZE_SMALL); |
|
2366 | + } elseif ($obj->assignment == 2) { |
|
2367 | + $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL); |
|
2368 | + } elseif ($obj->assignment == 0) { |
|
2369 | 2369 | $ShowAssignment = Display::return_icon('px_transparent.gif'); |
2370 | 2370 | } |
2371 | 2371 | $row = array(); |
2372 | 2372 | $row[] = $ShowAssignment; |
2373 | 2373 | |
2374 | - if($all_vers=='1') { |
|
2374 | + if ($all_vers == '1') { |
|
2375 | 2375 | $row[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=showpage&title='.api_htmlentities(urlencode($obj->reflink)).'&view='.$obj->id.'&session_id='.api_htmlentities(urlencode($_GET['$session_id'])).'&group_id='.api_htmlentities(urlencode($_GET['group_id'])).'">'. |
2376 | 2376 | api_htmlentities($obj->title).'</a>'; |
2377 | 2377 | } else { |
@@ -2382,21 +2382,21 @@ discard block |
||
2382 | 2382 | $row[] = ($obj->user_id != 0 && $userinfo !== false) ? UserManager::getUserProfileLink($userinfo) : get_lang('Anonymous').' ('.$obj->user_ip.')'; |
2383 | 2383 | $row[] = $year.'-'.$month.'-'.$day.' '.$hours.":".$minutes.":".$seconds; |
2384 | 2384 | |
2385 | - if ($all_vers=='1') { |
|
2385 | + if ($all_vers == '1') { |
|
2386 | 2386 | $row[] = $obj->version; |
2387 | 2387 | } else { |
2388 | 2388 | $showdelete = ''; |
2389 | - if (api_is_allowed_to_edit(false,true)|| api_is_platform_admin()) { |
|
2390 | - $showdelete=' <a href="'.api_get_self().'?'.api_get_cidreq().'&action=delete&title='.api_htmlentities(urlencode($obj->reflink)).'&group_id='.api_htmlentities($_GET['group_id']).'">'. |
|
2391 | - Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL); |
|
2389 | + if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { |
|
2390 | + $showdelete = ' <a href="'.api_get_self().'?'.api_get_cidreq().'&action=delete&title='.api_htmlentities(urlencode($obj->reflink)).'&group_id='.api_htmlentities($_GET['group_id']).'">'. |
|
2391 | + Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL); |
|
2392 | 2392 | } |
2393 | 2393 | $row[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=edit&title='.api_htmlentities(urlencode($obj->reflink)).'&group_id='.api_htmlentities($_GET['group_id']).'">'. |
2394 | - Display::return_icon('edit.png', get_lang('EditPage'),'',ICON_SIZE_SMALL).'</a> |
|
2394 | + Display::return_icon('edit.png', get_lang('EditPage'), '', ICON_SIZE_SMALL).'</a> |
|
2395 | 2395 | <a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=discuss&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'. |
2396 | - Display::return_icon('discuss.png', get_lang('Discuss'),'',ICON_SIZE_SMALL).'</a> |
|
2396 | + Display::return_icon('discuss.png', get_lang('Discuss'), '', ICON_SIZE_SMALL).'</a> |
|
2397 | 2397 | <a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=history&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'. |
2398 | - Display::return_icon('history.png', get_lang('History'),'',ICON_SIZE_SMALL).'</a> <a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=links&title='.api_htmlentities(urlencode($obj->reflink)).'&group_id='.api_htmlentities($_GET['group_id']).'">'. |
|
2399 | - Display::return_icon('what_link_here.png', get_lang('LinksPages'),'',ICON_SIZE_SMALL).'</a>'.$showdelete; |
|
2398 | + Display::return_icon('history.png', get_lang('History'), '', ICON_SIZE_SMALL).'</a> <a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=links&title='.api_htmlentities(urlencode($obj->reflink)).'&group_id='.api_htmlentities($_GET['group_id']).'">'. |
|
2399 | + Display::return_icon('what_link_here.png', get_lang('LinksPages'), '', ICON_SIZE_SMALL).'</a>'.$showdelete; |
|
2400 | 2400 | } |
2401 | 2401 | $rows[] = $row; |
2402 | 2402 | } |
@@ -2421,16 +2421,16 @@ discard block |
||
2421 | 2421 | 'all_vers' => $all_vers, |
2422 | 2422 | ) |
2423 | 2423 | ); |
2424 | - $table->set_header(0,get_lang('Type'), true, array ('style' => 'width:30px;')); |
|
2425 | - $table->set_header(1,get_lang('Title'), true); |
|
2424 | + $table->set_header(0, get_lang('Type'), true, array('style' => 'width:30px;')); |
|
2425 | + $table->set_header(1, get_lang('Title'), true); |
|
2426 | 2426 | if ($all_vers == '1') { |
2427 | - $table->set_header(2,get_lang('Author'), true); |
|
2428 | - $table->set_header(3,get_lang('Date'), true); |
|
2429 | - $table->set_header(4,get_lang('Version'), true); |
|
2427 | + $table->set_header(2, get_lang('Author'), true); |
|
2428 | + $table->set_header(3, get_lang('Date'), true); |
|
2429 | + $table->set_header(4, get_lang('Version'), true); |
|
2430 | 2430 | } else { |
2431 | - $table->set_header(2,get_lang('Author').' ('.get_lang('LastVersion').')', true); |
|
2432 | - $table->set_header(3,get_lang('Date').' ('.get_lang('LastVersion').')', true); |
|
2433 | - $table->set_header(4,get_lang('Actions'), false, array ('style' => 'width:130px;')); |
|
2431 | + $table->set_header(2, get_lang('Author').' ('.get_lang('LastVersion').')', true); |
|
2432 | + $table->set_header(3, get_lang('Date').' ('.get_lang('LastVersion').')', true); |
|
2433 | + $table->set_header(4, get_lang('Actions'), false, array('style' => 'width:130px;')); |
|
2434 | 2434 | } |
2435 | 2435 | $table->display(); |
2436 | 2436 | } else { |
@@ -2443,14 +2443,14 @@ discard block |
||
2443 | 2443 | * @todo replace this function with the formvalidator datepicker |
2444 | 2444 | * |
2445 | 2445 | */ |
2446 | - public function draw_date_picker($prefix,$default='') |
|
2446 | + public function draw_date_picker($prefix, $default = '') |
|
2447 | 2447 | { |
2448 | 2448 | if (empty($default)) { |
2449 | 2449 | $default = date('Y-m-d H:i:s'); |
2450 | 2450 | } |
2451 | 2451 | $parts = explode(' ', $default); |
2452 | - list($d_year,$d_month,$d_day) = explode('-',$parts[0]); |
|
2453 | - list($d_hour,$d_minute) = explode(':',$parts[1]); |
|
2452 | + list($d_year, $d_month, $d_day) = explode('-', $parts[0]); |
|
2453 | + list($d_hour, $d_minute) = explode(':', $parts[1]); |
|
2454 | 2454 | |
2455 | 2455 | $month_list = array( |
2456 | 2456 | 1 => get_lang('JanuaryLong'), |
@@ -2467,9 +2467,9 @@ discard block |
||
2467 | 2467 | 12 => get_lang('DecemberLong'), |
2468 | 2468 | ); |
2469 | 2469 | |
2470 | - $minute = range(10,59); |
|
2471 | - array_unshift($minute,'00','01','02','03','04','05','06','07','08','09'); |
|
2472 | - $date_form = self::make_select($prefix.'_day', array_combine(range(1,31),range(1,31)), $d_day); |
|
2470 | + $minute = range(10, 59); |
|
2471 | + array_unshift($minute, '00', '01', '02', '03', '04', '05', '06', '07', '08', '09'); |
|
2472 | + $date_form = self::make_select($prefix.'_day', array_combine(range(1, 31), range(1, 31)), $d_day); |
|
2473 | 2473 | $date_form .= self::make_select($prefix.'_month', $month_list, $d_month); |
2474 | 2474 | $date_form .= self::make_select( |
2475 | 2475 | $prefix.'_year', |
@@ -2482,7 +2482,7 @@ discard block |
||
2482 | 2482 | ), |
2483 | 2483 | $d_year |
2484 | 2484 | ).' '; |
2485 | - $date_form .= self::make_select($prefix.'_hour', array_combine(range(0,23),range(0,23)), $d_hour).' : '; |
|
2485 | + $date_form .= self::make_select($prefix.'_hour', array_combine(range(0, 23), range(0, 23)), $d_hour).' : '; |
|
2486 | 2486 | $date_form .= self::make_select($prefix.'_minute', $minute, $d_minute); |
2487 | 2487 | |
2488 | 2488 | return $date_form; |
@@ -2492,11 +2492,11 @@ discard block |
||
2492 | 2492 | * Draws an HTML form select with the given options |
2493 | 2493 | * |
2494 | 2494 | */ |
2495 | - public function make_select($name,$values,$checked='') |
|
2495 | + public function make_select($name, $values, $checked = '') |
|
2496 | 2496 | { |
2497 | 2497 | $output = '<select name="'.$name.'" id="'.$name.'">'; |
2498 | - foreach($values as $key => $value) { |
|
2499 | - $output .= '<option value="'.$key.'" '.(($checked==$key)?'selected="selected"':'').'>'.$value.'</option>'; |
|
2498 | + foreach ($values as $key => $value) { |
|
2499 | + $output .= '<option value="'.$key.'" '.(($checked == $key) ? 'selected="selected"' : '').'>'.$value.'</option>'; |
|
2500 | 2500 | } |
2501 | 2501 | $output .= '</select>'; |
2502 | 2502 | return $output; |
@@ -2520,7 +2520,7 @@ discard block |
||
2520 | 2520 | */ |
2521 | 2521 | public function two_digits($number) |
2522 | 2522 | { |
2523 | - $number = (int)$number; |
|
2523 | + $number = (int) $number; |
|
2524 | 2524 | return ($number < 10) ? '0'.$number : $number; |
2525 | 2525 | } |
2526 | 2526 | |
@@ -2541,7 +2541,7 @@ discard block |
||
2541 | 2541 | WHERE c_id = '.$course_id.' AND id = '.$id.' '; |
2542 | 2542 | $result = Database::query($sql); |
2543 | 2543 | $data = array(); |
2544 | - while ($row=Database::fetch_array($result,'ASSOC')) { |
|
2544 | + while ($row = Database::fetch_array($result, 'ASSOC')) { |
|
2545 | 2545 | $data = $row; |
2546 | 2546 | } |
2547 | 2547 | return $data; |
@@ -2595,7 +2595,7 @@ discard block |
||
2595 | 2595 | $result = Database::query($sql); |
2596 | 2596 | $data = array(); |
2597 | 2597 | if (Database::num_rows($result)) { |
2598 | - $data = Database::fetch_array($result,'ASSOC'); |
|
2598 | + $data = Database::fetch_array($result, 'ASSOC'); |
|
2599 | 2599 | } |
2600 | 2600 | |
2601 | 2601 | return $data; |
@@ -2689,9 +2689,9 @@ discard block |
||
2689 | 2689 | $result = self::getAllWiki(); |
2690 | 2690 | if (!empty($result)) { |
2691 | 2691 | foreach ($result as $is_editing_block) { |
2692 | - $max_edit_time = 1200; // 20 minutes |
|
2693 | - $timestamp_edit = strtotime($is_editing_block['time_edit']); |
|
2694 | - $time_editing = time()-$timestamp_edit; |
|
2692 | + $max_edit_time = 1200; // 20 minutes |
|
2693 | + $timestamp_edit = strtotime($is_editing_block['time_edit']); |
|
2694 | + $time_editing = time() - $timestamp_edit; |
|
2695 | 2695 | |
2696 | 2696 | // First prevent concurrent users and double version |
2697 | 2697 | if ($is_editing_block['is_editing'] == $userId) { |
@@ -2700,7 +2700,7 @@ discard block |
||
2700 | 2700 | Session::erase('_version'); |
2701 | 2701 | } |
2702 | 2702 | // Second checks if has exceeded the time that a page may be available or if a page was edited and saved by its author |
2703 | - if ($time_editing > $max_edit_time || ($is_editing_block['is_editing'] == $userId && $action!='edit')) { |
|
2703 | + if ($time_editing > $max_edit_time || ($is_editing_block['is_editing'] == $userId && $action != 'edit')) { |
|
2704 | 2704 | self::updateWikiIsEditing($is_editing_block['is_editing']); |
2705 | 2705 | } |
2706 | 2706 | } |
@@ -2748,7 +2748,7 @@ discard block |
||
2748 | 2748 | FROM ".$tbl_wiki." |
2749 | 2749 | WHERE c_id = $course_id AND ".$groupfilter.$condition_session.""; |
2750 | 2750 | |
2751 | - $allpages=Database::query($sql); |
|
2751 | + $allpages = Database::query($sql); |
|
2752 | 2752 | while ($row = Database::fetch_array($allpages)) { |
2753 | 2753 | $total_versions = $row['TOTAL_VERS']; |
2754 | 2754 | $total_visits = intval($row['TOTAL_VISITS']); |
@@ -2758,30 +2758,30 @@ discard block |
||
2758 | 2758 | WHERE c_id = $course_id AND ".$groupfilter.$condition_session.""; |
2759 | 2759 | $allpages = Database::query($sql); |
2760 | 2760 | |
2761 | - while ($row=Database::fetch_array($allpages)) { |
|
2761 | + while ($row = Database::fetch_array($allpages)) { |
|
2762 | 2762 | $total_words = $total_words + self::word_count($row['content']); |
2763 | - $total_links = $total_links+substr_count($row['content'], "href="); |
|
2764 | - $total_links_anchors = $total_links_anchors+substr_count($row['content'], 'href="#'); |
|
2765 | - $total_links_mail = $total_links_mail+substr_count($row['content'], 'href="mailto'); |
|
2766 | - $total_links_ftp = $total_links_ftp+substr_count($row['content'], 'href="ftp'); |
|
2767 | - $total_links_irc = $total_links_irc+substr_count($row['content'], 'href="irc'); |
|
2768 | - $total_links_news = $total_links_news+substr_count($row['content'], 'href="news'); |
|
2769 | - $total_wlinks = $total_wlinks+substr_count($row['content'], "[["); |
|
2770 | - $total_images = $total_images+substr_count($row['content'], "<img"); |
|
2763 | + $total_links = $total_links + substr_count($row['content'], "href="); |
|
2764 | + $total_links_anchors = $total_links_anchors + substr_count($row['content'], 'href="#'); |
|
2765 | + $total_links_mail = $total_links_mail + substr_count($row['content'], 'href="mailto'); |
|
2766 | + $total_links_ftp = $total_links_ftp + substr_count($row['content'], 'href="ftp'); |
|
2767 | + $total_links_irc = $total_links_irc + substr_count($row['content'], 'href="irc'); |
|
2768 | + $total_links_news = $total_links_news + substr_count($row['content'], 'href="news'); |
|
2769 | + $total_wlinks = $total_wlinks + substr_count($row['content'], "[["); |
|
2770 | + $total_images = $total_images + substr_count($row['content'], "<img"); |
|
2771 | 2771 | $clean_total_flash = preg_replace('/player.swf/', ' ', $row['content']); |
2772 | - $total_flash = $total_flash+substr_count($clean_total_flash, '.swf"'); |
|
2772 | + $total_flash = $total_flash + substr_count($clean_total_flash, '.swf"'); |
|
2773 | 2773 | //.swf" end quotes prevent insert swf through flvplayer (is not counted) |
2774 | - $total_mp3 = $total_mp3+substr_count($row['content'], ".mp3"); |
|
2775 | - $total_flv_p = $total_flv_p+substr_count($row['content'], ".flv"); |
|
2776 | - $total_flv = $total_flv_p/5; |
|
2777 | - $total_youtube = $total_youtube+substr_count($row['content'], "http://www.youtube.com"); |
|
2778 | - $total_multimedia = $total_multimedia+substr_count($row['content'], "video/x-msvideo"); |
|
2779 | - $total_tables = $total_tables+substr_count($row['content'], "<table"); |
|
2774 | + $total_mp3 = $total_mp3 + substr_count($row['content'], ".mp3"); |
|
2775 | + $total_flv_p = $total_flv_p + substr_count($row['content'], ".flv"); |
|
2776 | + $total_flv = $total_flv_p / 5; |
|
2777 | + $total_youtube = $total_youtube + substr_count($row['content'], "http://www.youtube.com"); |
|
2778 | + $total_multimedia = $total_multimedia + substr_count($row['content'], "video/x-msvideo"); |
|
2779 | + $total_tables = $total_tables + substr_count($row['content'], "<table"); |
|
2780 | 2780 | } |
2781 | 2781 | |
2782 | 2782 | //check only last version of all pages (current page) |
2783 | 2783 | |
2784 | - $sql =' SELECT *, COUNT(*) AS TOTAL_PAGES, SUM(hits) AS TOTAL_VISITS_LV |
|
2784 | + $sql = ' SELECT *, COUNT(*) AS TOTAL_PAGES, SUM(hits) AS TOTAL_VISITS_LV |
|
2785 | 2785 | FROM '.$tbl_wiki.' s1 |
2786 | 2786 | WHERE s1.c_id = '.$course_id.' AND id=( |
2787 | 2787 | SELECT MAX(s2.id) |
@@ -2792,9 +2792,9 @@ discard block |
||
2792 | 2792 | '.$groupfilter.' AND |
2793 | 2793 | session_id='.$session_id.')'; |
2794 | 2794 | $allpages = Database::query($sql); |
2795 | - while ($row=Database::fetch_array($allpages)) { |
|
2796 | - $total_pages = $row['TOTAL_PAGES']; |
|
2797 | - $total_visits_lv = intval($row['TOTAL_VISITS_LV']); |
|
2795 | + while ($row = Database::fetch_array($allpages)) { |
|
2796 | + $total_pages = $row['TOTAL_PAGES']; |
|
2797 | + $total_visits_lv = intval($row['TOTAL_VISITS_LV']); |
|
2798 | 2798 | } |
2799 | 2799 | |
2800 | 2800 | $total_words_lv = 0; |
@@ -2826,29 +2826,29 @@ discard block |
||
2826 | 2826 | )'; |
2827 | 2827 | $allpages = Database::query($sql); |
2828 | 2828 | |
2829 | - while ($row=Database::fetch_array($allpages)) { |
|
2830 | - $total_words_lv = $total_words_lv+ self::word_count($row['content']); |
|
2831 | - $total_links_lv = $total_links_lv+substr_count($row['content'], "href="); |
|
2832 | - $total_links_anchors_lv = $total_links_anchors_lv+substr_count($row['content'], 'href="#'); |
|
2833 | - $total_links_mail_lv = $total_links_mail_lv+substr_count($row['content'], 'href="mailto'); |
|
2834 | - $total_links_ftp_lv = $total_links_ftp_lv+substr_count($row['content'], 'href="ftp'); |
|
2835 | - $total_links_irc_lv = $total_links_irc_lv+substr_count($row['content'], 'href="irc'); |
|
2836 | - $total_links_news_lv = $total_links_news_lv+substr_count($row['content'], 'href="news'); |
|
2837 | - $total_wlinks_lv = $total_wlinks_lv+substr_count($row['content'], "[["); |
|
2838 | - $total_images_lv = $total_images_lv+substr_count($row['content'], "<img"); |
|
2829 | + while ($row = Database::fetch_array($allpages)) { |
|
2830 | + $total_words_lv = $total_words_lv + self::word_count($row['content']); |
|
2831 | + $total_links_lv = $total_links_lv + substr_count($row['content'], "href="); |
|
2832 | + $total_links_anchors_lv = $total_links_anchors_lv + substr_count($row['content'], 'href="#'); |
|
2833 | + $total_links_mail_lv = $total_links_mail_lv + substr_count($row['content'], 'href="mailto'); |
|
2834 | + $total_links_ftp_lv = $total_links_ftp_lv + substr_count($row['content'], 'href="ftp'); |
|
2835 | + $total_links_irc_lv = $total_links_irc_lv + substr_count($row['content'], 'href="irc'); |
|
2836 | + $total_links_news_lv = $total_links_news_lv + substr_count($row['content'], 'href="news'); |
|
2837 | + $total_wlinks_lv = $total_wlinks_lv + substr_count($row['content'], "[["); |
|
2838 | + $total_images_lv = $total_images_lv + substr_count($row['content'], "<img"); |
|
2839 | 2839 | $clean_total_flash_lv = preg_replace('/player.swf/', ' ', $row['content']); |
2840 | - $total_flash_lv = $total_flash_lv+substr_count($clean_total_flash_lv, '.swf"'); |
|
2840 | + $total_flash_lv = $total_flash_lv + substr_count($clean_total_flash_lv, '.swf"'); |
|
2841 | 2841 | //.swf" end quotes prevent insert swf through flvplayer (is not counted) |
2842 | - $total_mp3_lv = $total_mp3_lv+substr_count($row['content'], ".mp3"); |
|
2843 | - $total_flv_p_lv = $total_flv_p_lv+substr_count($row['content'], ".flv"); |
|
2844 | - $total_flv_lv = $total_flv_p_lv/5; |
|
2845 | - $total_youtube_lv = $total_youtube_lv+substr_count($row['content'], "http://www.youtube.com"); |
|
2846 | - $total_multimedia_lv = $total_multimedia_lv+substr_count($row['content'], "video/x-msvideo"); |
|
2847 | - $total_tables_lv = $total_tables_lv+substr_count($row['content'], "<table"); |
|
2842 | + $total_mp3_lv = $total_mp3_lv + substr_count($row['content'], ".mp3"); |
|
2843 | + $total_flv_p_lv = $total_flv_p_lv + substr_count($row['content'], ".flv"); |
|
2844 | + $total_flv_lv = $total_flv_p_lv / 5; |
|
2845 | + $total_youtube_lv = $total_youtube_lv + substr_count($row['content'], "http://www.youtube.com"); |
|
2846 | + $total_multimedia_lv = $total_multimedia_lv + substr_count($row['content'], "video/x-msvideo"); |
|
2847 | + $total_tables_lv = $total_tables_lv + substr_count($row['content'], "<table"); |
|
2848 | 2848 | } |
2849 | 2849 | |
2850 | 2850 | //Total pages edited at this time |
2851 | - $total_editing_now=0; |
|
2851 | + $total_editing_now = 0; |
|
2852 | 2852 | $sql = 'SELECT *, COUNT(*) AS TOTAL_EDITING_NOW |
2853 | 2853 | FROM '.$tbl_wiki.' s1 |
2854 | 2854 | WHERE is_editing!=0 AND s1.c_id = '.$course_id.' AND |
@@ -2863,66 +2863,66 @@ discard block |
||
2863 | 2863 | )'; |
2864 | 2864 | |
2865 | 2865 | // Can not use group by because the mark is set in the latest version |
2866 | - $allpages=Database::query($sql); |
|
2867 | - while ($row=Database::fetch_array($allpages)) { |
|
2868 | - $total_editing_now = $row['TOTAL_EDITING_NOW']; |
|
2866 | + $allpages = Database::query($sql); |
|
2867 | + while ($row = Database::fetch_array($allpages)) { |
|
2868 | + $total_editing_now = $row['TOTAL_EDITING_NOW']; |
|
2869 | 2869 | } |
2870 | 2870 | |
2871 | 2871 | // Total hidden pages |
2872 | - $total_hidden=0; |
|
2872 | + $total_hidden = 0; |
|
2873 | 2873 | $sql = 'SELECT * FROM '.$tbl_wiki.' |
2874 | 2874 | WHERE c_id = '.$course_id.' AND visibility=0 AND '.$groupfilter.$condition_session.' |
2875 | 2875 | GROUP BY reflink'; |
2876 | 2876 | // or group by page_id. As the mark of hidden places it in all versions of the page, I can use group by to see the first |
2877 | - $allpages=Database::query($sql); |
|
2878 | - while ($row=Database::fetch_array($allpages)) { |
|
2879 | - $total_hidden = $total_hidden+1; |
|
2877 | + $allpages = Database::query($sql); |
|
2878 | + while ($row = Database::fetch_array($allpages)) { |
|
2879 | + $total_hidden = $total_hidden + 1; |
|
2880 | 2880 | } |
2881 | 2881 | |
2882 | 2882 | //Total protect pages |
2883 | - $total_protected=0; |
|
2883 | + $total_protected = 0; |
|
2884 | 2884 | $sql = 'SELECT * FROM '.$tbl_wiki.' |
2885 | 2885 | WHERE c_id = '.$course_id.' AND editlock=1 AND '.$groupfilter.$condition_session.' |
2886 | 2886 | GROUP BY reflink'; |
2887 | 2887 | // or group by page_id. As the mark of protected page is the first version of the page, I can use group by |
2888 | 2888 | |
2889 | - $allpages=Database::query($sql); |
|
2890 | - while ($row=Database::fetch_array($allpages)) { |
|
2891 | - $total_protected = $total_protected+1; |
|
2889 | + $allpages = Database::query($sql); |
|
2890 | + while ($row = Database::fetch_array($allpages)) { |
|
2891 | + $total_protected = $total_protected + 1; |
|
2892 | 2892 | } |
2893 | 2893 | |
2894 | 2894 | // Total empty versions. |
2895 | - $total_empty_content=0; |
|
2895 | + $total_empty_content = 0; |
|
2896 | 2896 | $sql = 'SELECT * FROM '.$tbl_wiki.' |
2897 | 2897 | WHERE |
2898 | 2898 | c_id = '.$course_id.' AND |
2899 | 2899 | content="" AND |
2900 | 2900 | '.$groupfilter.$condition_session.''; |
2901 | 2901 | $allpages = Database::query($sql); |
2902 | - while ($row=Database::fetch_array($allpages)) { |
|
2903 | - $total_empty_content = $total_empty_content+1; |
|
2902 | + while ($row = Database::fetch_array($allpages)) { |
|
2903 | + $total_empty_content = $total_empty_content + 1; |
|
2904 | 2904 | } |
2905 | 2905 | |
2906 | 2906 | //Total empty pages (last version) |
2907 | 2907 | |
2908 | - $total_empty_content_lv=0; |
|
2908 | + $total_empty_content_lv = 0; |
|
2909 | 2909 | $sql = 'SELECT * FROM '.$tbl_wiki.' s1 |
2910 | 2910 | WHERE s1.c_id = '.$course_id.' AND content="" AND id=( |
2911 | 2911 | SELECT MAX(s2.id) FROM '.$tbl_wiki.' s2 |
2912 | 2912 | WHERE s1.c_id = '.$course_id.' AND s1.reflink = s2.reflink AND '.$groupfilter.' AND session_id='.$session_id.')'; |
2913 | - $allpages=Database::query($sql); |
|
2913 | + $allpages = Database::query($sql); |
|
2914 | 2914 | while ($row = Database::fetch_array($allpages)) { |
2915 | - $total_empty_content_lv = $total_empty_content_lv+1; |
|
2915 | + $total_empty_content_lv = $total_empty_content_lv + 1; |
|
2916 | 2916 | } |
2917 | 2917 | |
2918 | 2918 | // Total locked discuss pages |
2919 | - $total_lock_disc=0; |
|
2919 | + $total_lock_disc = 0; |
|
2920 | 2920 | $sql = 'SELECT * FROM '.$tbl_wiki.' |
2921 | 2921 | WHERE c_id = '.$course_id.' AND addlock_disc=0 AND '.$groupfilter.$condition_session.' |
2922 | 2922 | GROUP BY reflink';//group by because mark lock in all vers, then always is ok |
2923 | - $allpages=Database::query($sql); |
|
2923 | + $allpages = Database::query($sql); |
|
2924 | 2924 | while ($row = Database::fetch_array($allpages)) { |
2925 | - $total_lock_disc = $total_lock_disc+1; |
|
2925 | + $total_lock_disc = $total_lock_disc + 1; |
|
2926 | 2926 | } |
2927 | 2927 | |
2928 | 2928 | // Total hidden discuss pages. |
@@ -2933,7 +2933,7 @@ discard block |
||
2933 | 2933 | //group by because mark lock in all vers, then always is ok |
2934 | 2934 | $allpages = Database::query($sql); |
2935 | 2935 | while ($row = Database::fetch_array($allpages)) { |
2936 | - $total_hidden_disc = $total_hidden_disc+1; |
|
2936 | + $total_hidden_disc = $total_hidden_disc + 1; |
|
2937 | 2937 | } |
2938 | 2938 | |
2939 | 2939 | //Total versions with any short comment by user or system |
@@ -2941,44 +2941,44 @@ discard block |
||
2941 | 2941 | $total_comment_version = 0; |
2942 | 2942 | $sql = 'SELECT * FROM '.$tbl_wiki.' |
2943 | 2943 | WHERE c_id = '.$course_id.' AND comment!="" AND '.$groupfilter.$condition_session.''; |
2944 | - $allpages=Database::query($sql); |
|
2944 | + $allpages = Database::query($sql); |
|
2945 | 2945 | while ($row = Database::fetch_array($allpages)) { |
2946 | - $total_comment_version = $total_comment_version+1; |
|
2946 | + $total_comment_version = $total_comment_version + 1; |
|
2947 | 2947 | } |
2948 | 2948 | |
2949 | 2949 | // Total pages that can only be scored by teachers. |
2950 | 2950 | |
2951 | - $total_only_teachers_rating=0; |
|
2951 | + $total_only_teachers_rating = 0; |
|
2952 | 2952 | $sql = 'SELECT * FROM '.$tbl_wiki.' |
2953 | 2953 | WHERE c_id = '.$course_id.' AND |
2954 | 2954 | ratinglock_disc = 0 AND |
2955 | 2955 | '.$groupfilter.$condition_session.' |
2956 | 2956 | GROUP BY reflink';//group by because mark lock in all vers, then always is ok |
2957 | - $allpages=Database::query($sql); |
|
2958 | - while ($row=Database::fetch_array($allpages)) { |
|
2959 | - $total_only_teachers_rating = $total_only_teachers_rating+1; |
|
2957 | + $allpages = Database::query($sql); |
|
2958 | + while ($row = Database::fetch_array($allpages)) { |
|
2959 | + $total_only_teachers_rating = $total_only_teachers_rating + 1; |
|
2960 | 2960 | } |
2961 | 2961 | |
2962 | 2962 | // Total pages scored by peers |
2963 | 2963 | // put always this line alfter check num all pages and num pages rated by teachers |
2964 | - $total_rating_by_peers=$total_pages-$total_only_teachers_rating; |
|
2964 | + $total_rating_by_peers = $total_pages - $total_only_teachers_rating; |
|
2965 | 2965 | |
2966 | 2966 | //Total pages identified as standard task |
2967 | 2967 | |
2968 | - $total_task=0; |
|
2969 | - $sql='SELECT * FROM '.$tbl_wiki.', '.$tbl_wiki_conf.' |
|
2968 | + $total_task = 0; |
|
2969 | + $sql = 'SELECT * FROM '.$tbl_wiki.', '.$tbl_wiki_conf.' |
|
2970 | 2970 | WHERE '.$tbl_wiki_conf.'.c_id = '.$course_id.' AND |
2971 | 2971 | '.$tbl_wiki_conf.'.task!="" AND |
2972 | 2972 | '.$tbl_wiki_conf.'.page_id='.$tbl_wiki.'.page_id AND |
2973 | 2973 | '.$tbl_wiki.'.'.$groupfilter.$condition_session; |
2974 | 2974 | $allpages = Database::query($sql); |
2975 | - while ($row=Database::fetch_array($allpages)) { |
|
2976 | - $total_task=$total_task+1; |
|
2975 | + while ($row = Database::fetch_array($allpages)) { |
|
2976 | + $total_task = $total_task + 1; |
|
2977 | 2977 | } |
2978 | 2978 | |
2979 | 2979 | //Total pages identified as teacher page (wiki portfolio mode - individual assignment) |
2980 | 2980 | |
2981 | - $total_teacher_assignment=0; |
|
2981 | + $total_teacher_assignment = 0; |
|
2982 | 2982 | $sql = 'SELECT * FROM '.$tbl_wiki.' s1 |
2983 | 2983 | WHERE s1.c_id = '.$course_id.' AND assignment=1 AND id=( |
2984 | 2984 | SELECT MAX(s2.id) |
@@ -2988,20 +2988,20 @@ discard block |
||
2988 | 2988 | //mark all versions, but do not use group by reflink because y want the pages not versions |
2989 | 2989 | $allpages = Database::query($sql); |
2990 | 2990 | while ($row = Database::fetch_array($allpages)) { |
2991 | - $total_teacher_assignment=$total_teacher_assignment+1; |
|
2991 | + $total_teacher_assignment = $total_teacher_assignment + 1; |
|
2992 | 2992 | } |
2993 | 2993 | |
2994 | 2994 | //Total pages identifies as student page (wiki portfolio mode - individual assignment) |
2995 | 2995 | |
2996 | - $total_student_assignment=0; |
|
2996 | + $total_student_assignment = 0; |
|
2997 | 2997 | $sql = 'SELECT * FROM '.$tbl_wiki.' s1 |
2998 | 2998 | WHERE s1.c_id = '.$course_id.' AND assignment=2 AND |
2999 | 2999 | id=(SELECT MAX(s2.id) FROM '.$tbl_wiki.' s2 |
3000 | 3000 | WHERE s2.c_id = '.$course_id.' AND s1.reflink = s2.reflink AND '.$groupfilter.' AND session_id='.$session_id.')'; |
3001 | 3001 | //mark all versions, but do not use group by reflink because y want the pages not versions |
3002 | - $allpages=Database::query($sql); |
|
3003 | - while ($row=Database::fetch_array($allpages)) { |
|
3004 | - $total_student_assignment = $total_student_assignment+1; |
|
3002 | + $allpages = Database::query($sql); |
|
3003 | + while ($row = Database::fetch_array($allpages)) { |
|
3004 | + $total_student_assignment = $total_student_assignment + 1; |
|
3005 | 3005 | } |
3006 | 3006 | |
3007 | 3007 | //Current Wiki status add new pages |
@@ -3010,14 +3010,14 @@ discard block |
||
3010 | 3010 | GROUP BY addlock';//group by because mark 0 in all vers, then always is ok |
3011 | 3011 | $allpages = Database::query($sql); |
3012 | 3012 | $wiki_add_lock = null; |
3013 | - while ($row=Database::fetch_array($allpages)) { |
|
3014 | - $wiki_add_lock=$row['addlock']; |
|
3013 | + while ($row = Database::fetch_array($allpages)) { |
|
3014 | + $wiki_add_lock = $row['addlock']; |
|
3015 | 3015 | } |
3016 | 3016 | |
3017 | - if ($wiki_add_lock==1) { |
|
3018 | - $status_add_new_pag=get_lang('Yes'); |
|
3017 | + if ($wiki_add_lock == 1) { |
|
3018 | + $status_add_new_pag = get_lang('Yes'); |
|
3019 | 3019 | } else { |
3020 | - $status_add_new_pag=get_lang('No'); |
|
3020 | + $status_add_new_pag = get_lang('No'); |
|
3021 | 3021 | } |
3022 | 3022 | |
3023 | 3023 | //Creation date of the oldest wiki page and version |
@@ -3040,7 +3040,7 @@ discard block |
||
3040 | 3040 | ORDER BY dtime DESC |
3041 | 3041 | LIMIT 1'; |
3042 | 3042 | $allpages = Database::query($sql); |
3043 | - while ($row=Database::fetch_array($allpages)) { |
|
3043 | + while ($row = Database::fetch_array($allpages)) { |
|
3044 | 3044 | $last_wiki_date = $row['dtime']; |
3045 | 3045 | } |
3046 | 3046 | |
@@ -3053,18 +3053,18 @@ discard block |
||
3053 | 3053 | // Do not use "count" because using "group by", would give a wrong value |
3054 | 3054 | $allpages = Database::query($sql); |
3055 | 3055 | $total_score = 0; |
3056 | - while ($row=Database::fetch_array($allpages)) { |
|
3057 | - $total_score = $total_score+$row['TOTAL_SCORE']; |
|
3056 | + while ($row = Database::fetch_array($allpages)) { |
|
3057 | + $total_score = $total_score + $row['TOTAL_SCORE']; |
|
3058 | 3058 | } |
3059 | 3059 | |
3060 | 3060 | if (!empty($total_pages)) { |
3061 | - $media_score = $total_score/$total_pages; |
|
3061 | + $media_score = $total_score / $total_pages; |
|
3062 | 3062 | //put always this line alfter check num all pages |
3063 | 3063 | } |
3064 | 3064 | |
3065 | 3065 | // Average user progress in his pages. |
3066 | 3066 | |
3067 | - $media_progress=0; |
|
3067 | + $media_progress = 0; |
|
3068 | 3068 | $sql = 'SELECT *, SUM(progress) AS TOTAL_PROGRESS |
3069 | 3069 | FROM '.$tbl_wiki.' s1 |
3070 | 3070 | WHERE s1.c_id = '.$course_id.' AND id= |
@@ -3078,24 +3078,24 @@ discard block |
||
3078 | 3078 | // As the value is only the latest version I can not use group by |
3079 | 3079 | $allpages = Database::query($sql); |
3080 | 3080 | while ($row = Database::fetch_array($allpages)) { |
3081 | - $total_progress = $row['TOTAL_PROGRESS']; |
|
3081 | + $total_progress = $row['TOTAL_PROGRESS']; |
|
3082 | 3082 | } |
3083 | 3083 | |
3084 | 3084 | if (!empty($total_pages)) { |
3085 | - $media_progress=$total_progress/$total_pages; |
|
3085 | + $media_progress = $total_progress / $total_pages; |
|
3086 | 3086 | //put always this line alfter check num all pages |
3087 | 3087 | } |
3088 | 3088 | |
3089 | 3089 | //Total users that have participated in the Wiki |
3090 | 3090 | |
3091 | - $total_users=0; |
|
3091 | + $total_users = 0; |
|
3092 | 3092 | $sql = 'SELECT * FROM '.$tbl_wiki.' |
3093 | 3093 | WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.' |
3094 | 3094 | GROUP BY user_id'; |
3095 | 3095 | //as the mark of user it in all versions of the page, I can use group by to see the first |
3096 | - $allpages=Database::query($sql); |
|
3097 | - while ($row=Database::fetch_array($allpages)) { |
|
3098 | - $total_users = $total_users+1; |
|
3096 | + $allpages = Database::query($sql); |
|
3097 | + while ($row = Database::fetch_array($allpages)) { |
|
3098 | + $total_users = $total_users + 1; |
|
3099 | 3099 | } |
3100 | 3100 | |
3101 | 3101 | // Total of different IP addresses that have participated in the wiki |
@@ -3103,9 +3103,9 @@ discard block |
||
3103 | 3103 | $sql = 'SELECT * FROM '.$tbl_wiki.' |
3104 | 3104 | WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.' |
3105 | 3105 | GROUP BY user_ip'; |
3106 | - $allpages=Database::query($sql); |
|
3107 | - while ($row=Database::fetch_array($allpages)) { |
|
3108 | - $total_ip = $total_ip+1; |
|
3106 | + $allpages = Database::query($sql); |
|
3107 | + while ($row = Database::fetch_array($allpages)) { |
|
3108 | + $total_ip = $total_ip + 1; |
|
3109 | 3109 | } |
3110 | 3110 | |
3111 | 3111 | echo '<table class="data_table">'; |
@@ -3297,18 +3297,18 @@ discard block |
||
3297 | 3297 | $userinfo = api_get_user_info($obj->user_id); |
3298 | 3298 | $username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username']), ENT_QUOTES); |
3299 | 3299 | $row = array(); |
3300 | - if ($obj->user_id != 0 && $userinfo !== false) { |
|
3300 | + if ($obj->user_id != 0 && $userinfo !== false) { |
|
3301 | 3301 | $row[] = UserManager::getUserProfileLink($userinfo).' |
3302 | 3302 | <a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=usercontrib&user_id='.urlencode($obj->user_id). |
3303 | 3303 | '&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'"></a>'; |
3304 | 3304 | } else { |
3305 | 3305 | $row[] = get_lang('Anonymous').' ('.$obj->user_ip.')'; |
3306 | 3306 | } |
3307 | - $row[] ='<a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=usercontrib&user_id='.urlencode($obj->user_id).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'.$obj->NUM_EDIT.'</a>'; |
|
3307 | + $row[] = '<a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=usercontrib&user_id='.urlencode($obj->user_id).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'.$obj->NUM_EDIT.'</a>'; |
|
3308 | 3308 | $rows[] = $row; |
3309 | 3309 | } |
3310 | 3310 | |
3311 | - $table = new SortableTableFromArrayConfig($rows,1,10,'MostActiveUsersA_table','','','DESC'); |
|
3311 | + $table = new SortableTableFromArrayConfig($rows, 1, 10, 'MostActiveUsersA_table', '', '', 'DESC'); |
|
3312 | 3312 | $table->set_additional_parameters( |
3313 | 3313 | array( |
3314 | 3314 | 'cidReq' => Security::remove_XSS($_GET['cidReq']), |
@@ -3317,8 +3317,8 @@ discard block |
||
3317 | 3317 | 'group_id' => Security::remove_XSS($_GET['group_id']) |
3318 | 3318 | ) |
3319 | 3319 | ); |
3320 | - $table->set_header(0,get_lang('Author'), true); |
|
3321 | - $table->set_header(1,get_lang('Contributions'), true,array ('style' => 'width:30px;')); |
|
3320 | + $table->set_header(0, get_lang('Author'), true); |
|
3321 | + $table->set_header(1, get_lang('Contributions'), true, array('style' => 'width:30px;')); |
|
3322 | 3322 | $table->display(); |
3323 | 3323 | } |
3324 | 3324 | } |
@@ -3334,8 +3334,8 @@ discard block |
||
3334 | 3334 | $groupfilter = $this->groupfilter; |
3335 | 3335 | $tbl_wiki_discuss = $this->tbl_wiki_discuss; |
3336 | 3336 | |
3337 | - if (api_get_session_id()!=0 && |
|
3338 | - api_is_allowed_to_session_edit(false,true)==false |
|
3337 | + if (api_get_session_id() != 0 && |
|
3338 | + api_is_allowed_to_session_edit(false, true) == false |
|
3339 | 3339 | ) { |
3340 | 3340 | api_not_allowed(); |
3341 | 3341 | } |
@@ -3396,9 +3396,9 @@ discard block |
||
3396 | 3396 | //mode assignment: previous to show page type |
3397 | 3397 | $icon_assignment = null; |
3398 | 3398 | if ($row['assignment'] == 1) { |
3399 | - $icon_assignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'),'',ICON_SIZE_SMALL); |
|
3399 | + $icon_assignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'), '', ICON_SIZE_SMALL); |
|
3400 | 3400 | } elseif ($row['assignment'] == 2) { |
3401 | - $icon_assignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWorkExtra'),'',ICON_SIZE_SMALL); |
|
3401 | + $icon_assignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWorkExtra'), '', ICON_SIZE_SMALL); |
|
3402 | 3402 | } |
3403 | 3403 | |
3404 | 3404 | $countWPost = null; |
@@ -3413,19 +3413,19 @@ discard block |
||
3413 | 3413 | if ($row['visibility_disc'] == 1 || |
3414 | 3414 | api_is_allowed_to_edit(false, true) || |
3415 | 3415 | api_is_platform_admin() || |
3416 | - ($row['assignment'] == 2 && $row['visibility_disc']==0 && (api_get_user_id()==$row['user_id'])) |
|
3416 | + ($row['assignment'] == 2 && $row['visibility_disc'] == 0 && (api_get_user_id() == $row['user_id'])) |
|
3417 | 3417 | ) { |
3418 | 3418 | echo '<div id="wikititle">'; |
3419 | 3419 | // discussion action: protecting (locking) the discussion |
3420 | 3420 | $addlock_disc = null; |
3421 | 3421 | $lock_unlock_disc = null; |
3422 | - if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { |
|
3422 | + if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { |
|
3423 | 3423 | if (self::check_addlock_discuss() == 1) { |
3424 | - $addlock_disc = Display::return_icon('unlock.png', get_lang('UnlockDiscussExtra'),'',ICON_SIZE_SMALL); |
|
3425 | - $lock_unlock_disc ='unlockdisc'; |
|
3424 | + $addlock_disc = Display::return_icon('unlock.png', get_lang('UnlockDiscussExtra'), '', ICON_SIZE_SMALL); |
|
3425 | + $lock_unlock_disc = 'unlockdisc'; |
|
3426 | 3426 | } else { |
3427 | - $addlock_disc = Display::return_icon('lock.png', get_lang('LockDiscussExtra'),'',ICON_SIZE_SMALL); |
|
3428 | - $lock_unlock_disc ='lockdisc'; |
|
3427 | + $addlock_disc = Display::return_icon('lock.png', get_lang('LockDiscussExtra'), '', ICON_SIZE_SMALL); |
|
3428 | + $lock_unlock_disc = 'lockdisc'; |
|
3429 | 3429 | } |
3430 | 3430 | } |
3431 | 3431 | echo '<span style="float:right">'; |
@@ -3436,12 +3436,12 @@ discard block |
||
3436 | 3436 | $visibility_disc = null; |
3437 | 3437 | $hide_show_disc = null; |
3438 | 3438 | if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { |
3439 | - if (self::check_visibility_discuss()==1) { |
|
3439 | + if (self::check_visibility_discuss() == 1) { |
|
3440 | 3440 | /// TODO: Fix Mode assignments: If is hidden, show discussion to student only if student is the author |
3441 | - $visibility_disc = Display::return_icon('visible.png', get_lang('ShowDiscussExtra'),'',ICON_SIZE_SMALL); |
|
3441 | + $visibility_disc = Display::return_icon('visible.png', get_lang('ShowDiscussExtra'), '', ICON_SIZE_SMALL); |
|
3442 | 3442 | $hide_show_disc = 'hidedisc'; |
3443 | 3443 | } else { |
3444 | - $visibility_disc = Display::return_icon('invisible.png', get_lang('HideDiscussExtra'),'',ICON_SIZE_SMALL); |
|
3444 | + $visibility_disc = Display::return_icon('invisible.png', get_lang('HideDiscussExtra'), '', ICON_SIZE_SMALL); |
|
3445 | 3445 | $hide_show_disc = 'showdisc'; |
3446 | 3446 | } |
3447 | 3447 | } |
@@ -3454,10 +3454,10 @@ discard block |
||
3454 | 3454 | $ratinglock_disc = null; |
3455 | 3455 | if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { |
3456 | 3456 | if (self::check_ratinglock_discuss() == 1) { |
3457 | - $ratinglock_disc = Display::return_icon('star.png', get_lang('UnlockRatingDiscussExtra'),'',ICON_SIZE_SMALL); |
|
3457 | + $ratinglock_disc = Display::return_icon('star.png', get_lang('UnlockRatingDiscussExtra'), '', ICON_SIZE_SMALL); |
|
3458 | 3458 | $lock_unlock_rating_disc = 'unlockrating'; |
3459 | 3459 | } else { |
3460 | - $ratinglock_disc = Display::return_icon('star_na.png', get_lang('LockRatingDiscussExtra'),'',ICON_SIZE_SMALL); |
|
3460 | + $ratinglock_disc = Display::return_icon('star_na.png', get_lang('LockRatingDiscussExtra'), '', ICON_SIZE_SMALL); |
|
3461 | 3461 | $lock_unlock_rating_disc = 'lockrating'; |
3462 | 3462 | } |
3463 | 3463 | } |
@@ -3468,11 +3468,11 @@ discard block |
||
3468 | 3468 | |
3469 | 3469 | //discussion action: email notification |
3470 | 3470 | if (self::check_notify_discuss($page) == 1) { |
3471 | - $notify_disc= Display::return_icon('messagebox_info.png', get_lang('NotifyDiscussByEmail'),'',ICON_SIZE_SMALL); |
|
3472 | - $lock_unlock_notify_disc='unlocknotifydisc'; |
|
3471 | + $notify_disc = Display::return_icon('messagebox_info.png', get_lang('NotifyDiscussByEmail'), '', ICON_SIZE_SMALL); |
|
3472 | + $lock_unlock_notify_disc = 'unlocknotifydisc'; |
|
3473 | 3473 | } else { |
3474 | - $notify_disc= Display::return_icon('mail.png', get_lang('CancelNotifyDiscussByEmail'),'',ICON_SIZE_SMALL); |
|
3475 | - $lock_unlock_notify_disc='locknotifydisc'; |
|
3474 | + $notify_disc = Display::return_icon('mail.png', get_lang('CancelNotifyDiscussByEmail'), '', ICON_SIZE_SMALL); |
|
3475 | + $lock_unlock_notify_disc = 'locknotifydisc'; |
|
3476 | 3476 | } |
3477 | 3477 | echo '<span style="float:right">'; |
3478 | 3478 | echo '<a href="index.php?action=discuss&actionpage='.$lock_unlock_notify_disc.'&title='.api_htmlentities(urlencode($page)).'">'.$notify_disc.'</a>'; |
@@ -3481,26 +3481,26 @@ discard block |
||
3481 | 3481 | echo $icon_assignment.' '.api_htmlentities($row['title']); |
3482 | 3482 | |
3483 | 3483 | if ($lastuserinfo !== false) { |
3484 | - echo ' (' . get_lang('MostRecentVersionBy') . ' ' . UserManager::getUserProfileLink($lastuserinfo) . ' ' . $lastversiondate . $countWPost . ')' . $avg_WPost_score . ' '; //TODO: read average score |
|
3484 | + echo ' ('.get_lang('MostRecentVersionBy').' '.UserManager::getUserProfileLink($lastuserinfo).' '.$lastversiondate.$countWPost.')'.$avg_WPost_score.' '; //TODO: read average score |
|
3485 | 3485 | } |
3486 | 3486 | |
3487 | 3487 | echo '</div>'; |
3488 | - if ($row['addlock_disc']==1 || api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { |
|
3488 | + if ($row['addlock_disc'] == 1 || api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { |
|
3489 | 3489 | //show comments but students can't add theirs |
3490 | 3490 | ?> |
3491 | 3491 | <form name="form1" method="post" action=""> |
3492 | 3492 | <table> |
3493 | 3493 | <tr> |
3494 | - <td valign="top" ><?php echo get_lang('Comments');?>:</td> |
|
3495 | - <?php echo '<input type="hidden" name="wpost_id" value="'.md5(uniqid(rand(), true)).'">';//prevent double post ?> |
|
3494 | + <td valign="top" ><?php echo get_lang('Comments'); ?>:</td> |
|
3495 | + <?php echo '<input type="hidden" name="wpost_id" value="'.md5(uniqid(rand(), true)).'">'; //prevent double post ?> |
|
3496 | 3496 | <td><textarea name="comment" cols="80" rows="5" id="comment"></textarea></td> |
3497 | 3497 | </tr> |
3498 | 3498 | <tr> |
3499 | 3499 | <?php |
3500 | 3500 | //check if rating is allowed |
3501 | - if ($row['ratinglock_disc']==1 || api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { |
|
3501 | + if ($row['ratinglock_disc'] == 1 || api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { |
|
3502 | 3502 | ?> |
3503 | - <td><?php echo get_lang('Rating');?>: </td> |
|
3503 | + <td><?php echo get_lang('Rating'); ?>: </td> |
|
3504 | 3504 | <td valign="top"><select name="rating" id="rating"> |
3505 | 3505 | <option value="-" selected>-</option> |
3506 | 3506 | <option value="0">0</option> |
@@ -3517,7 +3517,7 @@ discard block |
||
3517 | 3517 | </select></td> |
3518 | 3518 | <?php |
3519 | 3519 | } else { |
3520 | - echo '<input type=hidden name="rating" value="-">';// must pass a default value to avoid rate automatically |
|
3520 | + echo '<input type=hidden name="rating" value="-">'; // must pass a default value to avoid rate automatically |
|
3521 | 3521 | } |
3522 | 3522 | ?> |
3523 | 3523 | </tr> |
@@ -3557,12 +3557,12 @@ discard block |
||
3557 | 3557 | $sql = "SELECT * FROM $tbl_wiki_discuss |
3558 | 3558 | WHERE c_id = $course_id AND publication_id='".$id."' AND NOT p_score='-'"; |
3559 | 3559 | $result3 = Database::query($sql); |
3560 | - $countWPost_score= Database::num_rows($result3); |
|
3560 | + $countWPost_score = Database::num_rows($result3); |
|
3561 | 3561 | |
3562 | - echo ' - '.get_lang('NumCommentsScore').': '.$countWPost_score;// |
|
3562 | + echo ' - '.get_lang('NumCommentsScore').': '.$countWPost_score; // |
|
3563 | 3563 | |
3564 | - if ($countWPost_score!=0) { |
|
3565 | - $avg_WPost_score = round($row2['sumWPost'] / $countWPost_score,2).' / 10'; |
|
3564 | + if ($countWPost_score != 0) { |
|
3565 | + $avg_WPost_score = round($row2['sumWPost'] / $countWPost_score, 2).' / 10'; |
|
3566 | 3566 | } else { |
3567 | 3567 | $avg_WPost_score = $countWPost_score; |
3568 | 3568 | } |
@@ -3580,16 +3580,16 @@ discard block |
||
3580 | 3580 | |
3581 | 3581 | echo '<hr noshade size="1">'; |
3582 | 3582 | |
3583 | - while ($row=Database::fetch_array($result)) { |
|
3583 | + while ($row = Database::fetch_array($result)) { |
|
3584 | 3584 | $userinfo = api_get_user_info($row['userc_id']); |
3585 | - if (($userinfo['status'])=="5") { |
|
3586 | - $author_status=get_lang('Student'); |
|
3585 | + if (($userinfo['status']) == "5") { |
|
3586 | + $author_status = get_lang('Student'); |
|
3587 | 3587 | } else { |
3588 | - $author_status=get_lang('Teacher'); |
|
3588 | + $author_status = get_lang('Teacher'); |
|
3589 | 3589 | } |
3590 | 3590 | |
3591 | 3591 | $name = $userinfo['complete_name']; |
3592 | - $author_photo= '<img src="'.$userinfo['avatar'].'" alt="'.api_htmlentities($name).'" width="40" height="50" align="top" title="'.api_htmlentities($name).'" />'; |
|
3592 | + $author_photo = '<img src="'.$userinfo['avatar'].'" alt="'.api_htmlentities($name).'" width="40" height="50" align="top" title="'.api_htmlentities($name).'" />'; |
|
3593 | 3593 | |
3594 | 3594 | //stars |
3595 | 3595 | $p_score = $row['p_score']; |
@@ -3635,7 +3635,7 @@ discard block |
||
3635 | 3635 | if ($userinfo !== false) { |
3636 | 3636 | $userProfile = UserManager::getUserProfileLink($userinfo); |
3637 | 3637 | } |
3638 | - echo '<td style=" color:#999999">' . $userProfile . ' (' . $author_status . ') '. |
|
3638 | + echo '<td style=" color:#999999">'.$userProfile.' ('.$author_status.') '. |
|
3639 | 3639 | api_get_local_time($row['dtime'], null, date_default_timezone_get()). |
3640 | 3640 | ' - '.get_lang('Rating').': '.$row['p_score'].' '.$imagerating.' </td>'; |
3641 | 3641 | echo '</tr>'; |
@@ -3672,7 +3672,7 @@ discard block |
||
3672 | 3672 | } |
3673 | 3673 | echo '</div>'; |
3674 | 3674 | |
3675 | - if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { //only by professors if page is hidden |
|
3675 | + if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { //only by professors if page is hidden |
|
3676 | 3676 | $sql = 'SELECT * |
3677 | 3677 | FROM '.$tbl_wiki.' s1 |
3678 | 3678 | WHERE s1.c_id = '.$course_id.' AND id=( |
@@ -3698,11 +3698,11 @@ discard block |
||
3698 | 3698 | $username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username']), ENT_QUOTES); |
3699 | 3699 | |
3700 | 3700 | //get type assignment icon |
3701 | - if ($obj->assignment==1) { |
|
3702 | - $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL); |
|
3703 | - } elseif ($obj->assignment==2) { |
|
3704 | - $ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL); |
|
3705 | - } elseif ($obj->assignment==0) { |
|
3701 | + if ($obj->assignment == 1) { |
|
3702 | + $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'), '', ICON_SIZE_SMALL); |
|
3703 | + } elseif ($obj->assignment == 2) { |
|
3704 | + $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL); |
|
3705 | + } elseif ($obj->assignment == 0) { |
|
3706 | 3706 | $ShowAssignment = Display::return_icon('px_transparent.gif'); |
3707 | 3707 | } |
3708 | 3708 | |
@@ -3725,29 +3725,29 @@ discard block |
||
3725 | 3725 | } |
3726 | 3726 | $row[] = api_get_local_time($obj->dtime, null, date_default_timezone_get()); |
3727 | 3727 | $showdelete = ''; |
3728 | - if (api_is_allowed_to_edit(false,true)|| api_is_platform_admin()) { |
|
3729 | - $showdelete =' <a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=delete&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'. |
|
3730 | - Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL); |
|
3728 | + if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { |
|
3729 | + $showdelete = ' <a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=delete&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'. |
|
3730 | + Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL); |
|
3731 | 3731 | } |
3732 | - if (api_is_allowed_to_session_edit(false,true) ) { |
|
3732 | + if (api_is_allowed_to_session_edit(false, true)) { |
|
3733 | 3733 | $row[] = '<a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=edit&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'. |
3734 | - Display::return_icon('edit.png', get_lang('EditPage'),'',ICON_SIZE_SMALL).'</a> <a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=discuss&title='.api_htmlentities(urlencode($obj->reflink)).'&group_id='.api_htmlentities($_GET['group_id']).'">'. |
|
3735 | - Display::return_icon('discuss.png', get_lang('Discuss'),'',ICON_SIZE_SMALL).'</a> <a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=history&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'. |
|
3736 | - Display::return_icon('history.png', get_lang('History'),'',ICON_SIZE_SMALL).'</a> |
|
3734 | + Display::return_icon('edit.png', get_lang('EditPage'), '', ICON_SIZE_SMALL).'</a> <a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=discuss&title='.api_htmlentities(urlencode($obj->reflink)).'&group_id='.api_htmlentities($_GET['group_id']).'">'. |
|
3735 | + Display::return_icon('discuss.png', get_lang('Discuss'), '', ICON_SIZE_SMALL).'</a> <a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=history&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'. |
|
3736 | + Display::return_icon('history.png', get_lang('History'), '', ICON_SIZE_SMALL).'</a> |
|
3737 | 3737 | <a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=links&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'. |
3738 | - Display::return_icon('what_link_here.png', get_lang('LinksPages'),'',ICON_SIZE_SMALL).'</a>'.$showdelete; |
|
3738 | + Display::return_icon('what_link_here.png', get_lang('LinksPages'), '', ICON_SIZE_SMALL).'</a>'.$showdelete; |
|
3739 | 3739 | } |
3740 | 3740 | $rows[] = $row; |
3741 | 3741 | } |
3742 | 3742 | |
3743 | - $table = new SortableTableFromArrayConfig($rows,1,10,'AllPages_table','','','ASC'); |
|
3744 | - $table->set_additional_parameters(array('cidReq' =>Security::remove_XSS($_GET['cidReq']),'action'=>Security::remove_XSS($action),'group_id'=>Security::remove_XSS($_GET['group_id']))); |
|
3745 | - $table->set_header(0,get_lang('Type'), true, array ('style' => 'width:30px;')); |
|
3746 | - $table->set_header(1,get_lang('Title'), true); |
|
3747 | - $table->set_header(2,get_lang('Author').' ('.get_lang('LastVersion').')', true); |
|
3748 | - $table->set_header(3,get_lang('Date').' ('.get_lang('LastVersion').')', true); |
|
3749 | - if (api_is_allowed_to_session_edit(false,true) ) { |
|
3750 | - $table->set_header(4,get_lang('Actions'), true, array ('style' => 'width:130px;')); |
|
3743 | + $table = new SortableTableFromArrayConfig($rows, 1, 10, 'AllPages_table', '', '', 'ASC'); |
|
3744 | + $table->set_additional_parameters(array('cidReq' =>Security::remove_XSS($_GET['cidReq']), 'action'=>Security::remove_XSS($action), 'group_id'=>Security::remove_XSS($_GET['group_id']))); |
|
3745 | + $table->set_header(0, get_lang('Type'), true, array('style' => 'width:30px;')); |
|
3746 | + $table->set_header(1, get_lang('Title'), true); |
|
3747 | + $table->set_header(2, get_lang('Author').' ('.get_lang('LastVersion').')', true); |
|
3748 | + $table->set_header(3, get_lang('Date').' ('.get_lang('LastVersion').')', true); |
|
3749 | + if (api_is_allowed_to_session_edit(false, true)) { |
|
3750 | + $table->set_header(4, get_lang('Actions'), true, array('style' => 'width:130px;')); |
|
3751 | 3751 | } |
3752 | 3752 | $table->display(); |
3753 | 3753 | } |
@@ -3767,13 +3767,13 @@ discard block |
||
3767 | 3767 | $groupfilter = $this->groupfilter; |
3768 | 3768 | $tbl_wiki_conf = $this->tbl_wiki_conf; |
3769 | 3769 | |
3770 | - if (api_is_allowed_to_session_edit(false,true) ) { |
|
3771 | - if (self::check_notify_all()==1) { |
|
3772 | - $notify_all= Display::return_icon('messagebox_info.png', get_lang('NotifyByEmail'),'',ICON_SIZE_SMALL).' '.get_lang('NotNotifyChanges'); |
|
3773 | - $lock_unlock_notify_all='unlocknotifyall'; |
|
3770 | + if (api_is_allowed_to_session_edit(false, true)) { |
|
3771 | + if (self::check_notify_all() == 1) { |
|
3772 | + $notify_all = Display::return_icon('messagebox_info.png', get_lang('NotifyByEmail'), '', ICON_SIZE_SMALL).' '.get_lang('NotNotifyChanges'); |
|
3773 | + $lock_unlock_notify_all = 'unlocknotifyall'; |
|
3774 | 3774 | } else { |
3775 | - $notify_all=Display::return_icon('mail.png', get_lang('CancelNotifyByEmail'),'',ICON_SIZE_SMALL).' '.get_lang('NotifyChanges'); |
|
3776 | - $lock_unlock_notify_all='locknotifyall'; |
|
3775 | + $notify_all = Display::return_icon('mail.png', get_lang('CancelNotifyByEmail'), '', ICON_SIZE_SMALL).' '.get_lang('NotifyChanges'); |
|
3776 | + $lock_unlock_notify_all = 'locknotifyall'; |
|
3777 | 3777 | } |
3778 | 3778 | } |
3779 | 3779 | |
@@ -3781,7 +3781,7 @@ discard block |
||
3781 | 3781 | echo '<a href="index.php?action=recentchanges&actionpage='.$lock_unlock_notify_all.'&title='.api_htmlentities(urlencode($page)).'">'.$notify_all.'</a>'; |
3782 | 3782 | echo '</span>'.get_lang('RecentChanges').'</div>'; |
3783 | 3783 | |
3784 | - if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { //only by professors if page is hidden |
|
3784 | + if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { //only by professors if page is hidden |
|
3785 | 3785 | $sql = 'SELECT * FROM '.$tbl_wiki.', '.$tbl_wiki_conf.' |
3786 | 3786 | WHERE '.$tbl_wiki_conf.'.c_id= '.$course_id.' AND |
3787 | 3787 | '.$tbl_wiki.'.c_id= '.$course_id.' AND |
@@ -3809,19 +3809,19 @@ discard block |
||
3809 | 3809 | $userinfo = api_get_user_info($obj->user_id); |
3810 | 3810 | |
3811 | 3811 | //get type assignment icon |
3812 | - if ($obj->assignment==1) { |
|
3813 | - $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL); |
|
3814 | - } elseif ($obj->assignment==2) { |
|
3815 | - $ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL); |
|
3816 | - } elseif ($obj->assignment==0) { |
|
3817 | - $ShowAssignment=Display::return_icon('px_transparent.gif'); |
|
3812 | + if ($obj->assignment == 1) { |
|
3813 | + $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'), '', ICON_SIZE_SMALL); |
|
3814 | + } elseif ($obj->assignment == 2) { |
|
3815 | + $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL); |
|
3816 | + } elseif ($obj->assignment == 0) { |
|
3817 | + $ShowAssignment = Display::return_icon('px_transparent.gif'); |
|
3818 | 3818 | } |
3819 | 3819 | |
3820 | 3820 | // Get icon task |
3821 | 3821 | if (!empty($obj->task)) { |
3822 | - $icon_task=Display::return_icon('wiki_task.png', get_lang('StandardTask'),'',ICON_SIZE_SMALL); |
|
3822 | + $icon_task = Display::return_icon('wiki_task.png', get_lang('StandardTask'), '', ICON_SIZE_SMALL); |
|
3823 | 3823 | } else { |
3824 | - $icon_task=Display::return_icon('px_transparent.gif'); |
|
3824 | + $icon_task = Display::return_icon('px_transparent.gif'); |
|
3825 | 3825 | } |
3826 | 3826 | |
3827 | 3827 | $row = array(); |
@@ -3829,7 +3829,7 @@ discard block |
||
3829 | 3829 | $row[] = $ShowAssignment.$icon_task; |
3830 | 3830 | $row[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=showpage&title='.api_htmlentities(urlencode($obj->reflink)).'&view='.$obj->id.'&session_id='.api_get_session_id().'&group_id='.api_get_group_id().'">'. |
3831 | 3831 | api_htmlentities($obj->title).'</a>'; |
3832 | - $row[] = $obj->version>1 ? get_lang('EditedBy') : get_lang('AddedBy'); |
|
3832 | + $row[] = $obj->version > 1 ? get_lang('EditedBy') : get_lang('AddedBy'); |
|
3833 | 3833 | if ($userinfo !== false) { |
3834 | 3834 | $row[] = UserManager::getUserProfileLink($userinfo); |
3835 | 3835 | } else { |
@@ -3838,7 +3838,7 @@ discard block |
||
3838 | 3838 | $rows[] = $row; |
3839 | 3839 | } |
3840 | 3840 | |
3841 | - $table = new SortableTableFromArrayConfig($rows,0,10,'RecentPages_table','','','DESC'); |
|
3841 | + $table = new SortableTableFromArrayConfig($rows, 0, 10, 'RecentPages_table', '', '', 'DESC'); |
|
3842 | 3842 | $table->set_additional_parameters( |
3843 | 3843 | array( |
3844 | 3844 | 'cidReq' =>api_get_course_id(), |
@@ -3847,11 +3847,11 @@ discard block |
||
3847 | 3847 | 'group_id' => api_get_group_id() |
3848 | 3848 | ) |
3849 | 3849 | ); |
3850 | - $table->set_header(0,get_lang('Date'), true, array ('style' => 'width:200px;')); |
|
3851 | - $table->set_header(1,get_lang('Type'), true, array ('style' => 'width:30px;')); |
|
3852 | - $table->set_header(2,get_lang('Title'), true); |
|
3853 | - $table->set_header(3,get_lang('Actions'), true, array ('style' => 'width:80px;')); |
|
3854 | - $table->set_header(4,get_lang('Author'), true); |
|
3850 | + $table->set_header(0, get_lang('Date'), true, array('style' => 'width:200px;')); |
|
3851 | + $table->set_header(1, get_lang('Type'), true, array('style' => 'width:30px;')); |
|
3852 | + $table->set_header(2, get_lang('Title'), true); |
|
3853 | + $table->set_header(3, get_lang('Actions'), true, array('style' => 'width:80px;')); |
|
3854 | + $table->set_header(4, get_lang('Author'), true); |
|
3855 | 3855 | $table->display(); |
3856 | 3856 | } |
3857 | 3857 | } |
@@ -3883,17 +3883,17 @@ discard block |
||
3883 | 3883 | |
3884 | 3884 | //get type assignment icon |
3885 | 3885 | $ShowAssignment = ''; |
3886 | - if ($row['assignment']==1) { |
|
3887 | - $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL); |
|
3888 | - } elseif ($row['assignment']==2) { |
|
3889 | - $ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL); |
|
3890 | - } elseif ($row['assignment']==0) { |
|
3891 | - $ShowAssignment=Display::return_icon('px_transparent.gif'); |
|
3886 | + if ($row['assignment'] == 1) { |
|
3887 | + $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'), '', ICON_SIZE_SMALL); |
|
3888 | + } elseif ($row['assignment'] == 2) { |
|
3889 | + $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL); |
|
3890 | + } elseif ($row['assignment'] == 0) { |
|
3891 | + $ShowAssignment = Display::return_icon('px_transparent.gif'); |
|
3892 | 3892 | } |
3893 | 3893 | |
3894 | 3894 | //fix Title to reflink (link Main Page) |
3895 | - if ($page==get_lang('DefaultTitle')) { |
|
3896 | - $page='index'; |
|
3895 | + if ($page == get_lang('DefaultTitle')) { |
|
3896 | + $page = 'index'; |
|
3897 | 3897 | } |
3898 | 3898 | |
3899 | 3899 | echo '<div id="wikititle">'; |
@@ -3904,11 +3904,11 @@ discard block |
||
3904 | 3904 | //fix index to title Main page into linksto |
3905 | 3905 | |
3906 | 3906 | if ($page == 'index') { |
3907 | - $page = str_replace(' ','_',get_lang('DefaultTitle')); |
|
3907 | + $page = str_replace(' ', '_', get_lang('DefaultTitle')); |
|
3908 | 3908 | } |
3909 | 3909 | |
3910 | 3910 | //table |
3911 | - if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { |
|
3911 | + if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { |
|
3912 | 3912 | //only by professors if page is hidden |
3913 | 3913 | $sql = "SELECT * FROM ".$tbl_wiki." s1 |
3914 | 3914 | WHERE s1.c_id = $course_id AND linksto LIKE '%".Database::escape_string($page)."%' AND id=( |
@@ -3935,10 +3935,10 @@ discard block |
||
3935 | 3935 | //get time |
3936 | 3936 | $year = substr($obj->dtime, 0, 4); |
3937 | 3937 | $month = substr($obj->dtime, 5, 2); |
3938 | - $day = substr($obj->dtime, 8, 2); |
|
3939 | - $hours = substr($obj->dtime, 11,2); |
|
3940 | - $minutes = substr($obj->dtime, 14,2); |
|
3941 | - $seconds = substr($obj->dtime, 17,2); |
|
3938 | + $day = substr($obj->dtime, 8, 2); |
|
3939 | + $hours = substr($obj->dtime, 11, 2); |
|
3940 | + $minutes = substr($obj->dtime, 14, 2); |
|
3941 | + $seconds = substr($obj->dtime, 17, 2); |
|
3942 | 3942 | |
3943 | 3943 | //get type assignment icon |
3944 | 3944 | if ($obj->assignment == 1) { |
@@ -3950,7 +3950,7 @@ discard block |
||
3950 | 3950 | } |
3951 | 3951 | |
3952 | 3952 | $row = array(); |
3953 | - $row[] =$ShowAssignment; |
|
3953 | + $row[] = $ShowAssignment; |
|
3954 | 3954 | $row[] = '<a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=showpage&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'. |
3955 | 3955 | api_htmlentities($obj->title).'</a>'; |
3956 | 3956 | if ($userinfo !== false) { |
@@ -4057,13 +4057,13 @@ discard block |
||
4057 | 4057 | $userId = intval($userId); |
4058 | 4058 | $userinfo = api_get_user_info($userId); |
4059 | 4059 | if ($userinfo !== false) { |
4060 | - echo '<div class="actions">' . get_lang('UserContributions') . ': ' . UserManager::getUserProfileLink($userinfo) . |
|
4061 | - '<a href="' . api_get_self() . '?cidReq=' . $_course['code'] . '&action=usercontrib&user_id=' . $userId . |
|
4062 | - '&session_id=' . $this->session_id . '&group_id=' . $this->group_id . '">' . |
|
4060 | + echo '<div class="actions">'.get_lang('UserContributions').': '.UserManager::getUserProfileLink($userinfo). |
|
4061 | + '<a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=usercontrib&user_id='.$userId. |
|
4062 | + '&session_id='.$this->session_id.'&group_id='.$this->group_id.'">'. |
|
4063 | 4063 | '</a></div>'; |
4064 | 4064 | } |
4065 | 4065 | |
4066 | - if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { |
|
4066 | + if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { |
|
4067 | 4067 | //only by professors if page is hidden |
4068 | 4068 | $sql = 'SELECT * FROM '.$tbl_wiki.' |
4069 | 4069 | WHERE |
@@ -4088,19 +4088,19 @@ discard block |
||
4088 | 4088 | // Get time |
4089 | 4089 | $year = substr($obj->dtime, 0, 4); |
4090 | 4090 | $month = substr($obj->dtime, 5, 2); |
4091 | - $day = substr($obj->dtime, 8, 2); |
|
4092 | - $hours = substr($obj->dtime, 11,2); |
|
4093 | - $minutes = substr($obj->dtime, 14,2); |
|
4094 | - $seconds = substr($obj->dtime, 17,2); |
|
4091 | + $day = substr($obj->dtime, 8, 2); |
|
4092 | + $hours = substr($obj->dtime, 11, 2); |
|
4093 | + $minutes = substr($obj->dtime, 14, 2); |
|
4094 | + $seconds = substr($obj->dtime, 17, 2); |
|
4095 | 4095 | |
4096 | 4096 | //get type assignment icon |
4097 | 4097 | $ShowAssignment = ''; |
4098 | - if ($obj->assignment==1) { |
|
4099 | - $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'),'',ICON_SIZE_SMALL); |
|
4100 | - } elseif ($obj->assignment==2) { |
|
4101 | - $ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL); |
|
4102 | - } elseif ($obj->assignment==0) { |
|
4103 | - $ShowAssignment= Display::return_icon('px_transparent.gif'); |
|
4098 | + if ($obj->assignment == 1) { |
|
4099 | + $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'), '', ICON_SIZE_SMALL); |
|
4100 | + } elseif ($obj->assignment == 2) { |
|
4101 | + $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL); |
|
4102 | + } elseif ($obj->assignment == 0) { |
|
4103 | + $ShowAssignment = Display::return_icon('px_transparent.gif'); |
|
4104 | 4104 | } |
4105 | 4105 | |
4106 | 4106 | $row = array(); |
@@ -4116,7 +4116,7 @@ discard block |
||
4116 | 4116 | |
4117 | 4117 | } |
4118 | 4118 | |
4119 | - $table = new SortableTableFromArrayConfig($rows,2,10,'UsersContributions_table','','','ASC'); |
|
4119 | + $table = new SortableTableFromArrayConfig($rows, 2, 10, 'UsersContributions_table', '', '', 'ASC'); |
|
4120 | 4120 | $table->set_additional_parameters( |
4121 | 4121 | array( |
4122 | 4122 | 'cidReq' => Security::remove_XSS($_GET['cidReq']), |
@@ -4126,13 +4126,13 @@ discard block |
||
4126 | 4126 | 'group_id' => intval($_GET['group_id']), |
4127 | 4127 | ) |
4128 | 4128 | ); |
4129 | - $table->set_header(0,get_lang('Date'), true, array ('style' => 'width:200px;')); |
|
4130 | - $table->set_header(1,get_lang('Type'), true, array ('style' => 'width:30px;')); |
|
4131 | - $table->set_header(2,get_lang('Title'), true, array ('style' => 'width:200px;')); |
|
4132 | - $table->set_header(3,get_lang('Version'), true, array ('style' => 'width:30px;')); |
|
4133 | - $table->set_header(4,get_lang('Comment'), true, array ('style' => 'width:200px;')); |
|
4134 | - $table->set_header(5,get_lang('Progress'), true, array ('style' => 'width:30px;')); |
|
4135 | - $table->set_header(6,get_lang('Rating'), true, array ('style' => 'width:30px;')); |
|
4129 | + $table->set_header(0, get_lang('Date'), true, array('style' => 'width:200px;')); |
|
4130 | + $table->set_header(1, get_lang('Type'), true, array('style' => 'width:30px;')); |
|
4131 | + $table->set_header(2, get_lang('Title'), true, array('style' => 'width:200px;')); |
|
4132 | + $table->set_header(3, get_lang('Version'), true, array('style' => 'width:30px;')); |
|
4133 | + $table->set_header(4, get_lang('Comment'), true, array('style' => 'width:200px;')); |
|
4134 | + $table->set_header(5, get_lang('Progress'), true, array('style' => 'width:30px;')); |
|
4135 | + $table->set_header(6, get_lang('Rating'), true, array('style' => 'width:30px;')); |
|
4136 | 4136 | $table->display(); |
4137 | 4137 | } |
4138 | 4138 | } |
@@ -4150,7 +4150,7 @@ discard block |
||
4150 | 4150 | |
4151 | 4151 | echo '<div class="actions">'.get_lang('MostChangedPages').'</div>'; |
4152 | 4152 | |
4153 | - if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { //only by professors if page is hidden |
|
4153 | + if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { //only by professors if page is hidden |
|
4154 | 4154 | $sql = 'SELECT *, MAX(version) AS MAX FROM '.$tbl_wiki.' |
4155 | 4155 | WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.' |
4156 | 4156 | GROUP BY reflink';//TODO:check MAX and group by return last version |
@@ -4168,12 +4168,12 @@ discard block |
||
4168 | 4168 | while ($obj = Database::fetch_object($allpages)) { |
4169 | 4169 | //get type assignment icon |
4170 | 4170 | $ShowAssignment = ''; |
4171 | - if ($obj->assignment==1) { |
|
4172 | - $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL); |
|
4173 | - } elseif ($obj->assignment==2) { |
|
4174 | - $ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL); |
|
4175 | - } elseif ($obj->assignment==0) { |
|
4176 | - $ShowAssignment= Display::return_icon('px_transparent.gif'); |
|
4171 | + if ($obj->assignment == 1) { |
|
4172 | + $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'), '', ICON_SIZE_SMALL); |
|
4173 | + } elseif ($obj->assignment == 2) { |
|
4174 | + $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL); |
|
4175 | + } elseif ($obj->assignment == 0) { |
|
4176 | + $ShowAssignment = Display::return_icon('px_transparent.gif'); |
|
4177 | 4177 | } |
4178 | 4178 | |
4179 | 4179 | $row = array(); |
@@ -4201,9 +4201,9 @@ discard block |
||
4201 | 4201 | 'group_id' => intval($_GET['group_id']), |
4202 | 4202 | ) |
4203 | 4203 | ); |
4204 | - $table->set_header(0,get_lang('Type'), true, array ('style' => 'width:30px;')); |
|
4205 | - $table->set_header(1,get_lang('Title'), true); |
|
4206 | - $table->set_header(2,get_lang('Changes'), true); |
|
4204 | + $table->set_header(0, get_lang('Type'), true, array('style' => 'width:30px;')); |
|
4205 | + $table->set_header(1, get_lang('Title'), true); |
|
4206 | + $table->set_header(2, get_lang('Changes'), true); |
|
4207 | 4207 | $table->display(); |
4208 | 4208 | } |
4209 | 4209 | } |
@@ -4228,7 +4228,7 @@ discard block |
||
4228 | 4228 | /* Only teachers and platform admin can edit the index page. |
4229 | 4229 | Only teachers and platform admin can edit an assignment teacher*/ |
4230 | 4230 | if (($current_row['reflink'] == 'index' || $current_row['reflink'] == '' || $current_row['assignment'] == 1) && |
4231 | - (!api_is_allowed_to_edit(false,true) && $this->group_id == 0) |
|
4231 | + (!api_is_allowed_to_edit(false, true) && $this->group_id == 0) |
|
4232 | 4232 | ) { |
4233 | 4233 | Display::addFlash( |
4234 | 4234 | Display::display_normal_message(get_lang('OnlyEditPagesCourseManager'), false, true) |
@@ -4239,7 +4239,7 @@ discard block |
||
4239 | 4239 | if ($current_row['group_id'] != 0) { |
4240 | 4240 | $groupInfo = GroupManager::get_group_properties($this->group_id); |
4241 | 4241 | //Only teacher, platform admin and group members can edit a wiki group |
4242 | - if (api_is_allowed_to_edit(false,true) || |
|
4242 | + if (api_is_allowed_to_edit(false, true) || |
|
4243 | 4243 | api_is_platform_admin() || |
4244 | 4244 | GroupManager :: is_user_in_group($userId, $groupInfo['iid']) || |
4245 | 4245 | api_is_allowed_in_course() |
@@ -4258,9 +4258,9 @@ discard block |
||
4258 | 4258 | //$icon_assignment = null; |
4259 | 4259 | if ($current_row['assignment'] == 1) { |
4260 | 4260 | Display::addFlash(Display::display_normal_message(get_lang('EditAssignmentWarning'), false, true)); |
4261 | - } elseif($current_row['assignment']==2) { |
|
4262 | - if (($userId == $current_row['user_id'])==false) { |
|
4263 | - if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { |
|
4261 | + } elseif ($current_row['assignment'] == 2) { |
|
4262 | + if (($userId == $current_row['user_id']) == false) { |
|
4263 | + if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { |
|
4264 | 4264 | $PassEdit = true; |
4265 | 4265 | } else { |
4266 | 4266 | Display::addFlash(Display::display_warning_message(get_lang('LockByTeacher'), false, true)); |
@@ -4274,11 +4274,11 @@ discard block |
||
4274 | 4274 | //show editor if edit is allowed |
4275 | 4275 | if ($PassEdit) { |
4276 | 4276 | if ($current_row['editlock'] == 1 && |
4277 | - (api_is_allowed_to_edit(false,true)==false || api_is_platform_admin()==false) |
|
4277 | + (api_is_allowed_to_edit(false, true) == false || api_is_platform_admin() == false) |
|
4278 | 4278 | ) { |
4279 | 4279 | Display::addFlash(Display::display_normal_message(get_lang('PageLockedExtra'), false, true)); |
4280 | 4280 | } else { |
4281 | - if ($last_row['is_editing']!=0 && $last_row['is_editing'] != $userId) { |
|
4281 | + if ($last_row['is_editing'] != 0 && $last_row['is_editing'] != $userId) { |
|
4282 | 4282 | // Checking for concurrent users |
4283 | 4283 | $timestamp_edit = strtotime($last_row['time_edit']); |
4284 | 4284 | $time_editing = time() - $timestamp_edit; |
@@ -4287,7 +4287,7 @@ discard block |
||
4287 | 4287 | $userinfo = api_get_user_info($last_row['is_editing']); |
4288 | 4288 | $is_being_edited = get_lang('ThisPageisBeginEditedBy').' <a href='.$userinfo['profile_url'].'>'. |
4289 | 4289 | Display::tag('span', $userinfo['complete_name_with_username']). |
4290 | - get_lang('ThisPageisBeginEditedTryLater').' '.date( "i",$rest_time).' '.get_lang('MinMinutes'); |
|
4290 | + get_lang('ThisPageisBeginEditedTryLater').' '.date("i", $rest_time).' '.get_lang('MinMinutes'); |
|
4291 | 4291 | Display::addFlash(Display::display_normal_message($is_being_edited, false, true)); |
4292 | 4292 | } else { |
4293 | 4293 | Display::addFlash(Display::display_confirmation_message( |
@@ -4395,9 +4395,9 @@ discard block |
||
4395 | 4395 | GROUP BY reflink |
4396 | 4396 | ORDER BY reflink ASC'; |
4397 | 4397 | $allpages = Database::query($sql); |
4398 | - while ($row=Database::fetch_array($allpages)) { |
|
4399 | - if ($row['reflink']=='index') { |
|
4400 | - $row['reflink']=str_replace(' ', '_', get_lang('DefaultTitle')); |
|
4398 | + while ($row = Database::fetch_array($allpages)) { |
|
4399 | + if ($row['reflink'] == 'index') { |
|
4400 | + $row['reflink'] = str_replace(' ', '_', get_lang('DefaultTitle')); |
|
4401 | 4401 | } |
4402 | 4402 | $pages[] = $row['reflink']; |
4403 | 4403 | } |
@@ -4415,16 +4415,16 @@ discard block |
||
4415 | 4415 | |
4416 | 4416 | $allpages = Database::query($sql); |
4417 | 4417 | |
4418 | - while ($row=Database::fetch_array($allpages)) { |
|
4418 | + while ($row = Database::fetch_array($allpages)) { |
|
4419 | 4419 | //remove self reference |
4420 | - $row['linksto']= str_replace($row["reflink"], " ", trim($row["linksto"])); |
|
4420 | + $row['linksto'] = str_replace($row["reflink"], " ", trim($row["linksto"])); |
|
4421 | 4421 | $refs = explode(" ", trim($row["linksto"])); |
4422 | 4422 | |
4423 | 4423 | // Find linksto into reflink. If found ->page is linked |
4424 | 4424 | foreach ($refs as $v) { |
4425 | 4425 | if (in_array($v, $pages)) { |
4426 | - if (trim($v)!="") { |
|
4427 | - $linked[]=$v; |
|
4426 | + if (trim($v) != "") { |
|
4427 | + $linked[] = $v; |
|
4428 | 4428 | } |
4429 | 4429 | } |
4430 | 4430 | } |
@@ -4436,12 +4436,12 @@ discard block |
||
4436 | 4436 | $rows = array(); |
4437 | 4437 | foreach ($linked as $linked_show) { |
4438 | 4438 | $row = array(); |
4439 | - $row[] = '<a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=showpage&title='.api_htmlentities(urlencode(str_replace('_',' ',$linked_show))).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'. |
|
4440 | - str_replace('_',' ',$linked_show).'</a>'; |
|
4439 | + $row[] = '<a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=showpage&title='.api_htmlentities(urlencode(str_replace('_', ' ', $linked_show))).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'. |
|
4440 | + str_replace('_', ' ', $linked_show).'</a>'; |
|
4441 | 4441 | $rows[] = $row; |
4442 | 4442 | } |
4443 | 4443 | |
4444 | - $table = new SortableTableFromArrayConfig($rows,0,10,'LinkedPages_table','','','DESC'); |
|
4444 | + $table = new SortableTableFromArrayConfig($rows, 0, 10, 'LinkedPages_table', '', '', 'DESC'); |
|
4445 | 4445 | $table->set_additional_parameters( |
4446 | 4446 | array( |
4447 | 4447 | 'cidReq' => Security::remove_XSS($_GET['cidReq']), |
@@ -4450,7 +4450,7 @@ discard block |
||
4450 | 4450 | 'group_id' => intval($_GET['group_id']), |
4451 | 4451 | ) |
4452 | 4452 | ); |
4453 | - $table->set_header(0,get_lang('Title'), true); |
|
4453 | + $table->set_header(0, get_lang('Title'), true); |
|
4454 | 4454 | $table->display(); |
4455 | 4455 | } |
4456 | 4456 | |
@@ -4475,8 +4475,8 @@ discard block |
||
4475 | 4475 | WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.' |
4476 | 4476 | GROUP BY reflink |
4477 | 4477 | ORDER BY reflink ASC'; |
4478 | - $allpages=Database::query($sql); |
|
4479 | - while ($row=Database::fetch_array($allpages)) { |
|
4478 | + $allpages = Database::query($sql); |
|
4479 | + while ($row = Database::fetch_array($allpages)) { |
|
4480 | 4480 | $pages[] = $row['reflink']; |
4481 | 4481 | } |
4482 | 4482 | |
@@ -4491,14 +4491,14 @@ discard block |
||
4491 | 4491 | )'; |
4492 | 4492 | $allpages = Database::query($sql); |
4493 | 4493 | $array_refs_linked = array(); |
4494 | - while ($row=Database::fetch_array($allpages)) { |
|
4495 | - $row['linksto']= str_replace($row["reflink"], " ", trim($row["linksto"])); //remove self reference |
|
4494 | + while ($row = Database::fetch_array($allpages)) { |
|
4495 | + $row['linksto'] = str_replace($row["reflink"], " ", trim($row["linksto"])); //remove self reference |
|
4496 | 4496 | $refs = explode(" ", trim($row["linksto"])); |
4497 | - foreach ($refs as $ref_linked){ |
|
4498 | - if ($ref_linked==str_replace(' ','_',get_lang('DefaultTitle'))) { |
|
4499 | - $ref_linked='index'; |
|
4497 | + foreach ($refs as $ref_linked) { |
|
4498 | + if ($ref_linked == str_replace(' ', '_', get_lang('DefaultTitle'))) { |
|
4499 | + $ref_linked = 'index'; |
|
4500 | 4500 | } |
4501 | - $array_refs_linked[]= $ref_linked; |
|
4501 | + $array_refs_linked[] = $ref_linked; |
|
4502 | 4502 | } |
4503 | 4503 | } |
4504 | 4504 | |
@@ -4520,20 +4520,20 @@ discard block |
||
4520 | 4520 | '.$groupfilter.$condition_session.' AND |
4521 | 4521 | reflink="'.Database::escape_string($orphaned_show).'" |
4522 | 4522 | GROUP BY reflink'; |
4523 | - $allpages=Database::query($sql); |
|
4524 | - while ($row=Database::fetch_array($allpages)) { |
|
4525 | - $orphaned_title=$row['title']; |
|
4526 | - $orphaned_visibility=$row['visibility']; |
|
4527 | - if ($row['assignment']==1) { |
|
4528 | - $ShowAssignment=Display::return_icon('wiki_assignment.png','','',ICON_SIZE_SMALL); |
|
4529 | - } elseif ($row['assignment']==2) { |
|
4530 | - $ShowAssignment=Display::return_icon('wiki_work.png','','',ICON_SIZE_SMALL); |
|
4531 | - } elseif ($row['assignment']==0) { |
|
4532 | - $ShowAssignment= Display::return_icon('px_transparent.gif'); |
|
4523 | + $allpages = Database::query($sql); |
|
4524 | + while ($row = Database::fetch_array($allpages)) { |
|
4525 | + $orphaned_title = $row['title']; |
|
4526 | + $orphaned_visibility = $row['visibility']; |
|
4527 | + if ($row['assignment'] == 1) { |
|
4528 | + $ShowAssignment = Display::return_icon('wiki_assignment.png', '', '', ICON_SIZE_SMALL); |
|
4529 | + } elseif ($row['assignment'] == 2) { |
|
4530 | + $ShowAssignment = Display::return_icon('wiki_work.png', '', '', ICON_SIZE_SMALL); |
|
4531 | + } elseif ($row['assignment'] == 0) { |
|
4532 | + $ShowAssignment = Display::return_icon('px_transparent.gif'); |
|
4533 | 4533 | } |
4534 | 4534 | } |
4535 | 4535 | |
4536 | - if (!api_is_allowed_to_edit(false,true) || !api_is_platform_admin() && $orphaned_visibility==0){ |
|
4536 | + if (!api_is_allowed_to_edit(false, true) || !api_is_platform_admin() && $orphaned_visibility == 0) { |
|
4537 | 4537 | continue; |
4538 | 4538 | } |
4539 | 4539 | |
@@ -4545,7 +4545,7 @@ discard block |
||
4545 | 4545 | $rows[] = $row; |
4546 | 4546 | } |
4547 | 4547 | |
4548 | - $table = new SortableTableFromArrayConfig($rows,1, 10, 'OrphanedPages_table','','','DESC'); |
|
4548 | + $table = new SortableTableFromArrayConfig($rows, 1, 10, 'OrphanedPages_table', '', '', 'DESC'); |
|
4549 | 4549 | $table->set_additional_parameters( |
4550 | 4550 | array( |
4551 | 4551 | 'cidReq' => Security::remove_XSS($_GET['cidReq']), |
@@ -4554,8 +4554,8 @@ discard block |
||
4554 | 4554 | 'group_id' => intval($_GET['group_id']), |
4555 | 4555 | ) |
4556 | 4556 | ); |
4557 | - $table->set_header(0,get_lang('Type'), true, array ('style' => 'width:30px;')); |
|
4558 | - $table->set_header(1,get_lang('Title'), true); |
|
4557 | + $table->set_header(0, get_lang('Type'), true, array('style' => 'width:30px;')); |
|
4558 | + $table->set_header(1, get_lang('Title'), true); |
|
4559 | 4559 | $table->display(); |
4560 | 4560 | } |
4561 | 4561 | |
@@ -4577,11 +4577,11 @@ discard block |
||
4577 | 4577 | WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.' |
4578 | 4578 | GROUP BY reflink |
4579 | 4579 | ORDER BY reflink ASC'; |
4580 | - $allpages=Database::query($sql); |
|
4580 | + $allpages = Database::query($sql); |
|
4581 | 4581 | |
4582 | - while ($row=Database::fetch_array($allpages)) { |
|
4583 | - if ($row['reflink']=='index'){ |
|
4584 | - $row['reflink']=str_replace(' ','_',get_lang('DefaultTitle')); |
|
4582 | + while ($row = Database::fetch_array($allpages)) { |
|
4583 | + if ($row['reflink'] == 'index') { |
|
4584 | + $row['reflink'] = str_replace(' ', '_', get_lang('DefaultTitle')); |
|
4585 | 4585 | } |
4586 | 4586 | $pages[] = $row['reflink']; |
4587 | 4587 | } |
@@ -4595,31 +4595,31 @@ discard block |
||
4595 | 4595 | |
4596 | 4596 | $allpages = Database::query($sql); |
4597 | 4597 | |
4598 | - while ($row=Database::fetch_array($allpages)) { |
|
4598 | + while ($row = Database::fetch_array($allpages)) { |
|
4599 | 4599 | $refs = explode(" ", trim($row["linksto"])); |
4600 | 4600 | // Find linksto into reflink. If not found ->page is wanted |
4601 | 4601 | foreach ($refs as $v) { |
4602 | 4602 | |
4603 | 4603 | if (!in_array($v, $pages)) { |
4604 | - if (trim($v)!="") { |
|
4605 | - $wanted[]=$v; |
|
4604 | + if (trim($v) != "") { |
|
4605 | + $wanted[] = $v; |
|
4606 | 4606 | } |
4607 | 4607 | } |
4608 | 4608 | } |
4609 | 4609 | } |
4610 | 4610 | |
4611 | - $wanted = array_unique($wanted);//make a unique list |
|
4611 | + $wanted = array_unique($wanted); //make a unique list |
|
4612 | 4612 | |
4613 | 4613 | //show table |
4614 | 4614 | $rows = array(); |
4615 | 4615 | foreach ($wanted as $wanted_show) { |
4616 | 4616 | $row = array(); |
4617 | 4617 | $wanted_show = Security::remove_XSS($wanted_show); |
4618 | - $row[] = '<a href="'.api_get_path(WEB_PATH).'main/wiki/index.php?cidReq=&action=addnew&title='.str_replace('_',' ',$wanted_show).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'" class="new_wiki_link">'.str_replace('_',' ',$wanted_show).'</a>';//meter un remove xss en lugar de htmlentities |
|
4618 | + $row[] = '<a href="'.api_get_path(WEB_PATH).'main/wiki/index.php?cidReq=&action=addnew&title='.str_replace('_', ' ', $wanted_show).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'" class="new_wiki_link">'.str_replace('_', ' ', $wanted_show).'</a>'; //meter un remove xss en lugar de htmlentities |
|
4619 | 4619 | $rows[] = $row; |
4620 | 4620 | } |
4621 | 4621 | |
4622 | - $table = new SortableTableFromArrayConfig($rows,0,10,'WantedPages_table','','','DESC'); |
|
4622 | + $table = new SortableTableFromArrayConfig($rows, 0, 10, 'WantedPages_table', '', '', 'DESC'); |
|
4623 | 4623 | $table->set_additional_parameters( |
4624 | 4624 | array( |
4625 | 4625 | 'cidReq' => Security::remove_XSS($_GET['cidReq']), |
@@ -4628,7 +4628,7 @@ discard block |
||
4628 | 4628 | 'group_id' => intval($_GET['group_id']), |
4629 | 4629 | ) |
4630 | 4630 | ); |
4631 | - $table->set_header(0,get_lang('Title'), true); |
|
4631 | + $table->set_header(0, get_lang('Title'), true); |
|
4632 | 4632 | $table->display(); |
4633 | 4633 | } |
4634 | 4634 | |
@@ -4645,7 +4645,7 @@ discard block |
||
4645 | 4645 | |
4646 | 4646 | echo '<div class="actions">'.get_lang('MostVisitedPages').'</div>'; |
4647 | 4647 | |
4648 | - if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { //only by professors if page is hidden |
|
4648 | + if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { //only by professors if page is hidden |
|
4649 | 4649 | $sql = 'SELECT *, SUM(hits) AS tsum FROM '.$tbl_wiki.' |
4650 | 4650 | WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.' |
4651 | 4651 | GROUP BY reflink'; |
@@ -4666,11 +4666,11 @@ discard block |
||
4666 | 4666 | while ($obj = Database::fetch_object($allpages)) { |
4667 | 4667 | //get type assignment icon |
4668 | 4668 | $ShowAssignment = ''; |
4669 | - if ($obj->assignment==1) { |
|
4670 | - $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL); |
|
4671 | - } elseif ($obj->assignment==2) { |
|
4672 | - $ShowAssignment=$ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL); |
|
4673 | - } elseif ($obj->assignment==0) { |
|
4669 | + if ($obj->assignment == 1) { |
|
4670 | + $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'), '', ICON_SIZE_SMALL); |
|
4671 | + } elseif ($obj->assignment == 2) { |
|
4672 | + $ShowAssignment = $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL); |
|
4673 | + } elseif ($obj->assignment == 0) { |
|
4674 | 4674 | $ShowAssignment = Display::return_icon('px_transparent.gif'); |
4675 | 4675 | } |
4676 | 4676 | |
@@ -4699,7 +4699,7 @@ discard block |
||
4699 | 4699 | 'group_id' => intval($_GET['group_id']), |
4700 | 4700 | ) |
4701 | 4701 | ); |
4702 | - $table->set_header(0,get_lang('Type'), true, array ('style' => 'width:30px;')); |
|
4702 | + $table->set_header(0, get_lang('Type'), true, array('style' => 'width:30px;')); |
|
4703 | 4703 | $table->set_header(1, get_lang('Title'), true); |
4704 | 4704 | $table->set_header(2, get_lang('Visits'), true); |
4705 | 4705 | $table->display(); |
@@ -4724,8 +4724,8 @@ discard block |
||
4724 | 4724 | |
4725 | 4725 | if (api_is_allowed_to_session_edit(false, true) && api_is_allowed_to_edit()) { |
4726 | 4726 | // menu add page |
4727 | - $actionsLeft .= '<a href="index.php?cidReq=' . $_course['id'] . '&action=addnew&session_id=' . $session_id . '&group_id=' . $groupId . '"' . self::is_active_navigation_tab('addnew').'>' |
|
4728 | - . Display::return_icon('add.png', get_lang('AddNew'), '', ICON_SIZE_MEDIUM) . '</a>'; |
|
4727 | + $actionsLeft .= '<a href="index.php?cidReq='.$_course['id'].'&action=addnew&session_id='.$session_id.'&group_id='.$groupId.'"'.self::is_active_navigation_tab('addnew').'>' |
|
4728 | + . Display::return_icon('add.png', get_lang('AddNew'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
4729 | 4729 | } |
4730 | 4730 | |
4731 | 4731 | $lock_unlock_addnew = null; |
@@ -4733,12 +4733,12 @@ discard block |
||
4733 | 4733 | |
4734 | 4734 | if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { |
4735 | 4735 | // page action: enable or disable the adding of new pages |
4736 | - if (self::check_addnewpagelock()==0) { |
|
4736 | + if (self::check_addnewpagelock() == 0) { |
|
4737 | 4737 | $protect_addnewpage = Display::return_icon('off.png', get_lang('AddOptionProtected')); |
4738 | - $lock_unlock_addnew ='unlockaddnew'; |
|
4738 | + $lock_unlock_addnew = 'unlockaddnew'; |
|
4739 | 4739 | } else { |
4740 | 4740 | $protect_addnewpage = Display::return_icon('on.png', get_lang('AddOptionUnprotected')); |
4741 | - $lock_unlock_addnew ='lockaddnew'; |
|
4741 | + $lock_unlock_addnew = 'lockaddnew'; |
|
4742 | 4742 | } |
4743 | 4743 | } |
4744 | 4744 | |
@@ -4774,7 +4774,7 @@ discard block |
||
4774 | 4774 | return; |
4775 | 4775 | } |
4776 | 4776 | |
4777 | - if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { |
|
4777 | + if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { |
|
4778 | 4778 | Display::addFlash('<div id="wikititle">'.get_lang('DeletePageHistory').'</div>'); |
4779 | 4779 | |
4780 | 4780 | if ($page == "index") { |
@@ -4816,7 +4816,7 @@ discard block |
||
4816 | 4816 | $userId = api_get_user_id(); |
4817 | 4817 | |
4818 | 4818 | if (api_get_session_id() != 0 && |
4819 | - api_is_allowed_to_session_edit(false,true) == false |
|
4819 | + api_is_allowed_to_session_edit(false, true) == false |
|
4820 | 4820 | ) { |
4821 | 4821 | api_not_allowed(); |
4822 | 4822 | } |
@@ -4839,12 +4839,12 @@ discard block |
||
4839 | 4839 | Display::display_error_message(get_lang('MustSelectPage'), false, true) |
4840 | 4840 | ); |
4841 | 4841 | return; |
4842 | - } elseif ($row['content']=='' && $row['title']=='' && $page=='index') { |
|
4842 | + } elseif ($row['content'] == '' && $row['title'] == '' && $page == 'index') { |
|
4843 | 4843 | |
4844 | 4844 | // Table structure for better export to pdf |
4845 | 4845 | $default_table_for_content_Start = '<table align="center" border="0"><tr><td align="center">'; |
4846 | 4846 | $default_table_for_content_End = '</td></tr></table>'; |
4847 | - $content = $default_table_for_content_Start.sprintf(get_lang('DefaultContent'),api_get_path(WEB_IMG_PATH)).$default_table_for_content_End; |
|
4847 | + $content = $default_table_for_content_Start.sprintf(get_lang('DefaultContent'), api_get_path(WEB_IMG_PATH)).$default_table_for_content_End; |
|
4848 | 4848 | $title = get_lang('DefaultTitle'); |
4849 | 4849 | $page_id = 0; |
4850 | 4850 | } else { |
@@ -4871,7 +4871,7 @@ discard block |
||
4871 | 4871 | if (!empty($groupId)) { |
4872 | 4872 | $groupInfo = GroupManager::get_group_properties($groupId); |
4873 | 4873 | //Only teacher, platform admin and group members can edit a wiki group |
4874 | - if (api_is_allowed_to_edit(false,true) || |
|
4874 | + if (api_is_allowed_to_edit(false, true) || |
|
4875 | 4875 | api_is_platform_admin() || |
4876 | 4876 | GroupManager :: is_user_in_group($userId, $groupInfo['iid']) |
4877 | 4877 | ) { |
@@ -4884,7 +4884,7 @@ discard block |
||
4884 | 4884 | ); |
4885 | 4885 | } |
4886 | 4886 | } else { |
4887 | - $PassEdit=true; |
|
4887 | + $PassEdit = true; |
|
4888 | 4888 | } |
4889 | 4889 | |
4890 | 4890 | $icon_assignment = null; |
@@ -4894,10 +4894,10 @@ discard block |
||
4894 | 4894 | Display::return_message(get_lang('EditAssignmentWarning')) |
4895 | 4895 | ); |
4896 | 4896 | |
4897 | - $icon_assignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'),'',ICON_SIZE_SMALL); |
|
4897 | + $icon_assignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'), '', ICON_SIZE_SMALL); |
|
4898 | 4898 | } elseif ($row['assignment'] == 2) { |
4899 | - $icon_assignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWorkExtra'),'',ICON_SIZE_SMALL); |
|
4900 | - if (($userId == $row['user_id'])==false) { |
|
4899 | + $icon_assignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWorkExtra'), '', ICON_SIZE_SMALL); |
|
4900 | + if (($userId == $row['user_id']) == false) { |
|
4901 | 4901 | if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { |
4902 | 4902 | $PassEdit = true; |
4903 | 4903 | } else { |
@@ -4917,7 +4917,7 @@ discard block |
||
4917 | 4917 | if ($PassEdit) { |
4918 | 4918 | //show editor if edit is allowed <<<<< |
4919 | 4919 | if ($row['editlock'] == 1 && |
4920 | - (api_is_allowed_to_edit(false, true) == false || api_is_platform_admin()==false) |
|
4920 | + (api_is_allowed_to_edit(false, true) == false || api_is_platform_admin() == false) |
|
4921 | 4921 | ) { |
4922 | 4922 | Display::addFlash( |
4923 | 4923 | Display::return_message( |
@@ -4927,7 +4927,7 @@ discard block |
||
4927 | 4927 | } else { |
4928 | 4928 | // Check tasks |
4929 | 4929 | |
4930 | - if (!empty($row['startdate_assig']) && time() < api_strtotime($row['startdate_assig']) |
|
4930 | + if (!empty($row['startdate_assig']) && time() < api_strtotime($row['startdate_assig']) |
|
4931 | 4931 | ) { |
4932 | 4932 | $message = get_lang('TheTaskDoesNotBeginUntil').': '.api_get_local_time($row['startdate_assig']); |
4933 | 4933 | |
@@ -4945,7 +4945,7 @@ discard block |
||
4945 | 4945 | |
4946 | 4946 | if (!empty($row['enddate_assig']) && |
4947 | 4947 | time() > strtotime($row['enddate_assig']) && |
4948 | - $row['delayedsubmit']==0 |
|
4948 | + $row['delayedsubmit'] == 0 |
|
4949 | 4949 | ) { |
4950 | 4950 | $message = get_lang('TheDeadlineHasBeenCompleted').': '.api_get_local_time($row['enddate_assig']); |
4951 | 4951 | Display::addFlash( |
@@ -4954,20 +4954,20 @@ discard block |
||
4954 | 4954 | 'warning' |
4955 | 4955 | ) |
4956 | 4956 | ); |
4957 | - if (!api_is_allowed_to_edit(false,true)) { |
|
4957 | + if (!api_is_allowed_to_edit(false, true)) { |
|
4958 | 4958 | $this->redirectHome(); |
4959 | 4959 | } |
4960 | 4960 | } |
4961 | 4961 | |
4962 | - if (!empty($row['max_version']) && $row['version']>=$row['max_version']) { |
|
4963 | - $message=get_lang('HasReachedMaxiNumVersions'); |
|
4962 | + if (!empty($row['max_version']) && $row['version'] >= $row['max_version']) { |
|
4963 | + $message = get_lang('HasReachedMaxiNumVersions'); |
|
4964 | 4964 | Display::addFlash( |
4965 | 4965 | Display::return_message( |
4966 | 4966 | $message, |
4967 | 4967 | 'warning' |
4968 | 4968 | ) |
4969 | 4969 | ); |
4970 | - if (!api_is_allowed_to_edit(false,true)) { |
|
4970 | + if (!api_is_allowed_to_edit(false, true)) { |
|
4971 | 4971 | $this->redirectHome(); |
4972 | 4972 | } |
4973 | 4973 | } |
@@ -4980,7 +4980,7 @@ discard block |
||
4980 | 4980 | 'warning' |
4981 | 4981 | ) |
4982 | 4982 | ); |
4983 | - if (!api_is_allowed_to_edit(false,true)) { |
|
4983 | + if (!api_is_allowed_to_edit(false, true)) { |
|
4984 | 4984 | $this->redirectHome(); |
4985 | 4985 | } |
4986 | 4986 | } |
@@ -4988,7 +4988,7 @@ discard block |
||
4988 | 4988 | if (!empty($row['task'])) { |
4989 | 4989 | //previous change 0 by text |
4990 | 4990 | if (!empty($row['startdate_assig'])) { |
4991 | - $message_task_startdate =get_lang('No'); |
|
4991 | + $message_task_startdate = get_lang('No'); |
|
4992 | 4992 | } else { |
4993 | 4993 | $message_task_startdate = api_get_local_time($row['startdate_assig']); |
4994 | 4994 | } |
@@ -4999,31 +4999,31 @@ discard block |
||
4999 | 4999 | $message_task_enddate = api_get_local_time($row['enddate_assig']); |
5000 | 5000 | } |
5001 | 5001 | |
5002 | - if ($row['delayedsubmit']==0) { |
|
5003 | - $message_task_delayedsubmit=get_lang('No'); |
|
5002 | + if ($row['delayedsubmit'] == 0) { |
|
5003 | + $message_task_delayedsubmit = get_lang('No'); |
|
5004 | 5004 | } else { |
5005 | - $message_task_delayedsubmit=get_lang('Yes'); |
|
5005 | + $message_task_delayedsubmit = get_lang('Yes'); |
|
5006 | 5006 | } |
5007 | 5007 | |
5008 | - if ($row['max_version']==0) { |
|
5009 | - $message_task_max_version=get_lang('No'); |
|
5008 | + if ($row['max_version'] == 0) { |
|
5009 | + $message_task_max_version = get_lang('No'); |
|
5010 | 5010 | } else { |
5011 | - $message_task_max_version=$row['max_version']; |
|
5011 | + $message_task_max_version = $row['max_version']; |
|
5012 | 5012 | } |
5013 | 5013 | |
5014 | - if ($row['max_text']==0) { |
|
5015 | - $message_task_max_text=get_lang('No'); |
|
5014 | + if ($row['max_text'] == 0) { |
|
5015 | + $message_task_max_text = get_lang('No'); |
|
5016 | 5016 | } else { |
5017 | - $message_task_max_text=$row['max_text']; |
|
5017 | + $message_task_max_text = $row['max_text']; |
|
5018 | 5018 | } |
5019 | 5019 | |
5020 | 5020 | // Comp message |
5021 | - $message_task='<b>'.get_lang('DescriptionOfTheTask').'</b><p>'.$row['task'].'</p><hr>'; |
|
5022 | - $message_task.='<p>'.get_lang('StartDate').': '.$message_task_startdate.'</p>'; |
|
5023 | - $message_task.='<p>'.get_lang('EndDate').': '.$message_task_enddate; |
|
5024 | - $message_task.=' ('.get_lang('AllowLaterSends').') '.$message_task_delayedsubmit.'</p>'; |
|
5025 | - $message_task.='<p>'.get_lang('OtherSettings').': '.get_lang('NMaxVersion').': '.$message_task_max_version; |
|
5026 | - $message_task.=' '.get_lang('NMaxWords').': '.$message_task_max_text; |
|
5021 | + $message_task = '<b>'.get_lang('DescriptionOfTheTask').'</b><p>'.$row['task'].'</p><hr>'; |
|
5022 | + $message_task .= '<p>'.get_lang('StartDate').': '.$message_task_startdate.'</p>'; |
|
5023 | + $message_task .= '<p>'.get_lang('EndDate').': '.$message_task_enddate; |
|
5024 | + $message_task .= ' ('.get_lang('AllowLaterSends').') '.$message_task_delayedsubmit.'</p>'; |
|
5025 | + $message_task .= '<p>'.get_lang('OtherSettings').': '.get_lang('NMaxVersion').': '.$message_task_max_version; |
|
5026 | + $message_task .= ' '.get_lang('NMaxWords').': '.$message_task_max_text; |
|
5027 | 5027 | // Display message |
5028 | 5028 | Display::addFlash( |
5029 | 5029 | Display::return_message( |
@@ -5034,11 +5034,11 @@ discard block |
||
5034 | 5034 | |
5035 | 5035 | $feedback_message = ''; |
5036 | 5036 | if ($row['progress'] == $row['fprogress1'] && !empty($row['fprogress1'])) { |
5037 | - $feedback_message='<b>'.get_lang('Feedback').'</b><p>'.api_htmlentities($row['feedback1']).'</p>'; |
|
5037 | + $feedback_message = '<b>'.get_lang('Feedback').'</b><p>'.api_htmlentities($row['feedback1']).'</p>'; |
|
5038 | 5038 | } elseif ($row['progress'] == $row['fprogress2'] && !empty($row['fprogress2'])) { |
5039 | - $feedback_message='<b>'.get_lang('Feedback').'</b><p>'.api_htmlentities($row['feedback2']).'</p>'; |
|
5039 | + $feedback_message = '<b>'.get_lang('Feedback').'</b><p>'.api_htmlentities($row['feedback2']).'</p>'; |
|
5040 | 5040 | } elseif ($row['progress'] == $row['fprogress3'] && !empty($row['fprogress3'])) { |
5041 | - $feedback_message='<b>'.get_lang('Feedback').'</b><p>'.api_htmlentities($row['feedback3']).'</p>'; |
|
5041 | + $feedback_message = '<b>'.get_lang('Feedback').'</b><p>'.api_htmlentities($row['feedback3']).'</p>'; |
|
5042 | 5042 | } |
5043 | 5043 | |
5044 | 5044 | if (!empty($feedback_message)) { |
@@ -5063,15 +5063,15 @@ discard block |
||
5063 | 5063 | WHERE c_id = '.$course_id.' AND id="'.$row['id'].'"'; |
5064 | 5064 | Database::query($sql); |
5065 | 5065 | } elseif ($row['is_editing'] != $userId) { |
5066 | - $timestamp_edit=strtotime($row['time_edit']); |
|
5066 | + $timestamp_edit = strtotime($row['time_edit']); |
|
5067 | 5067 | $time_editing = time() - $timestamp_edit; |
5068 | 5068 | $max_edit_time = 1200; // 20 minutes |
5069 | 5069 | $rest_time = $max_edit_time - $time_editing; |
5070 | 5070 | |
5071 | 5071 | $userinfo = api_get_user_info($row['is_editing']); |
5072 | 5072 | if ($userinfo !== false) { |
5073 | - $is_being_edited = get_lang('ThisPageisBeginEditedBy') . ' ' . UserManager::getUserProfileLink($userinfo) . ' |
|
5074 | - ' . get_lang('ThisPageisBeginEditedTryLater') . ' ' . date("i", $rest_time) . ' ' . get_lang('MinMinutes') . ''; |
|
5073 | + $is_being_edited = get_lang('ThisPageisBeginEditedBy').' '.UserManager::getUserProfileLink($userinfo).' |
|
5074 | + ' . get_lang('ThisPageisBeginEditedTryLater').' '.date("i", $rest_time).' '.get_lang('MinMinutes').''; |
|
5075 | 5075 | } |
5076 | 5076 | |
5077 | 5077 | Display::addFlash( |
@@ -5088,7 +5088,7 @@ discard block |
||
5088 | 5088 | // Form. |
5089 | 5089 | $url = api_get_self().'?action=edit&title='.urlencode($page).'&session_id='.api_get_session_id().'&group_id='.api_get_group_id().'&'.api_get_cidreq(); |
5090 | 5090 | $form = new FormValidator('wiki', 'post', $url); |
5091 | - $form->addElement('header', $icon_assignment.str_repeat(' ',3).api_htmlentities($title)); |
|
5091 | + $form->addElement('header', $icon_assignment.str_repeat(' ', 3).api_htmlentities($title)); |
|
5092 | 5092 | self::setForm($form, $row); |
5093 | 5093 | $form->addElement('hidden', 'title'); |
5094 | 5094 | $form->addElement('button', 'SaveWikiChange', get_lang('Save')); |
@@ -5174,7 +5174,7 @@ discard block |
||
5174 | 5174 | $KeyAssignment = null; |
5175 | 5175 | $KeyTitle = null; |
5176 | 5176 | $KeyUserId = null; |
5177 | - while ($row=Database::fetch_array($result)) { |
|
5177 | + while ($row = Database::fetch_array($result)) { |
|
5178 | 5178 | $KeyVisibility = $row['visibility']; |
5179 | 5179 | $KeyAssignment = $row['assignment']; |
5180 | 5180 | $KeyTitle = $row['title']; |
@@ -5183,7 +5183,7 @@ discard block |
||
5183 | 5183 | $icon_assignment = null; |
5184 | 5184 | if ($KeyAssignment == 1) { |
5185 | 5185 | $icon_assignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'), '', ICON_SIZE_SMALL); |
5186 | - } elseif($KeyAssignment == 2) { |
|
5186 | + } elseif ($KeyAssignment == 2) { |
|
5187 | 5187 | $icon_assignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWorkExtra'), '', ICON_SIZE_SMALL); |
5188 | 5188 | } |
5189 | 5189 | |
@@ -5191,10 +5191,10 @@ discard block |
||
5191 | 5191 | |
5192 | 5192 | //if the page is hidden and is a job only sees its author and professor |
5193 | 5193 | if ($KeyVisibility == 1 || |
5194 | - api_is_allowed_to_edit(false,true) || |
|
5194 | + api_is_allowed_to_edit(false, true) || |
|
5195 | 5195 | api_is_platform_admin() || |
5196 | 5196 | ( |
5197 | - $KeyAssignment==2 && $KeyVisibility==0 && |
|
5197 | + $KeyAssignment == 2 && $KeyVisibility == 0 && |
|
5198 | 5198 | ($userId == $KeyUserId) |
5199 | 5199 | ) |
5200 | 5200 | ) { |
@@ -5224,7 +5224,7 @@ discard block |
||
5224 | 5224 | get_lang('ShowDifferences').' '.get_lang('WordsDiff').'</button>'; |
5225 | 5225 | echo '<br/><br/>'; |
5226 | 5226 | |
5227 | - $counter=0; |
|
5227 | + $counter = 0; |
|
5228 | 5228 | $total_versions = Database::num_rows($result); |
5229 | 5229 | |
5230 | 5230 | while ($row = Database::fetch_array($result)) { |
@@ -5232,10 +5232,10 @@ discard block |
||
5232 | 5232 | $username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username']), ENT_QUOTES); |
5233 | 5233 | |
5234 | 5234 | echo '<li style="margin-bottom: 5px;">'; |
5235 | - ($counter==0) ? $oldstyle='style="visibility: hidden;"':$oldstyle=''; |
|
5236 | - ($counter==0) ? $newchecked=' checked': $newchecked=''; |
|
5237 | - ($counter==$total_versions-1) ? $newstyle='style="visibility: hidden;"':$newstyle=''; |
|
5238 | - ($counter==1) ? $oldchecked=' checked':$oldchecked=''; |
|
5235 | + ($counter == 0) ? $oldstyle = 'style="visibility: hidden;"' : $oldstyle = ''; |
|
5236 | + ($counter == 0) ? $newchecked = ' checked' : $newchecked = ''; |
|
5237 | + ($counter == $total_versions - 1) ? $newstyle = 'style="visibility: hidden;"' : $newstyle = ''; |
|
5238 | + ($counter == 1) ? $oldchecked = ' checked' : $oldchecked = ''; |
|
5239 | 5239 | echo '<input name="old" value="'.$row['id'].'" type="radio" '.$oldstyle.' '.$oldchecked.'/> '; |
5240 | 5240 | echo '<input name="new" value="'.$row['id'].'" type="radio" '.$newstyle.' '.$newchecked.'/> '; |
5241 | 5241 | echo '<a href="'.api_get_self().'?action=showpage&title='.api_htmlentities(urlencode($page)).'&view='.$row['id'].'">'; |
@@ -5255,8 +5255,8 @@ discard block |
||
5255 | 5255 | $comment = api_substr($comment, 0, 100); |
5256 | 5256 | if ($comment !== false) { |
5257 | 5257 | $comment = api_htmlentities($comment); |
5258 | - echo get_lang('Comments').': ' . $comment; |
|
5259 | - if (api_strlen($row['comment'])>100) { |
|
5258 | + echo get_lang('Comments').': '.$comment; |
|
5259 | + if (api_strlen($row['comment']) > 100) { |
|
5260 | 5260 | echo '... '; |
5261 | 5261 | } |
5262 | 5262 | } |
@@ -5282,8 +5282,8 @@ discard block |
||
5282 | 5282 | |
5283 | 5283 | $sql_new = "SELECT * FROM $tbl_wiki |
5284 | 5284 | WHERE c_id = $course_id AND id='".Database::escape_string($_POST['new'])."'"; |
5285 | - $result_new=Database::query($sql_new); |
|
5286 | - $version_new=Database::fetch_array($result_new); |
|
5285 | + $result_new = Database::query($sql_new); |
|
5286 | + $version_new = Database::fetch_array($result_new); |
|
5287 | 5287 | $oldTime = isset($version_old['dtime']) ? $version_old['dtime'] : null; |
5288 | 5288 | $oldContent = isset($version_old['content']) ? $version_old['content'] : null; |
5289 | 5289 | |
@@ -5310,9 +5310,9 @@ discard block |
||
5310 | 5310 | |
5311 | 5311 | |
5312 | 5312 | if (isset($_POST['HistoryDifferences'])) { |
5313 | - echo '<table>'.diff($oldContent, $version_new['content'], true, 'format_table_line' ).'</table>'; // format_line mode is better for words |
|
5313 | + echo '<table>'.diff($oldContent, $version_new['content'], true, 'format_table_line').'</table>'; // format_line mode is better for words |
|
5314 | 5314 | echo '<br />'; |
5315 | - echo '<strong>'.get_lang('Legend').'</strong><div class="diff">' . "\n"; |
|
5315 | + echo '<strong>'.get_lang('Legend').'</strong><div class="diff">'."\n"; |
|
5316 | 5316 | echo '<table><tr>'; |
5317 | 5317 | echo '<td>'; |
5318 | 5318 | echo '</td><td>'; |
@@ -5331,7 +5331,7 @@ discard block |
||
5331 | 5331 | $renderer = new Text_Diff_Renderer_inline(); |
5332 | 5332 | echo '<style>del{background:#fcc}ins{background:#cfc}</style>'.$renderer->render($diff); // Code inline |
5333 | 5333 | echo '<br />'; |
5334 | - echo '<strong>'.get_lang('Legend').'</strong><div class="diff">' . "\n"; |
|
5334 | + echo '<strong>'.get_lang('Legend').'</strong><div class="diff">'."\n"; |
|
5335 | 5335 | echo '<table><tr>'; |
5336 | 5336 | echo '<td>'; |
5337 | 5337 | echo '</td><td>'; |
@@ -5379,7 +5379,7 @@ discard block |
||
5379 | 5379 | echo '<td style="vertical-align:top">'; |
5380 | 5380 | echo '<ul>'; |
5381 | 5381 | // Submenu Statistics |
5382 | - if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { |
|
5382 | + if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { |
|
5383 | 5383 | echo '<li><a href="index.php?cidReq='.$_course['id'].'&action=statistics&session_id='.$session_id.'&group_id='.$groupId.'">'.get_lang('Statistics').'</a></li>'; |
5384 | 5384 | } |
5385 | 5385 | echo ' </ul>'; |
@@ -5452,7 +5452,7 @@ discard block |
||
5452 | 5452 | break; |
5453 | 5453 | case 'deletewiki': |
5454 | 5454 | $title = '<div class="actions">'.get_lang('DeleteWiki').'</div>'; |
5455 | - if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { |
|
5455 | + if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { |
|
5456 | 5456 | $message = get_lang('ConfirmDeleteWiki'); |
5457 | 5457 | $message .= '<p> |
5458 | 5458 | <a href="index.php?'.api_get_cidreq().'">'.get_lang('No').'</a> |
@@ -5483,7 +5483,7 @@ discard block |
||
5483 | 5483 | self::getLinks($page); |
5484 | 5484 | break; |
5485 | 5485 | case 'addnew': |
5486 | - if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) { |
|
5486 | + if (api_get_session_id() != 0 && api_is_allowed_to_session_edit(false, true) == false) { |
|
5487 | 5487 | api_not_allowed(); |
5488 | 5488 | } |
5489 | 5489 | $groupInfo = GroupManager::get_group_properties(api_get_group_id()); |
@@ -5491,7 +5491,7 @@ discard block |
||
5491 | 5491 | echo '<br/>'; |
5492 | 5492 | //first, check if page index was created. chektitle=false |
5493 | 5493 | if (self::checktitle('index')) { |
5494 | - if (api_is_allowed_to_edit(false,true) || |
|
5494 | + if (api_is_allowed_to_edit(false, true) || |
|
5495 | 5495 | api_is_platform_admin() || |
5496 | 5496 | GroupManager::is_user_in_group(api_get_user_id(), $groupInfo['iid']) || |
5497 | 5497 | api_is_allowed_in_course() |
@@ -5500,11 +5500,11 @@ discard block |
||
5500 | 5500 | } else { |
5501 | 5501 | Display::addFlash(Display::display_normal_message(get_lang('WikiStandBy'), false, true)); |
5502 | 5502 | } |
5503 | - } elseif (self::check_addnewpagelock()==0 && (api_is_allowed_to_edit(false, true)==false || api_is_platform_admin()==false)) { |
|
5503 | + } elseif (self::check_addnewpagelock() == 0 && (api_is_allowed_to_edit(false, true) == false || api_is_platform_admin() == false)) { |
|
5504 | 5504 | Display::addFlash(Display::display_error_message(get_lang('AddPagesLocked'), false, true)); |
5505 | 5505 | } else { |
5506 | 5506 | $groupInfo = GroupManager::get_group_properties(api_get_group_id()); |
5507 | - if (api_is_allowed_to_edit(false,true) || |
|
5507 | + if (api_is_allowed_to_edit(false, true) || |
|
5508 | 5508 | api_is_platform_admin() || |
5509 | 5509 | GroupManager::is_user_in_group(api_get_user_id(), $groupInfo['iid']) || |
5510 | 5510 | $_GET['group_id'] == 0 |
@@ -1893,7 +1893,7 @@ discard block |
||
1893 | 1893 | $email_body = get_lang('DearUser').' '.api_get_person_name($userinfo['firstname'], $userinfo['lastname']).',<br /><br />'; |
1894 | 1894 | if($session_id==0){ |
1895 | 1895 | $email_body .= $emailtext.' <strong>'.$_course['name'].' - '.$group_name.'</strong><br /><br /><br />'; |
1896 | - }else{ |
|
1896 | + } else{ |
|
1897 | 1897 | $email_body .= $emailtext.' <strong>'.$_course['name'].' ('.api_get_session_name(api_get_session_id()).') - '.$group_name.'</strong><br /><br /><br />'; |
1898 | 1898 | } |
1899 | 1899 | $email_body .= $email_user_author.' ('.$email_date_changes.')<br /><br /><br />'; |
@@ -2283,8 +2283,7 @@ discard block |
||
2283 | 2283 | s1.reflink = s2.reflink AND |
2284 | 2284 | ".$groupfilter.$condition_session.")"; |
2285 | 2285 | // warning don't use group by reflink because don't return the last version |
2286 | - } |
|
2287 | - else { |
|
2286 | + } else { |
|
2288 | 2287 | $sql = " SELECT * FROM ".$tbl_wiki." s1 |
2289 | 2288 | WHERE |
2290 | 2289 | s1.c_id = $course_id AND |
@@ -3726,8 +3725,7 @@ discard block |
||
3726 | 3725 | '.api_htmlentities($obj->title).'</a>'; |
3727 | 3726 | if ($userinfo !== false) { |
3728 | 3727 | $row[] = UserManager::getUserProfileLink($userinfo); |
3729 | - } |
|
3730 | - else { |
|
3728 | + } else { |
|
3731 | 3729 | $row[] = get_lang('Anonymous').' ('.api_htmlentities($obj->user_ip).')'; |
3732 | 3730 | } |
3733 | 3731 | $row[] = api_get_local_time($obj->dtime, null, date_default_timezone_get()); |
@@ -3962,8 +3960,7 @@ discard block |
||
3962 | 3960 | api_htmlentities($obj->title).'</a>'; |
3963 | 3961 | if ($userinfo !== false) { |
3964 | 3962 | $row[] = UserManager::getUserProfileLink($userinfo); |
3965 | - } |
|
3966 | - else { |
|
3963 | + } else { |
|
3967 | 3964 | $row[] = get_lang('Anonymous').' ('.$obj->user_ip.')'; |
3968 | 3965 | } |
3969 | 3966 | $row[] = $year.'-'.$month.'-'.$day.' '.$hours.":".$minutes.":".$seconds; |
@@ -1415,7 +1415,7 @@ discard block |
||
1415 | 1415 | |
1416 | 1416 | /** |
1417 | 1417 | * Get the emoji list to include in chat |
1418 | - * @return array |
|
1418 | + * @return string[] |
|
1419 | 1419 | */ |
1420 | 1420 | public static function getEmojisToInclude() |
1421 | 1421 | { |
@@ -1738,7 +1738,7 @@ discard block |
||
1738 | 1738 | |
1739 | 1739 | /** |
1740 | 1740 | * Get the number of users connected in chat |
1741 | - * @return mixed |
|
1741 | + * @return integer |
|
1742 | 1742 | */ |
1743 | 1743 | public function countUsersOnline() |
1744 | 1744 | { |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | return ''; |
68 | 68 | } |
69 | 69 | |
70 | - Emojione\Emojione::$imagePathPNG = api_get_path(WEB_LIBRARY_PATH) . 'javascript/emojione/png/'; |
|
70 | + Emojione\Emojione::$imagePathPNG = api_get_path(WEB_LIBRARY_PATH).'javascript/emojione/png/'; |
|
71 | 71 | Emojione\Emojione::$ascii = true; |
72 | 72 | |
73 | 73 | $message = trim($message); |
@@ -113,15 +113,15 @@ discard block |
||
113 | 113 | $user = $em->find('ChamiloUserBundle:User', $this->userId); |
114 | 114 | $courseInfo = api_get_course_info_by_id($this->courseId); |
115 | 115 | $isMaster = (bool) api_is_course_admin(); |
116 | - $document_path = api_get_path(SYS_COURSE_PATH) . $courseInfo['path'] . '/document'; |
|
116 | + $document_path = api_get_path(SYS_COURSE_PATH).$courseInfo['path'].'/document'; |
|
117 | 117 | $basepath_chat = '/chat_files'; |
118 | 118 | |
119 | 119 | if (!$this->groupId) { |
120 | 120 | $group_info = GroupManager::get_group_properties($this->groupId); |
121 | - $basepath_chat = $group_info['directory'] . '/chat_files'; |
|
121 | + $basepath_chat = $group_info['directory'].'/chat_files'; |
|
122 | 122 | } |
123 | 123 | |
124 | - $chat_path = $document_path . $basepath_chat . '/'; |
|
124 | + $chat_path = $document_path.$basepath_chat.'/'; |
|
125 | 125 | |
126 | 126 | if (!is_dir($chat_path)) { |
127 | 127 | if (is_file($chat_path)) { |
@@ -131,25 +131,25 @@ discard block |
||
131 | 131 | |
132 | 132 | $date_now = date('Y-m-d'); |
133 | 133 | $timeNow = date('d/m/y H:i:s'); |
134 | - $basename_chat = 'messages-' . $date_now; |
|
134 | + $basename_chat = 'messages-'.$date_now; |
|
135 | 135 | |
136 | 136 | if ($this->groupId && !$friendId) { |
137 | - $basename_chat = 'messages-' . $date_now . '_gid-' . $this->groupId; |
|
137 | + $basename_chat = 'messages-'.$date_now.'_gid-'.$this->groupId; |
|
138 | 138 | } elseif ($this->sessionId && !$friendId) { |
139 | - $basename_chat = 'messages-' . $date_now . '_sid-' . $this->sessionId; |
|
139 | + $basename_chat = 'messages-'.$date_now.'_sid-'.$this->sessionId; |
|
140 | 140 | } elseif ($friendId) { |
141 | 141 | if ($this->userId < $friendId) { |
142 | - $basename_chat = 'messages-' . $date_now . '_uid-' . $this->userId . '-' . $friendId; |
|
142 | + $basename_chat = 'messages-'.$date_now.'_uid-'.$this->userId.'-'.$friendId; |
|
143 | 143 | } else { |
144 | - $basename_chat = 'messages-' . $date_now . '_uid-' . $friendId . '-' . $this->userId; |
|
144 | + $basename_chat = 'messages-'.$date_now.'_uid-'.$friendId.'-'.$this->userId; |
|
145 | 145 | } |
146 | 146 | } |
147 | 147 | |
148 | 148 | $message = self::prepareMessage($message); |
149 | 149 | |
150 | - $fileTitle = $basename_chat . '.log.html'; |
|
151 | - $filePath = $basepath_chat . '/' . $fileTitle; |
|
152 | - $absoluteFilePath = $chat_path . $fileTitle; |
|
150 | + $fileTitle = $basename_chat.'.log.html'; |
|
151 | + $filePath = $basepath_chat.'/'.$fileTitle; |
|
152 | + $absoluteFilePath = $chat_path.$fileTitle; |
|
153 | 153 | |
154 | 154 | if (!file_exists($absoluteFilePath)) { |
155 | 155 | $doc_id = add_document($courseInfo, $filePath, 'file', 0, $fileTitle); |
@@ -182,23 +182,23 @@ discard block |
||
182 | 182 | $fileContent = ' |
183 | 183 | <div class="message-teacher"> |
184 | 184 | <div class="content-message"> |
185 | - <div class="chat-message-block-name">' . $user->getCompleteName() . '</div> |
|
186 | - <div class="chat-message-block-content">' . $message . '</div> |
|
187 | - <div class="message-date">' . $timeNow . '</div> |
|
185 | + <div class="chat-message-block-name">' . $user->getCompleteName().'</div> |
|
186 | + <div class="chat-message-block-content">' . $message.'</div> |
|
187 | + <div class="message-date">' . $timeNow.'</div> |
|
188 | 188 | </div> |
189 | 189 | <div class="icon-message"></div> |
190 | - <img class="chat-image" src="' . $userPhoto . '"> |
|
190 | + <img class="chat-image" src="' . $userPhoto.'"> |
|
191 | 191 | </div> |
192 | 192 | '; |
193 | 193 | } else { |
194 | 194 | $fileContent = ' |
195 | 195 | <div class="message-student"> |
196 | - <img class="chat-image" src="' . $userPhoto . '"> |
|
196 | + <img class="chat-image" src="' . $userPhoto.'"> |
|
197 | 197 | <div class="icon-message"></div> |
198 | 198 | <div class="content-message"> |
199 | - <div class="chat-message-block-name">' . $user->getCompleteName() . '</div> |
|
200 | - <div class="chat-message-block-content">' . $message . '</div> |
|
201 | - <div class="message-date">' . $timeNow . '</div> |
|
199 | + <div class="chat-message-block-name">' . $user->getCompleteName().'</div> |
|
200 | + <div class="chat-message-block-content">' . $message.'</div> |
|
201 | + <div class="message-date">' . $timeNow.'</div> |
|
202 | 202 | </div> |
203 | 203 | </div> |
204 | 204 | '; |
@@ -293,9 +293,9 @@ discard block |
||
293 | 293 | $extraCondition = null; |
294 | 294 | |
295 | 295 | if ($this->groupId) { |
296 | - $extraCondition = 'AND ccc.toGroupId = ' . intval($this->groupId); |
|
296 | + $extraCondition = 'AND ccc.toGroupId = '.intval($this->groupId); |
|
297 | 297 | } else { |
298 | - $extraCondition = 'AND ccc.sessionId = ' . intval($this->sessionId); |
|
298 | + $extraCondition = 'AND ccc.sessionId = '.intval($this->sessionId); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | $currentTime = new DateTime(api_get_utc_datetime(), new DateTimeZone('UTC')); |
@@ -1394,7 +1394,7 @@ discard block |
||
1394 | 1394 | { |
1395 | 1395 | return [ |
1396 | 1396 | ':bowtie:', |
1397 | - ':smile:'| |
|
1397 | + ':smile:' | |
|
1398 | 1398 | ':laughing:', |
1399 | 1399 | ':blush:', |
1400 | 1400 | ':smiley:', |
@@ -1467,17 +1467,17 @@ discard block |
||
1467 | 1467 | public function getFileName($absolute = false, $friendId = 0) |
1468 | 1468 | { |
1469 | 1469 | $date = date('Y-m-d'); |
1470 | - $base = 'messages-' . $date . '.log.html'; |
|
1470 | + $base = 'messages-'.$date.'.log.html'; |
|
1471 | 1471 | |
1472 | 1472 | if ($this->groupId && !$friendId) { |
1473 | - $base = 'messages-' . $date . '_gid-' . $this->groupId . '.log.html'; |
|
1473 | + $base = 'messages-'.$date.'_gid-'.$this->groupId.'.log.html'; |
|
1474 | 1474 | } elseif ($this->sessionId && !$friendId) { |
1475 | - $base = 'messages-' . $date . '_sid-' . $this->sessionId . '.log.html'; |
|
1475 | + $base = 'messages-'.$date.'_sid-'.$this->sessionId.'.log.html'; |
|
1476 | 1476 | } elseif ($friendId) { |
1477 | 1477 | if ($this->userId < $friendId) { |
1478 | - $base = 'messages-' . $date . '_uid-' . $this->userId . '-' . $friendId . '.log.html'; |
|
1478 | + $base = 'messages-'.$date.'_uid-'.$this->userId.'-'.$friendId.'.log.html'; |
|
1479 | 1479 | } else { |
1480 | - $base = 'messages-' . $date . '_uid-' . $friendId . '-' . $this->userId . '.log.html'; |
|
1480 | + $base = 'messages-'.$date.'_uid-'.$friendId.'-'.$this->userId.'.log.html'; |
|
1481 | 1481 | } |
1482 | 1482 | } |
1483 | 1483 | |
@@ -1486,16 +1486,16 @@ discard block |
||
1486 | 1486 | } |
1487 | 1487 | |
1488 | 1488 | $courseInfo = api_get_course_info_by_id($this->courseId); |
1489 | - $document_path = api_get_path(SYS_COURSE_PATH) . $courseInfo['path'] . '/document'; |
|
1489 | + $document_path = api_get_path(SYS_COURSE_PATH).$courseInfo['path'].'/document'; |
|
1490 | 1490 | |
1491 | - $chatPath = $document_path . '/chat_files/'; |
|
1491 | + $chatPath = $document_path.'/chat_files/'; |
|
1492 | 1492 | |
1493 | 1493 | if ($this->groupId) { |
1494 | 1494 | $group_info = GroupManager::get_group_properties($this->groupId); |
1495 | - $chatPath = $document_path . $group_info['directory'] . '/chat_files/'; |
|
1495 | + $chatPath = $document_path.$group_info['directory'].'/chat_files/'; |
|
1496 | 1496 | } |
1497 | 1497 | |
1498 | - return $chatPath . $base; |
|
1498 | + return $chatPath.$base; |
|
1499 | 1499 | } |
1500 | 1500 | |
1501 | 1501 | /** |
@@ -1508,16 +1508,16 @@ discard block |
||
1508 | 1508 | { |
1509 | 1509 | $courseInfo = api_get_course_info_by_id($this->courseId); |
1510 | 1510 | $date_now = date('Y-m-d'); |
1511 | - $isMaster = (bool)api_is_course_admin(); |
|
1511 | + $isMaster = (bool) api_is_course_admin(); |
|
1512 | 1512 | $basepath_chat = '/chat_files'; |
1513 | - $document_path = api_get_path(SYS_COURSE_PATH) . $courseInfo['path'] . '/document'; |
|
1513 | + $document_path = api_get_path(SYS_COURSE_PATH).$courseInfo['path'].'/document'; |
|
1514 | 1514 | |
1515 | 1515 | if ($this->groupId) { |
1516 | 1516 | $group_info = GroupManager:: get_group_properties($this->groupId); |
1517 | - $basepath_chat = $group_info['directory'] . '/chat_files'; |
|
1517 | + $basepath_chat = $group_info['directory'].'/chat_files'; |
|
1518 | 1518 | } |
1519 | 1519 | |
1520 | - $chat_path = $document_path . $basepath_chat . '/'; |
|
1520 | + $chat_path = $document_path.$basepath_chat.'/'; |
|
1521 | 1521 | |
1522 | 1522 | if (!is_dir($chat_path)) { |
1523 | 1523 | if (is_file($chat_path)) { |
@@ -1544,24 +1544,24 @@ discard block |
||
1544 | 1544 | } |
1545 | 1545 | } |
1546 | 1546 | |
1547 | - $filename_chat = 'messages-' . $date_now . '.log.html'; |
|
1547 | + $filename_chat = 'messages-'.$date_now.'.log.html'; |
|
1548 | 1548 | |
1549 | 1549 | if ($this->groupId && !$friendId) { |
1550 | - $filename_chat = 'messages-' . $date_now . '_gid-' . $this->groupId . '.log.html'; |
|
1550 | + $filename_chat = 'messages-'.$date_now.'_gid-'.$this->groupId.'.log.html'; |
|
1551 | 1551 | } else if ($this->sessionId && !$friendId) { |
1552 | - $filename_chat = 'messages-' . $date_now . '_sid-' . $this->sessionId . '.log.html'; |
|
1552 | + $filename_chat = 'messages-'.$date_now.'_sid-'.$this->sessionId.'.log.html'; |
|
1553 | 1553 | } elseif ($friendId) { |
1554 | 1554 | if ($this->userId < $friendId) { |
1555 | - $filename_chat = 'messages-' . $date_now . '_uid-' . $this->userId . '-' . $friendId . '.log.html'; |
|
1555 | + $filename_chat = 'messages-'.$date_now.'_uid-'.$this->userId.'-'.$friendId.'.log.html'; |
|
1556 | 1556 | } else { |
1557 | - $filename_chat = 'messages-' . $date_now . '_uid-' . $friendId . '-' . $this->userId . '.log.html'; |
|
1557 | + $filename_chat = 'messages-'.$date_now.'_uid-'.$friendId.'-'.$this->userId.'.log.html'; |
|
1558 | 1558 | } |
1559 | 1559 | } |
1560 | 1560 | |
1561 | - if (!file_exists($chat_path . $filename_chat)) { |
|
1562 | - @fclose(fopen($chat_path . $filename_chat, 'w')); |
|
1561 | + if (!file_exists($chat_path.$filename_chat)) { |
|
1562 | + @fclose(fopen($chat_path.$filename_chat, 'w')); |
|
1563 | 1563 | if (!api_is_anonymous()) { |
1564 | - $doc_id = add_document($courseInfo, $basepath_chat . '/' . $filename_chat, 'file', 0, $filename_chat); |
|
1564 | + $doc_id = add_document($courseInfo, $basepath_chat.'/'.$filename_chat, 'file', 0, $filename_chat); |
|
1565 | 1565 | api_item_property_update( |
1566 | 1566 | $courseInfo, |
1567 | 1567 | TOOL_DOCUMENT, |
@@ -1590,17 +1590,17 @@ discard block |
||
1590 | 1590 | } |
1591 | 1591 | } |
1592 | 1592 | |
1593 | - $basename_chat = 'messages-' . $date_now; |
|
1593 | + $basename_chat = 'messages-'.$date_now; |
|
1594 | 1594 | |
1595 | 1595 | if ($this->groupId && !$friendId) { |
1596 | - $basename_chat = 'messages-' . $date_now . '_gid-' . $this->groupId; |
|
1596 | + $basename_chat = 'messages-'.$date_now.'_gid-'.$this->groupId; |
|
1597 | 1597 | } else if ($this->sessionId && !$friendId) { |
1598 | - $basename_chat = 'messages-' . $date_now . '_sid-' . $this->sessionId; |
|
1598 | + $basename_chat = 'messages-'.$date_now.'_sid-'.$this->sessionId; |
|
1599 | 1599 | } elseif ($friendId) { |
1600 | 1600 | if ($this->userId < $friendId) { |
1601 | - $basename_chat = 'messages-' . $date_now . '_uid-' . $this->userId . '-' . $friendId; |
|
1601 | + $basename_chat = 'messages-'.$date_now.'_uid-'.$this->userId.'-'.$friendId; |
|
1602 | 1602 | } else { |
1603 | - $basename_chat = 'messages-' . $date_now . '_uid-' . $friendId . '-' . $this->userId; |
|
1603 | + $basename_chat = 'messages-'.$date_now.'_uid-'.$friendId.'-'.$this->userId; |
|
1604 | 1604 | } |
1605 | 1605 | } |
1606 | 1606 | |
@@ -1608,19 +1608,19 @@ discard block |
||
1608 | 1608 | |
1609 | 1609 | $i = 1; |
1610 | 1610 | |
1611 | - while (file_exists($chat_path . $basename_chat . '-' . $i . '.log.html')) { |
|
1611 | + while (file_exists($chat_path.$basename_chat.'-'.$i.'.log.html')) { |
|
1612 | 1612 | $i++; |
1613 | 1613 | } |
1614 | 1614 | |
1615 | - @rename($chat_path . $basename_chat . '.log.html', $chat_path . $basename_chat . '-' . $i . '.log.html'); |
|
1616 | - @fclose(fopen($chat_path . $basename_chat . '.log.html', 'w')); |
|
1615 | + @rename($chat_path.$basename_chat.'.log.html', $chat_path.$basename_chat.'-'.$i.'.log.html'); |
|
1616 | + @fclose(fopen($chat_path.$basename_chat.'.log.html', 'w')); |
|
1617 | 1617 | |
1618 | 1618 | $doc_id = add_document( |
1619 | 1619 | $courseInfo, |
1620 | - $basepath_chat . '/' . $basename_chat . '-' . $i . '.log.html', |
|
1620 | + $basepath_chat.'/'.$basename_chat.'-'.$i.'.log.html', |
|
1621 | 1621 | 'file', |
1622 | - filesize($chat_path . $basename_chat . '-' . $i . '.log.html'), |
|
1623 | - $basename_chat . '-' . $i . '.log.html' |
|
1622 | + filesize($chat_path.$basename_chat.'-'.$i.'.log.html'), |
|
1623 | + $basename_chat.'-'.$i.'.log.html' |
|
1624 | 1624 | ); |
1625 | 1625 | |
1626 | 1626 | api_item_property_update( |
@@ -1651,7 +1651,7 @@ discard block |
||
1651 | 1651 | |
1652 | 1652 | $doc_id = DocumentManager::get_document_id( |
1653 | 1653 | $courseInfo, |
1654 | - $basepath_chat . '/' . $basename_chat . '.log.html' |
|
1654 | + $basepath_chat.'/'.$basename_chat.'.log.html' |
|
1655 | 1655 | ); |
1656 | 1656 | |
1657 | 1657 | update_existing_document($courseInfo, $doc_id, 0); |
@@ -1660,8 +1660,8 @@ discard block |
||
1660 | 1660 | $remove = 0; |
1661 | 1661 | $content = array(); |
1662 | 1662 | |
1663 | - if (file_exists($chat_path . $basename_chat . '.log.html')) { |
|
1664 | - $content = file($chat_path . $basename_chat . '.log.html'); |
|
1663 | + if (file_exists($chat_path.$basename_chat.'.log.html')) { |
|
1664 | + $content = file($chat_path.$basename_chat.'.log.html'); |
|
1665 | 1665 | $nbr_lines = sizeof($content); |
1666 | 1666 | $remove = $nbr_lines - 100; |
1667 | 1667 | } |
@@ -1674,7 +1674,7 @@ discard block |
||
1674 | 1674 | |
1675 | 1675 | if (isset($_GET['origin']) && $_GET['origin'] == 'whoisonline') { |
1676 | 1676 | //the caller |
1677 | - $content[0] = get_lang('CallSent') . '<br />' . $content[0]; |
|
1677 | + $content[0] = get_lang('CallSent').'<br />'.$content[0]; |
|
1678 | 1678 | } |
1679 | 1679 | |
1680 | 1680 | $history = '<div id="content-chat">'; |
@@ -1689,7 +1689,7 @@ discard block |
||
1689 | 1689 | $history .= ' |
1690 | 1690 | <div id="clear-chat"> |
1691 | 1691 | <button type="button" id="chat-reset" class="btn btn-danger btn-sm"> |
1692 | - ' . get_lang('ClearList') . ' |
|
1692 | + ' . get_lang('ClearList').' |
|
1693 | 1693 | </button> |
1694 | 1694 | </div> |
1695 | 1695 | '; |
@@ -1710,9 +1710,9 @@ discard block |
||
1710 | 1710 | $extraCondition = null; |
1711 | 1711 | |
1712 | 1712 | if ($this->groupId) { |
1713 | - $extraCondition = 'AND ccc.toGroupId = ' . intval($this->groupId); |
|
1713 | + $extraCondition = 'AND ccc.toGroupId = '.intval($this->groupId); |
|
1714 | 1714 | } else { |
1715 | - $extraCondition = 'AND ccc.sessionId = ' . intval($this->sessionId); |
|
1715 | + $extraCondition = 'AND ccc.sessionId = '.intval($this->sessionId); |
|
1716 | 1716 | } |
1717 | 1717 | |
1718 | 1718 | $number = Database::getManager() |
@@ -1742,9 +1742,9 @@ discard block |
||
1742 | 1742 | $extraCondition = null; |
1743 | 1743 | |
1744 | 1744 | if ($this->groupId) { |
1745 | - $extraCondition = 'AND ccc.toGroupId = ' . intval($this->groupId); |
|
1745 | + $extraCondition = 'AND ccc.toGroupId = '.intval($this->groupId); |
|
1746 | 1746 | } else { |
1747 | - $extraCondition = 'AND ccc.sessionId = ' . intval($this->sessionId); |
|
1747 | + $extraCondition = 'AND ccc.sessionId = '.intval($this->sessionId); |
|
1748 | 1748 | } |
1749 | 1749 | |
1750 | 1750 | $number = Database::getManager() |
@@ -1780,7 +1780,7 @@ discard block |
||
1780 | 1780 | 'lastname' => $user->getLastname(), |
1781 | 1781 | 'status' => !$this->sessionId ? $subscription->getStatus() : $user->getStatus(), |
1782 | 1782 | 'image_url' => UserManager::getUserPicture($user->getId(), USER_IMAGE_SIZE_MEDIUM), |
1783 | - 'profile_url' => api_get_path(WEB_CODE_PATH) . 'social/profile.php?u=' . $user->getId(), |
|
1783 | + 'profile_url' => api_get_path(WEB_CODE_PATH).'social/profile.php?u='.$user->getId(), |
|
1784 | 1784 | 'complete_name' => $user->getCompleteName(), |
1785 | 1785 | 'username' => $user->getUsername(), |
1786 | 1786 | 'email' => $user->getEmail(), |
@@ -17,11 +17,11 @@ discard block |
||
17 | 17 | ]; |
18 | 18 | |
19 | 19 | foreach ($externalCSS as $css) { |
20 | - $htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_JS_PATH) . $css); |
|
20 | + $htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_JS_PATH).$css); |
|
21 | 21 | } |
22 | 22 | |
23 | -$htmlHeadXtra[] = api_get_css(api_get_path(WEB_CSS_PATH) . 'chat.css'); |
|
24 | -$htmlHeadXtra[] = api_get_css(api_get_path(WEB_CSS_PATH) . 'markdown.css'); |
|
23 | +$htmlHeadXtra[] = api_get_css(api_get_path(WEB_CSS_PATH).'chat.css'); |
|
24 | +$htmlHeadXtra[] = api_get_css(api_get_path(WEB_CSS_PATH).'markdown.css'); |
|
25 | 25 | |
26 | 26 | $externalJS = [ |
27 | 27 | 'highlight/highlight.pack.js', |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | continue; |
42 | 42 | } |
43 | 43 | |
44 | - $iconList[$key] = strtoupper($icon) . '.png'; |
|
44 | + $iconList[$key] = strtoupper($icon).'.png'; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | $view = new Template(get_lang('Chat'), false, false, false, true, false); |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @param array $values Array of title + description (name => $title, description => $comment) |
97 | 97 | * |
98 | - * @return mixed Term id on success, false on failure |
|
98 | + * @return false|string Term id on success, false on failure |
|
99 | 99 | * |
100 | 100 | */ |
101 | 101 | public static function save_glossary($values, $showMessage = true) |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | |
449 | 449 | /** |
450 | 450 | * Display the glossary terms in a list |
451 | - * @return bool true |
|
451 | + * @return string true |
|
452 | 452 | */ |
453 | 453 | public static function displayGlossaryList() |
454 | 454 | { |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | * Update action icons column |
586 | 586 | * |
587 | 587 | * @param integer $glossary_id |
588 | - * @param array $url_params Parameters to use to affect links |
|
588 | + * @param string $url_params Parameters to use to affect links |
|
589 | 589 | * @param array $row The line of results from a query on the glossary table |
590 | 590 | * |
591 | 591 | * @return string HTML string for the action icons columns |
@@ -47,9 +47,9 @@ discard block |
||
47 | 47 | * |
48 | 48 | * @return string The glossary description |
49 | 49 | */ |
50 | - public static function get_glossary_term_by_glossary_id ($glossary_id) |
|
50 | + public static function get_glossary_term_by_glossary_id($glossary_id) |
|
51 | 51 | { |
52 | - $glossary_table = Database::get_course_table(TABLE_GLOSSARY); |
|
52 | + $glossary_table = Database::get_course_table(TABLE_GLOSSARY); |
|
53 | 53 | $course_id = api_get_course_int_id(); |
54 | 54 | $sql = "SELECT description FROM $glossary_table |
55 | 55 | WHERE c_id = $course_id AND glossary_id =".intval($glossary_id); |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | */ |
73 | 73 | public static function get_glossary_term_by_glossary_name($glossary_name) |
74 | 74 | { |
75 | - $glossary_table = Database::get_course_table(TABLE_GLOSSARY); |
|
75 | + $glossary_table = Database::get_course_table(TABLE_GLOSSARY); |
|
76 | 76 | $session_id = api_get_session_id(); |
77 | 77 | $course_id = api_get_course_int_id(); |
78 | 78 | $sql_filter = api_get_session_condition($session_id); |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | $get_max = "SELECT MAX(display_order) FROM $t_glossary |
226 | 226 | WHERE c_id = $course_id "; |
227 | 227 | $res_max = Database::query($get_max); |
228 | - if (Database::num_rows($res_max)==0) { |
|
228 | + if (Database::num_rows($res_max) == 0) { |
|
229 | 229 | return 0; |
230 | 230 | } |
231 | 231 | $row = Database::fetch_array($res_max); |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | WHERE |
255 | 255 | c_id = $course_id AND |
256 | 256 | name = '".Database::escape_string($term)."'"; |
257 | - if ($not_id<>'') { |
|
257 | + if ($not_id <> '') { |
|
258 | 258 | $sql .= " AND glossary_id <> '".intval($not_id)."'"; |
259 | 259 | } |
260 | 260 | $result = Database::query($sql); |
@@ -378,25 +378,25 @@ discard block |
||
378 | 378 | $actionsLeft = ''; |
379 | 379 | if (api_is_allowed_to_edit(null, true)) { |
380 | 380 | $actionsLeft .= '<a href="index.php?'.api_get_cidreq().'&action=addglossary&msg=add?'.api_get_cidreq().'">'. |
381 | - Display::return_icon('new_glossary_term.png',get_lang('TermAddNew'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
381 | + Display::return_icon('new_glossary_term.png', get_lang('TermAddNew'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | $actionsLeft .= '<a href="index.php?'.api_get_cidreq().'&action=export">'. |
385 | - Display::return_icon('export_csv.png',get_lang('ExportGlossaryAsCSV'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
385 | + Display::return_icon('export_csv.png', get_lang('ExportGlossaryAsCSV'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
386 | 386 | if (api_is_allowed_to_edit(null, true)) { |
387 | 387 | $actionsLeft .= '<a href="index.php?'.api_get_cidreq().'&action=import">'. |
388 | - Display::return_icon('import_csv.png',get_lang('ImportGlossary'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
388 | + Display::return_icon('import_csv.png', get_lang('ImportGlossary'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | $actionsLeft .= '<a href="index.php?'.api_get_cidreq().'&action=export_to_pdf">'. |
392 | - Display::return_icon('pdf.png',get_lang('ExportToPDF'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
392 | + Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
393 | 393 | |
394 | 394 | if (($view == 'table') || (!isset($view))) { |
395 | 395 | $actionsLeft .= '<a href="index.php?'.api_get_cidreq().'&action=changeview&view=list">'. |
396 | - Display::return_icon('view_detailed.png',get_lang('ListView'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
396 | + Display::return_icon('view_detailed.png', get_lang('ListView'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
397 | 397 | } else { |
398 | 398 | $actionsLeft .= '<a href="index.php?'.api_get_cidreq().'&action=changeview&view=table">'. |
399 | - Display::return_icon('view_text.png',get_lang('TableView'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
399 | + Display::return_icon('view_text.png', get_lang('TableView'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | /* BUILD SEARCH FORM */ |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | $table->set_header(1, get_lang('TermDefinition'), true); |
434 | 434 | if (api_is_allowed_to_edit(null, true)) { |
435 | 435 | $table->set_header(2, get_lang('Actions'), false, 'width=90px', array('class' => 'td_actions')); |
436 | - $table->set_column_filter(2, array('GlossaryManager','actions_filter')); |
|
436 | + $table->set_column_filter(2, array('GlossaryManager', 'actions_filter')); |
|
437 | 437 | } |
438 | 438 | $content .= $table->return_table(); |
439 | 439 | } |
@@ -455,8 +455,8 @@ discard block |
||
455 | 455 | $content = ''; |
456 | 456 | foreach ($glossary_data as $key => $glossary_item) { |
457 | 457 | $actions = ''; |
458 | - if (api_is_allowed_to_edit(null,true)) { |
|
459 | - $actions = '<div class="pull-right">'.self::actions_filter($glossary_item[2], '',$glossary_item).'</div>'; |
|
458 | + if (api_is_allowed_to_edit(null, true)) { |
|
459 | + $actions = '<div class="pull-right">'.self::actions_filter($glossary_item[2], '', $glossary_item).'</div>'; |
|
460 | 460 | } |
461 | 461 | $content .= Display::panel($glossary_item[1], $glossary_item[0].' '.$actions); |
462 | 462 | } |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | * @return integer Count of glossary terms |
470 | 470 | * |
471 | 471 | */ |
472 | - public static function get_number_glossary_terms($session_id=0) |
|
472 | + public static function get_number_glossary_terms($session_id = 0) |
|
473 | 473 | { |
474 | 474 | // Database table definition |
475 | 475 | $t_glossary = Database :: get_course_table(TABLE_GLOSSARY); |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | while ($data = Database::fetch_array($res)) { |
564 | 564 | // Validation when belongs to a session |
565 | 565 | $session_img = api_get_session_image($data['session_id'], $_user['status']); |
566 | - $array[0] = $data[0] . $session_img; |
|
566 | + $array[0] = $data[0].$session_img; |
|
567 | 567 | |
568 | 568 | if (!$view || $view === 'table') { |
569 | 569 | $array[1] = str_replace(array('<p>', '</p>'), array('', '<br />'), $data[1]); |
@@ -593,13 +593,13 @@ discard block |
||
593 | 593 | { |
594 | 594 | $glossary_id = $row[2]; |
595 | 595 | $return = '<a href="'.api_get_self().'?action=edit_glossary&glossary_id='.$glossary_id.'&'.api_get_cidreq().'&msg=edit">'. |
596 | - Display::return_icon('edit.png',get_lang('Edit'),'',22).'</a>'; |
|
596 | + Display::return_icon('edit.png', get_lang('Edit'), '', 22).'</a>'; |
|
597 | 597 | $glossary_data = GlossaryManager::get_glossary_information($glossary_id); |
598 | 598 | $glossary_term = $glossary_data['name']; |
599 | 599 | if (api_is_allowed_to_edit(null, true)) { |
600 | 600 | if ($glossary_data['session_id'] == api_get_session_id()) { |
601 | 601 | $return .= '<a href="'.api_get_self().'?action=delete_glossary&glossary_id='.$glossary_id.'&'.api_get_cidreq().'" onclick="return confirmation(\''.$glossary_term.'\');">'. |
602 | - Display::return_icon('delete.png', get_lang('Delete'),'',22).'</a>'; |
|
602 | + Display::return_icon('delete.png', get_lang('Delete'), '', 22).'</a>'; |
|
603 | 603 | } else { |
604 | 604 | $return = get_lang('EditionNotAvailableFromSession'); |
605 | 605 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | // Now that there is an association created, move on |
65 | 65 | // to request authentication from the IdP |
66 | 66 | $identity = (!empty($services[0]['delegate'])) ? $services[0]['delegate'] : $claimed_id; |
67 | - if (isset($services[0]['types']) && is_array($services[0]['types']) && in_array(OPENID_NS_2_0 . '/server', $services[0]['types'])) { |
|
67 | + if (isset($services[0]['types']) && is_array($services[0]['types']) && in_array(OPENID_NS_2_0.'/server', $services[0]['types'])) { |
|
68 | 68 | $identity = 'http://openid.net/identifier_select/2.0'; |
69 | 69 | } |
70 | 70 | $authn_request = openid_authentication_request($claimed_id, $identity, $return_to, $assoc_handle, $services[0]['version']); |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | |
120 | 120 | $xrds_url = $claimed_id; |
121 | 121 | if (_openid_is_xri($claimed_id)) { |
122 | - $xrds_url = 'http://xri.net/' . $claimed_id; |
|
122 | + $xrds_url = 'http://xri.net/'.$claimed_id; |
|
123 | 123 | } |
124 | 124 | $url = @parse_url($xrds_url); |
125 | 125 | if ($url['scheme'] == 'http' || $url['scheme'] == 'https') { |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | //@todo Remove Old Associations: |
183 | 183 | $openid_association = Database::get_main_table(TABLE_MAIN_OPENID_ASSOCIATION); |
184 | 184 | $sql = "DELETE FROM $openid_association |
185 | - WHERE created + expires_in < '" . api_get_utc_datetime() . "'"; |
|
185 | + WHERE created + expires_in < '".api_get_utc_datetime()."'"; |
|
186 | 186 | Database::query($sql); |
187 | 187 | |
188 | 188 | // Check to see if we have an association for this IdP already |
@@ -339,17 +339,17 @@ discard block |
||
339 | 339 | switch ($uri['scheme']) { |
340 | 340 | case 'http': |
341 | 341 | $port = isset($uri['port']) ? $uri['port'] : 80; |
342 | - $host = $uri['host'] . ($port != 80 ? ':' . $port : ''); |
|
342 | + $host = $uri['host'].($port != 80 ? ':'.$port : ''); |
|
343 | 343 | $fp = @fsockopen($uri['host'], $port, $errno, $errstr, 15); |
344 | 344 | break; |
345 | 345 | case 'https': |
346 | 346 | // Note: Only works for PHP 4.3 compiled with OpenSSL. |
347 | 347 | $port = isset($uri['port']) ? $uri['port'] : 443; |
348 | - $host = $uri['host'] . ($port != 443 ? ':' . $port : ''); |
|
349 | - $fp = @fsockopen('ssl://' . $uri['host'], $port, $errno, $errstr, 20); |
|
348 | + $host = $uri['host'].($port != 443 ? ':'.$port : ''); |
|
349 | + $fp = @fsockopen('ssl://'.$uri['host'], $port, $errno, $errstr, 20); |
|
350 | 350 | break; |
351 | 351 | default: |
352 | - $result->error = 'invalid schema ' . $uri['scheme']; |
|
352 | + $result->error = 'invalid schema '.$uri['scheme']; |
|
353 | 353 | return $result; |
354 | 354 | } |
355 | 355 | |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | // Construct the path to act on. |
366 | 366 | $path = isset($uri['path']) ? $uri['path'] : '/'; |
367 | 367 | if (isset($uri['query'])) { |
368 | - $path .= '?' . $uri['query']; |
|
368 | + $path .= '?'.$uri['query']; |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | // Create HTTP request. |
@@ -375,23 +375,23 @@ discard block |
||
375 | 375 | // host that do not take into account the port number. |
376 | 376 | 'Host' => "Host: $host", |
377 | 377 | 'User-Agent' => 'User-Agent: Chamilo (+http://www.chamilo.org/)', |
378 | - 'Content-Length' => 'Content-Length: ' . strlen($data) |
|
378 | + 'Content-Length' => 'Content-Length: '.strlen($data) |
|
379 | 379 | ); |
380 | 380 | |
381 | 381 | // If the server url has a user then attempt to use basic authentication |
382 | 382 | if (isset($uri['user'])) { |
383 | - $defaults['Authorization'] = 'Authorization: Basic ' . base64_encode($uri['user'] . (!empty($uri['pass']) ? ":" . $uri['pass'] : '')); |
|
383 | + $defaults['Authorization'] = 'Authorization: Basic '.base64_encode($uri['user'].(!empty($uri['pass']) ? ":".$uri['pass'] : '')); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | foreach ($headers as $header => $value) { |
387 | - $defaults[$header] = $header . ': ' . $value; |
|
387 | + $defaults[$header] = $header.': '.$value; |
|
388 | 388 | } |
389 | 389 | |
390 | - $request = $method . ' ' . $path . " HTTP/1.0\r\n"; |
|
390 | + $request = $method.' '.$path." HTTP/1.0\r\n"; |
|
391 | 391 | $request .= implode("\r\n", $defaults); |
392 | 392 | $request .= "\r\n\r\n"; |
393 | 393 | if ($data) { |
394 | - $request .= $data . "\r\n"; |
|
394 | + $request .= $data."\r\n"; |
|
395 | 395 | } |
396 | 396 | $result->request = $request; |
397 | 397 | |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | if (isset($result->headers[$header]) && $header == 'Set-Cookie') { |
418 | 418 | // RFC 2109: the Set-Cookie response header comprises the token Set- |
419 | 419 | // Cookie:, followed by a comma-separated list of one or more cookies. |
420 | - $result->headers[$header] .= ',' . trim($value); |
|
420 | + $result->headers[$header] .= ','.trim($value); |
|
421 | 421 | } else { |
422 | 422 | $result->headers[$header] = trim($value); |
423 | 423 | } |
@@ -12,490 +12,490 @@ |
||
12 | 12 | */ |
13 | 13 | class WSCourse extends WS |
14 | 14 | { |
15 | - /** |
|
16 | - * Deletes a course (helper method) |
|
17 | - * |
|
18 | - * @param string Course id field name |
|
19 | - * @param string Course id value |
|
20 | - * @return mixed True if the course was successfully deleted, WSError otherwise |
|
21 | - */ |
|
22 | - protected function deleteCourseHelper($course_id_field_name, $course_id_value) { |
|
23 | - $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
|
24 | - if($course_id instanceof WSError) { |
|
25 | - return $course_id; |
|
26 | - } else { |
|
27 | - $course_code = CourseManager::get_course_code_from_course_id($course_id); |
|
28 | - CourseManager::delete_course($course_code); |
|
29 | - return true; |
|
30 | - } |
|
31 | - } |
|
15 | + /** |
|
16 | + * Deletes a course (helper method) |
|
17 | + * |
|
18 | + * @param string Course id field name |
|
19 | + * @param string Course id value |
|
20 | + * @return mixed True if the course was successfully deleted, WSError otherwise |
|
21 | + */ |
|
22 | + protected function deleteCourseHelper($course_id_field_name, $course_id_value) { |
|
23 | + $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
|
24 | + if($course_id instanceof WSError) { |
|
25 | + return $course_id; |
|
26 | + } else { |
|
27 | + $course_code = CourseManager::get_course_code_from_course_id($course_id); |
|
28 | + CourseManager::delete_course($course_code); |
|
29 | + return true; |
|
30 | + } |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * Deletes a course |
|
35 | - * |
|
36 | - * @param string API secret key |
|
37 | - * @param string Course id field name |
|
38 | - * @param string Course id value |
|
39 | - */ |
|
40 | - public function DeleteCourse($secret_key, $course_id_field_name, $course_id_value) { |
|
41 | - $verifKey = $this->verifyKey($secret_key); |
|
42 | - if($verifKey instanceof WSError) { |
|
43 | - $this->handleError($verifKey); |
|
44 | - } else { |
|
45 | - $result = $this->deleteCourseHelper($course_id_field_name, $course_id_value); |
|
46 | - if($result instanceof WSError) { |
|
47 | - $this->handleError($result); |
|
48 | - } |
|
49 | - } |
|
50 | - } |
|
33 | + /** |
|
34 | + * Deletes a course |
|
35 | + * |
|
36 | + * @param string API secret key |
|
37 | + * @param string Course id field name |
|
38 | + * @param string Course id value |
|
39 | + */ |
|
40 | + public function DeleteCourse($secret_key, $course_id_field_name, $course_id_value) { |
|
41 | + $verifKey = $this->verifyKey($secret_key); |
|
42 | + if($verifKey instanceof WSError) { |
|
43 | + $this->handleError($verifKey); |
|
44 | + } else { |
|
45 | + $result = $this->deleteCourseHelper($course_id_field_name, $course_id_value); |
|
46 | + if($result instanceof WSError) { |
|
47 | + $this->handleError($result); |
|
48 | + } |
|
49 | + } |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * Deletes multiple courses |
|
54 | - * |
|
55 | - * @param string API secret key |
|
56 | - * @param array Array of courses with elements of the form array('course_id_field_name' => 'name_of_field', 'course_id_value' => 'value') |
|
57 | - * @return array Array with elements like array('course_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different |
|
58 | - * than 0, an error occured |
|
59 | - */ |
|
60 | - public function DeleteCourses($secret_key, $courses) { |
|
61 | - $verifKey = $this->verifyKey($secret_key); |
|
62 | - if($verifKey instanceof WSError) { |
|
63 | - $this->handleError($verifKey); |
|
64 | - } else { |
|
65 | - $results = array(); |
|
66 | - foreach($courses as $course) { |
|
67 | - $result_tmp = array(); |
|
68 | - $result_op = $this->deleteCourseHelper($course['course_id_field_name'], $course['course_id_value']); |
|
69 | - $result_tmp['course_id_value'] = $course['course_id_value']; |
|
70 | - if($result_op instanceof WSError) { |
|
71 | - // Return the error in the results |
|
72 | - $result_tmp['result'] = $result_op->toArray(); |
|
73 | - } else { |
|
74 | - $result_tmp['result'] = $this->getSuccessfulResult(); |
|
75 | - } |
|
76 | - $results[] = $result_tmp; |
|
77 | - } |
|
78 | - return $results; |
|
79 | - } |
|
80 | - } |
|
52 | + /** |
|
53 | + * Deletes multiple courses |
|
54 | + * |
|
55 | + * @param string API secret key |
|
56 | + * @param array Array of courses with elements of the form array('course_id_field_name' => 'name_of_field', 'course_id_value' => 'value') |
|
57 | + * @return array Array with elements like array('course_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different |
|
58 | + * than 0, an error occured |
|
59 | + */ |
|
60 | + public function DeleteCourses($secret_key, $courses) { |
|
61 | + $verifKey = $this->verifyKey($secret_key); |
|
62 | + if($verifKey instanceof WSError) { |
|
63 | + $this->handleError($verifKey); |
|
64 | + } else { |
|
65 | + $results = array(); |
|
66 | + foreach($courses as $course) { |
|
67 | + $result_tmp = array(); |
|
68 | + $result_op = $this->deleteCourseHelper($course['course_id_field_name'], $course['course_id_value']); |
|
69 | + $result_tmp['course_id_value'] = $course['course_id_value']; |
|
70 | + if($result_op instanceof WSError) { |
|
71 | + // Return the error in the results |
|
72 | + $result_tmp['result'] = $result_op->toArray(); |
|
73 | + } else { |
|
74 | + $result_tmp['result'] = $this->getSuccessfulResult(); |
|
75 | + } |
|
76 | + $results[] = $result_tmp; |
|
77 | + } |
|
78 | + return $results; |
|
79 | + } |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * Creates a course (helper method) |
|
84 | - * |
|
85 | - * @param string Title |
|
86 | - * @param string Category code |
|
87 | - * @param string Wanted code. If it's not defined, it will be generated automatically |
|
88 | - * @param string Tutor name |
|
89 | - * @param string Course admin user id field name |
|
90 | - * @param string Course admin user id value |
|
91 | - * @param string Course language |
|
92 | - * @param string Course id field name |
|
93 | - * @param string Course id value |
|
94 | - * @param array Course extra fields |
|
95 | - * @return mixed Generated id if creation was successful, WSError otherwise |
|
96 | - */ |
|
97 | - protected function createCourseHelper($title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras) { |
|
98 | - // Add the original course id field name and value to the extra fields if needed |
|
99 | - $extras_associative = array(); |
|
100 | - if($course_id_field_name != "chamilo_course_id") { |
|
101 | - $extras_associative[$course_id_field_name] = $course_id_value; |
|
102 | - } |
|
103 | - foreach($extras as $extra) { |
|
104 | - $extras_associative[$extra['field_name']] = $extra['field_value']; |
|
105 | - } |
|
106 | - $course_admin_id = $this->getUserId($course_admin_user_id_field_name, $course_admin_user_id_value); |
|
107 | - if($course_admin_id instanceof WSError) { |
|
108 | - return $course_admin_id; |
|
109 | - } |
|
110 | - if($wanted_code == '') { |
|
111 | - $wanted_code = CourseManager::generate_course_code($title); |
|
112 | - } |
|
113 | - $result = create_course($wanted_code, $title, $tutor_name, $category_code, $language, $course_admin_id, $this->_configuration['db_prefix'], 0); |
|
114 | - if (!$result) { |
|
115 | - return new WSError(202, 'There was an error creating the course'); |
|
116 | - } else { |
|
117 | - // Update extra fields |
|
118 | - foreach($extras_associative as $fname => $fvalue) { |
|
119 | - CourseManager::update_course_extra_field_value($result, $fname, $fvalue); |
|
120 | - } |
|
121 | - // Get course id |
|
122 | - $course_info = CourseManager::get_course_information($result); |
|
123 | - return $course_info['real_id']; |
|
124 | - } |
|
125 | - } |
|
82 | + /** |
|
83 | + * Creates a course (helper method) |
|
84 | + * |
|
85 | + * @param string Title |
|
86 | + * @param string Category code |
|
87 | + * @param string Wanted code. If it's not defined, it will be generated automatically |
|
88 | + * @param string Tutor name |
|
89 | + * @param string Course admin user id field name |
|
90 | + * @param string Course admin user id value |
|
91 | + * @param string Course language |
|
92 | + * @param string Course id field name |
|
93 | + * @param string Course id value |
|
94 | + * @param array Course extra fields |
|
95 | + * @return mixed Generated id if creation was successful, WSError otherwise |
|
96 | + */ |
|
97 | + protected function createCourseHelper($title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras) { |
|
98 | + // Add the original course id field name and value to the extra fields if needed |
|
99 | + $extras_associative = array(); |
|
100 | + if($course_id_field_name != "chamilo_course_id") { |
|
101 | + $extras_associative[$course_id_field_name] = $course_id_value; |
|
102 | + } |
|
103 | + foreach($extras as $extra) { |
|
104 | + $extras_associative[$extra['field_name']] = $extra['field_value']; |
|
105 | + } |
|
106 | + $course_admin_id = $this->getUserId($course_admin_user_id_field_name, $course_admin_user_id_value); |
|
107 | + if($course_admin_id instanceof WSError) { |
|
108 | + return $course_admin_id; |
|
109 | + } |
|
110 | + if($wanted_code == '') { |
|
111 | + $wanted_code = CourseManager::generate_course_code($title); |
|
112 | + } |
|
113 | + $result = create_course($wanted_code, $title, $tutor_name, $category_code, $language, $course_admin_id, $this->_configuration['db_prefix'], 0); |
|
114 | + if (!$result) { |
|
115 | + return new WSError(202, 'There was an error creating the course'); |
|
116 | + } else { |
|
117 | + // Update extra fields |
|
118 | + foreach($extras_associative as $fname => $fvalue) { |
|
119 | + CourseManager::update_course_extra_field_value($result, $fname, $fvalue); |
|
120 | + } |
|
121 | + // Get course id |
|
122 | + $course_info = CourseManager::get_course_information($result); |
|
123 | + return $course_info['real_id']; |
|
124 | + } |
|
125 | + } |
|
126 | 126 | |
127 | - /** |
|
128 | - * Creates a course |
|
129 | - * |
|
130 | - * @param string API secret key |
|
131 | - * @param string Title |
|
132 | - * @param string Category code |
|
133 | - * @param string Wanted code. If it's not defined, it will be generated automatically |
|
134 | - * @param string Tutor name |
|
135 | - * @param string Course admin user id field name |
|
136 | - * @param string Course admin user id value |
|
137 | - * @param string Course language |
|
138 | - * @param string Course id field name |
|
139 | - * @param string Course id value |
|
140 | - * @param array Course extra fields |
|
141 | - * @return int Course id generated |
|
142 | - */ |
|
143 | - public function CreateCourse($secret_key, $title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras) { |
|
144 | - // First, verify the secret key |
|
145 | - $verifKey = $this->verifyKey($secret_key); |
|
146 | - if($verifKey instanceof WSError) { |
|
147 | - $this->handleError($verifKey); |
|
148 | - } else { |
|
149 | - $result = $this->createCourseHelper($title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras); |
|
150 | - if($result instanceof WSError) { |
|
151 | - $this->handleError($result); |
|
152 | - } else { |
|
153 | - return $result; |
|
154 | - } |
|
155 | - } |
|
156 | - } |
|
127 | + /** |
|
128 | + * Creates a course |
|
129 | + * |
|
130 | + * @param string API secret key |
|
131 | + * @param string Title |
|
132 | + * @param string Category code |
|
133 | + * @param string Wanted code. If it's not defined, it will be generated automatically |
|
134 | + * @param string Tutor name |
|
135 | + * @param string Course admin user id field name |
|
136 | + * @param string Course admin user id value |
|
137 | + * @param string Course language |
|
138 | + * @param string Course id field name |
|
139 | + * @param string Course id value |
|
140 | + * @param array Course extra fields |
|
141 | + * @return int Course id generated |
|
142 | + */ |
|
143 | + public function CreateCourse($secret_key, $title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras) { |
|
144 | + // First, verify the secret key |
|
145 | + $verifKey = $this->verifyKey($secret_key); |
|
146 | + if($verifKey instanceof WSError) { |
|
147 | + $this->handleError($verifKey); |
|
148 | + } else { |
|
149 | + $result = $this->createCourseHelper($title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras); |
|
150 | + if($result instanceof WSError) { |
|
151 | + $this->handleError($result); |
|
152 | + } else { |
|
153 | + return $result; |
|
154 | + } |
|
155 | + } |
|
156 | + } |
|
157 | 157 | |
158 | - /** |
|
159 | - * Create multiple courses |
|
160 | - * |
|
161 | - * @param string API secret key |
|
162 | - * @param array Courses to be created, with elements following the structure presented in CreateCourse |
|
163 | - * @return array Array with elements of the form array('course_id_value' => 'original value sent', 'course_id_generated' => 'value_generated', 'result' => array('code' => 0, 'message' => 'Operation was successful')) |
|
164 | - */ |
|
165 | - public function CreateCourses($secret_key, $courses) { |
|
166 | - // First, verify the secret key |
|
167 | - $verifKey = $this->verifyKey($secret_key); |
|
168 | - if($verifKey instanceof WSError) { |
|
169 | - $this->handleError($verifKey); |
|
170 | - } else { |
|
171 | - $results = array(); |
|
172 | - foreach($courses as $course) { |
|
173 | - $result_tmp = array(); |
|
158 | + /** |
|
159 | + * Create multiple courses |
|
160 | + * |
|
161 | + * @param string API secret key |
|
162 | + * @param array Courses to be created, with elements following the structure presented in CreateCourse |
|
163 | + * @return array Array with elements of the form array('course_id_value' => 'original value sent', 'course_id_generated' => 'value_generated', 'result' => array('code' => 0, 'message' => 'Operation was successful')) |
|
164 | + */ |
|
165 | + public function CreateCourses($secret_key, $courses) { |
|
166 | + // First, verify the secret key |
|
167 | + $verifKey = $this->verifyKey($secret_key); |
|
168 | + if($verifKey instanceof WSError) { |
|
169 | + $this->handleError($verifKey); |
|
170 | + } else { |
|
171 | + $results = array(); |
|
172 | + foreach($courses as $course) { |
|
173 | + $result_tmp = array(); |
|
174 | 174 | // re-initialize variables just in case |
175 | 175 | $title = $category_code = $wanted_code = $tutor_name = $course_admin_user_id_field_name = $course_admin_user_id_value = $language = $course_id_field_name = $course_id_value = $extras = 0; |
176 | - extract($course); |
|
177 | - $result = $this->createCourseHelper($title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras); |
|
178 | - if($result instanceof WSError) { |
|
179 | - $result_tmp['result'] = $result->toArray(); |
|
180 | - $result_tmp['course_id_value'] = $course_id_value; |
|
181 | - $result_tmp['course_id_generated'] = 0; |
|
182 | - } else { |
|
183 | - $result_tmp['result'] = $this->getSuccessfulResult(); |
|
184 | - $result_tmp['course_id_value'] = $course_id_value; |
|
185 | - $result_tmp['course_id_generated'] = $result; |
|
186 | - } |
|
187 | - $results[] = $result_tmp; |
|
188 | - } |
|
189 | - return $results; |
|
190 | - } |
|
191 | - } |
|
176 | + extract($course); |
|
177 | + $result = $this->createCourseHelper($title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras); |
|
178 | + if($result instanceof WSError) { |
|
179 | + $result_tmp['result'] = $result->toArray(); |
|
180 | + $result_tmp['course_id_value'] = $course_id_value; |
|
181 | + $result_tmp['course_id_generated'] = 0; |
|
182 | + } else { |
|
183 | + $result_tmp['result'] = $this->getSuccessfulResult(); |
|
184 | + $result_tmp['course_id_value'] = $course_id_value; |
|
185 | + $result_tmp['course_id_generated'] = $result; |
|
186 | + } |
|
187 | + $results[] = $result_tmp; |
|
188 | + } |
|
189 | + return $results; |
|
190 | + } |
|
191 | + } |
|
192 | 192 | |
193 | - /** |
|
194 | - * Edits a course (helper method) |
|
195 | - * |
|
196 | - * @param string Course id field name |
|
197 | - * @param string Course id value |
|
198 | - * @param string Title |
|
199 | - * @param string Category code |
|
200 | - * @param string Department name |
|
201 | - * @param string Department url |
|
202 | - * @param string Course language |
|
203 | - * @param int Visibility |
|
204 | - * @param int Subscribe (0 = denied, 1 = allowed) |
|
205 | - * @param int Unsubscribe (0 = denied, 1 = allowed) |
|
206 | - * @param string Visual code |
|
207 | - * @param array Course extra fields |
|
208 | - * @return mixed True in case of success, WSError otherwise |
|
209 | - */ |
|
210 | - protected function editCourseHelper($course_id_field_name, $course_id_value, $title, $category_code, $department_name, $department_url, $language, $visibility, $subscribe, $unsubscribe, $visual_code, $extras) { |
|
211 | - $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
|
212 | - if($course_id instanceof WSError) { |
|
213 | - return $course_id; |
|
214 | - } else { |
|
215 | - $attributes = array(); |
|
216 | - if(!empty($title)) { |
|
217 | - $attributes['title'] = $title; |
|
218 | - } |
|
219 | - if(!empty($category_code)) { |
|
220 | - $attributes['category_code'] = $category_code; |
|
221 | - } |
|
222 | - if(!empty($department_name)) { |
|
223 | - $attributes['department_name'] = $department_name; |
|
224 | - } |
|
225 | - if(!empty($department_url)) { |
|
226 | - $attributes['department_url'] = $department_url; |
|
227 | - } |
|
228 | - if(!empty($language)) { |
|
229 | - $attributes['course_language'] = $language; |
|
230 | - } |
|
231 | - if($visibility != '') { |
|
232 | - $attributes['visibility'] = (int)$visibility; |
|
233 | - } |
|
234 | - if($subscribe != '') { |
|
235 | - $attributes['subscribe'] = (int)$subscribe; |
|
236 | - } |
|
237 | - if($unsubscribe != '') { |
|
238 | - $attributes['unsubscribe'] = (int)$unsubscribe; |
|
239 | - } |
|
240 | - if(!empty($visual_code)) { |
|
241 | - $attributes['visual_code'] = $visual_code; |
|
242 | - } |
|
243 | - if(!empty($attributes)) { |
|
244 | - CourseManager::update_attributes($course_id, $attributes); |
|
245 | - } |
|
246 | - if(!empty($extras)) { |
|
247 | - $course_code = CourseManager::get_course_code_from_course_id($course_id); |
|
248 | - $extras_associative = array(); |
|
249 | - foreach($extras as $extra) { |
|
250 | - $extras_associative[$extra['field_name']] = $extra['field_value']; |
|
251 | - } |
|
252 | - foreach($extras_associative as $fname => $fvalue) { |
|
253 | - CourseManager::update_extra_field_value($course_code, $fname, $fvalue); |
|
254 | - } |
|
255 | - } |
|
256 | - return true; |
|
257 | - } |
|
258 | - } |
|
193 | + /** |
|
194 | + * Edits a course (helper method) |
|
195 | + * |
|
196 | + * @param string Course id field name |
|
197 | + * @param string Course id value |
|
198 | + * @param string Title |
|
199 | + * @param string Category code |
|
200 | + * @param string Department name |
|
201 | + * @param string Department url |
|
202 | + * @param string Course language |
|
203 | + * @param int Visibility |
|
204 | + * @param int Subscribe (0 = denied, 1 = allowed) |
|
205 | + * @param int Unsubscribe (0 = denied, 1 = allowed) |
|
206 | + * @param string Visual code |
|
207 | + * @param array Course extra fields |
|
208 | + * @return mixed True in case of success, WSError otherwise |
|
209 | + */ |
|
210 | + protected function editCourseHelper($course_id_field_name, $course_id_value, $title, $category_code, $department_name, $department_url, $language, $visibility, $subscribe, $unsubscribe, $visual_code, $extras) { |
|
211 | + $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
|
212 | + if($course_id instanceof WSError) { |
|
213 | + return $course_id; |
|
214 | + } else { |
|
215 | + $attributes = array(); |
|
216 | + if(!empty($title)) { |
|
217 | + $attributes['title'] = $title; |
|
218 | + } |
|
219 | + if(!empty($category_code)) { |
|
220 | + $attributes['category_code'] = $category_code; |
|
221 | + } |
|
222 | + if(!empty($department_name)) { |
|
223 | + $attributes['department_name'] = $department_name; |
|
224 | + } |
|
225 | + if(!empty($department_url)) { |
|
226 | + $attributes['department_url'] = $department_url; |
|
227 | + } |
|
228 | + if(!empty($language)) { |
|
229 | + $attributes['course_language'] = $language; |
|
230 | + } |
|
231 | + if($visibility != '') { |
|
232 | + $attributes['visibility'] = (int)$visibility; |
|
233 | + } |
|
234 | + if($subscribe != '') { |
|
235 | + $attributes['subscribe'] = (int)$subscribe; |
|
236 | + } |
|
237 | + if($unsubscribe != '') { |
|
238 | + $attributes['unsubscribe'] = (int)$unsubscribe; |
|
239 | + } |
|
240 | + if(!empty($visual_code)) { |
|
241 | + $attributes['visual_code'] = $visual_code; |
|
242 | + } |
|
243 | + if(!empty($attributes)) { |
|
244 | + CourseManager::update_attributes($course_id, $attributes); |
|
245 | + } |
|
246 | + if(!empty($extras)) { |
|
247 | + $course_code = CourseManager::get_course_code_from_course_id($course_id); |
|
248 | + $extras_associative = array(); |
|
249 | + foreach($extras as $extra) { |
|
250 | + $extras_associative[$extra['field_name']] = $extra['field_value']; |
|
251 | + } |
|
252 | + foreach($extras_associative as $fname => $fvalue) { |
|
253 | + CourseManager::update_extra_field_value($course_code, $fname, $fvalue); |
|
254 | + } |
|
255 | + } |
|
256 | + return true; |
|
257 | + } |
|
258 | + } |
|
259 | 259 | |
260 | - /** |
|
261 | - * Edits a course |
|
262 | - * |
|
263 | - * @param string API secret key |
|
264 | - * @param string Course id field name |
|
265 | - * @param string Course id value |
|
266 | - * @param string Title |
|
267 | - * @param string Category code |
|
268 | - * @param string Department name |
|
269 | - * @param string Department url |
|
270 | - * @param string Course language |
|
271 | - * @param int Visibility |
|
272 | - * @param int Subscribe (0 = denied, 1 = allowed) |
|
273 | - * @param int Unsubscribe (0 = denied, 1 = allowed) |
|
274 | - * @param string Visual code |
|
275 | - * @param array Course extra fields |
|
276 | - */ |
|
277 | - public function EditCourse($secret_key, $course_id_field_name, $course_id_value, $title, $category_code, $department_name, $department_url, $language, $visibility, $subscribe, $unsubscribe, $visual_code, $extras) { |
|
278 | - $verifKey = $this->verifyKey($secret_key); |
|
279 | - if($verifKey instanceof WSError) { |
|
280 | - $this->handleError($verifKey); |
|
281 | - } else { |
|
282 | - $result = $this->editCourseHelper($course_id_field_name, $course_id_value, $title, $category_code, $department_name, $department_url, $language, $visibility, $subscribe, $unsubscribe, $visual_code, $extras); |
|
283 | - if($result instanceof WSError) { |
|
284 | - $this->handleError($result); |
|
285 | - } |
|
286 | - } |
|
287 | - } |
|
260 | + /** |
|
261 | + * Edits a course |
|
262 | + * |
|
263 | + * @param string API secret key |
|
264 | + * @param string Course id field name |
|
265 | + * @param string Course id value |
|
266 | + * @param string Title |
|
267 | + * @param string Category code |
|
268 | + * @param string Department name |
|
269 | + * @param string Department url |
|
270 | + * @param string Course language |
|
271 | + * @param int Visibility |
|
272 | + * @param int Subscribe (0 = denied, 1 = allowed) |
|
273 | + * @param int Unsubscribe (0 = denied, 1 = allowed) |
|
274 | + * @param string Visual code |
|
275 | + * @param array Course extra fields |
|
276 | + */ |
|
277 | + public function EditCourse($secret_key, $course_id_field_name, $course_id_value, $title, $category_code, $department_name, $department_url, $language, $visibility, $subscribe, $unsubscribe, $visual_code, $extras) { |
|
278 | + $verifKey = $this->verifyKey($secret_key); |
|
279 | + if($verifKey instanceof WSError) { |
|
280 | + $this->handleError($verifKey); |
|
281 | + } else { |
|
282 | + $result = $this->editCourseHelper($course_id_field_name, $course_id_value, $title, $category_code, $department_name, $department_url, $language, $visibility, $subscribe, $unsubscribe, $visual_code, $extras); |
|
283 | + if($result instanceof WSError) { |
|
284 | + $this->handleError($result); |
|
285 | + } |
|
286 | + } |
|
287 | + } |
|
288 | 288 | |
289 | - /** |
|
290 | - * List courses |
|
291 | - * |
|
292 | - * @param string API secret key |
|
293 | - * @param string A list of visibility filter we want to apply |
|
294 | - * @return array An array with elements of the form ('id' => 'Course internal id', 'code' => 'Course code', 'title' => 'Course title', 'language' => 'Course language', 'visibility' => 'Course visibility', |
|
295 | - * 'category_name' => 'Name of the category of the course', 'number_students' => 'Number of students in the course', 'external_course_id' => 'External course id') |
|
296 | - */ |
|
297 | - public function ListCourses($secret_key, $visibility = 'public,public-registered,private,closed') { |
|
298 | - $verifKey = $this->verifyKey($secret_key); |
|
299 | - if($verifKey instanceof WSError) { |
|
300 | - $this->handleError($verifKey); |
|
301 | - } else { |
|
289 | + /** |
|
290 | + * List courses |
|
291 | + * |
|
292 | + * @param string API secret key |
|
293 | + * @param string A list of visibility filter we want to apply |
|
294 | + * @return array An array with elements of the form ('id' => 'Course internal id', 'code' => 'Course code', 'title' => 'Course title', 'language' => 'Course language', 'visibility' => 'Course visibility', |
|
295 | + * 'category_name' => 'Name of the category of the course', 'number_students' => 'Number of students in the course', 'external_course_id' => 'External course id') |
|
296 | + */ |
|
297 | + public function ListCourses($secret_key, $visibility = 'public,public-registered,private,closed') { |
|
298 | + $verifKey = $this->verifyKey($secret_key); |
|
299 | + if($verifKey instanceof WSError) { |
|
300 | + $this->handleError($verifKey); |
|
301 | + } else { |
|
302 | 302 | $visibilities = split(',',$visibility); |
303 | 303 | $vis = array('public' => '3', 'public-registered' => '2', 'private' => '1', 'closed' => '0'); |
304 | 304 | foreach ($visibilities as $p => $visibility) { |
305 | 305 | $visibilities[$p] = $vis[$visibility]; |
306 | 306 | } |
307 | - $courses_result = array(); |
|
308 | - $category_names = array(); |
|
307 | + $courses_result = array(); |
|
308 | + $category_names = array(); |
|
309 | 309 | |
310 | - $courses = CourseManager::get_courses_list(); |
|
311 | - foreach($courses as $course) { |
|
310 | + $courses = CourseManager::get_courses_list(); |
|
311 | + foreach($courses as $course) { |
|
312 | 312 | //skip elements that do not match required visibility |
313 | 313 | if (!in_array($course['visibility'],$visibilities)) { continue; } |
314 | - $course_tmp = array(); |
|
315 | - $course_tmp['id'] = $course['id']; |
|
316 | - $course_tmp['code'] = $course['code']; |
|
317 | - $course_tmp['title'] = $course['title']; |
|
318 | - $course_tmp['language'] = $course['course_language']; |
|
319 | - $course_tmp['visibility'] = $course['visibility']; |
|
314 | + $course_tmp = array(); |
|
315 | + $course_tmp['id'] = $course['id']; |
|
316 | + $course_tmp['code'] = $course['code']; |
|
317 | + $course_tmp['title'] = $course['title']; |
|
318 | + $course_tmp['language'] = $course['course_language']; |
|
319 | + $course_tmp['visibility'] = $course['visibility']; |
|
320 | 320 | |
321 | - // Determining category name |
|
322 | - if($category_names[$course['category_code']]) { |
|
323 | - $course_tmp['category_name'] = $category_names[$course['category_code']]; |
|
324 | - } else { |
|
325 | - $category = CourseManager::get_course_category($course['category_code']); |
|
326 | - $category_names[$course['category_code']] = $category['name']; |
|
327 | - $course_tmp['category_name'] = $category['name']; |
|
328 | - } |
|
321 | + // Determining category name |
|
322 | + if($category_names[$course['category_code']]) { |
|
323 | + $course_tmp['category_name'] = $category_names[$course['category_code']]; |
|
324 | + } else { |
|
325 | + $category = CourseManager::get_course_category($course['category_code']); |
|
326 | + $category_names[$course['category_code']] = $category['name']; |
|
327 | + $course_tmp['category_name'] = $category['name']; |
|
328 | + } |
|
329 | 329 | |
330 | - // Determining number of students registered in course |
|
331 | - $user_list = CourseManager::get_user_list_from_course_code($course['code'], 0); |
|
332 | - $course_tmp['number_students'] = count($user_list); |
|
330 | + // Determining number of students registered in course |
|
331 | + $user_list = CourseManager::get_user_list_from_course_code($course['code'], 0); |
|
332 | + $course_tmp['number_students'] = count($user_list); |
|
333 | 333 | |
334 | - // Determining external course id - this code misses the external course id field name |
|
335 | - // $course_tmp['external_course_id'] = CourseManager::get_course_extra_field_value($course_field_name, $course['code']); |
|
334 | + // Determining external course id - this code misses the external course id field name |
|
335 | + // $course_tmp['external_course_id'] = CourseManager::get_course_extra_field_value($course_field_name, $course['code']); |
|
336 | 336 | |
337 | 337 | |
338 | - $courses_result[] = $course_tmp; |
|
339 | - } |
|
338 | + $courses_result[] = $course_tmp; |
|
339 | + } |
|
340 | 340 | |
341 | - return $courses_result; |
|
342 | - } |
|
343 | - } |
|
341 | + return $courses_result; |
|
342 | + } |
|
343 | + } |
|
344 | 344 | |
345 | - /** |
|
346 | - * Subscribe or unsubscribe user to a course (helper method) |
|
347 | - * |
|
348 | - * @param string Course id field name. Use "chamilo_course_id" to use internal id |
|
349 | - * @param string Course id value. |
|
350 | - * @param string User id field name. Use "chamilo_user_id" to use internal id |
|
351 | - * @param string User id value |
|
352 | - * @param int Set to 1 to subscribe, 0 to unsubscribe |
|
353 | - * @param int Status (STUDENT or TEACHER) Used for subscription only |
|
354 | - * @return mixed True if subscription or unsubscription was successful, false otherwise |
|
355 | - */ |
|
356 | - protected function changeUserSubscription($course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, $state, $status = STUDENT) { |
|
357 | - $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
|
358 | - if($course_id instanceof WSError) { |
|
359 | - return $course_id; |
|
360 | - } else { |
|
361 | - $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
|
362 | - if($user_id instanceof WSError) { |
|
363 | - return $user_id; |
|
364 | - } else { |
|
365 | - $course_code = CourseManager::get_course_code_from_course_id($course_id); |
|
366 | - if($state == 0) { |
|
367 | - // Unsubscribe user |
|
368 | - CourseManager::unsubscribe_user($user_id, $course_code); |
|
369 | - return true; |
|
370 | - } else { |
|
371 | - // Subscribe user |
|
372 | - if(CourseManager::subscribe_user($user_id, $course_code, $status)) { |
|
373 | - return true; |
|
374 | - } else { |
|
375 | - return new WSError(203, 'An error occured subscribing to this course'); |
|
376 | - } |
|
377 | - } |
|
378 | - } |
|
379 | - } |
|
380 | - } |
|
345 | + /** |
|
346 | + * Subscribe or unsubscribe user to a course (helper method) |
|
347 | + * |
|
348 | + * @param string Course id field name. Use "chamilo_course_id" to use internal id |
|
349 | + * @param string Course id value. |
|
350 | + * @param string User id field name. Use "chamilo_user_id" to use internal id |
|
351 | + * @param string User id value |
|
352 | + * @param int Set to 1 to subscribe, 0 to unsubscribe |
|
353 | + * @param int Status (STUDENT or TEACHER) Used for subscription only |
|
354 | + * @return mixed True if subscription or unsubscription was successful, false otherwise |
|
355 | + */ |
|
356 | + protected function changeUserSubscription($course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, $state, $status = STUDENT) { |
|
357 | + $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
|
358 | + if($course_id instanceof WSError) { |
|
359 | + return $course_id; |
|
360 | + } else { |
|
361 | + $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
|
362 | + if($user_id instanceof WSError) { |
|
363 | + return $user_id; |
|
364 | + } else { |
|
365 | + $course_code = CourseManager::get_course_code_from_course_id($course_id); |
|
366 | + if($state == 0) { |
|
367 | + // Unsubscribe user |
|
368 | + CourseManager::unsubscribe_user($user_id, $course_code); |
|
369 | + return true; |
|
370 | + } else { |
|
371 | + // Subscribe user |
|
372 | + if(CourseManager::subscribe_user($user_id, $course_code, $status)) { |
|
373 | + return true; |
|
374 | + } else { |
|
375 | + return new WSError(203, 'An error occured subscribing to this course'); |
|
376 | + } |
|
377 | + } |
|
378 | + } |
|
379 | + } |
|
380 | + } |
|
381 | 381 | |
382 | - /** |
|
383 | - * Subscribe user to a course |
|
384 | - * |
|
385 | - * @param string API secret key |
|
386 | - * @param string Course id field name. Use "chamilo_course_id" to use internal id |
|
387 | - * @param string Course id value. |
|
388 | - * @param string User id field name. Use "chamilo_user_id" to use internal id |
|
389 | - * @param string User id value |
|
390 | - * @param int Status (1 = Teacher, 5 = Student) |
|
391 | - */ |
|
392 | - public function SubscribeUserToCourse($secret_key, $course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, $status) { |
|
393 | - $verifKey = $this->verifyKey($secret_key); |
|
394 | - if($verifKey instanceof WSError) { |
|
395 | - $this->handleError($verifKey); |
|
396 | - } else { |
|
397 | - $result = $this->changeUserSubscription($course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, 1, $status); |
|
398 | - if($result instanceof WSError) { |
|
399 | - $this->handleError($result); |
|
400 | - } |
|
401 | - } |
|
402 | - } |
|
382 | + /** |
|
383 | + * Subscribe user to a course |
|
384 | + * |
|
385 | + * @param string API secret key |
|
386 | + * @param string Course id field name. Use "chamilo_course_id" to use internal id |
|
387 | + * @param string Course id value. |
|
388 | + * @param string User id field name. Use "chamilo_user_id" to use internal id |
|
389 | + * @param string User id value |
|
390 | + * @param int Status (1 = Teacher, 5 = Student) |
|
391 | + */ |
|
392 | + public function SubscribeUserToCourse($secret_key, $course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, $status) { |
|
393 | + $verifKey = $this->verifyKey($secret_key); |
|
394 | + if($verifKey instanceof WSError) { |
|
395 | + $this->handleError($verifKey); |
|
396 | + } else { |
|
397 | + $result = $this->changeUserSubscription($course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, 1, $status); |
|
398 | + if($result instanceof WSError) { |
|
399 | + $this->handleError($result); |
|
400 | + } |
|
401 | + } |
|
402 | + } |
|
403 | 403 | |
404 | - /** |
|
405 | - * Unsusbscribe user from course |
|
406 | - * |
|
407 | - * @param string API secret key |
|
408 | - * @param string Course id field name. Use "chamilo_course_id" to use internal id |
|
409 | - * @param string Course id value. |
|
410 | - * @param string User id field name. Use "chamilo_user_id" to use internal id |
|
411 | - * @param string User id value |
|
412 | - */ |
|
413 | - public function UnsubscribeUserFromCourse($secret_key, $course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value) { |
|
414 | - $verifKey = $this->verifyKey($secret_key); |
|
415 | - if($verifKey instanceof WSError) { |
|
416 | - $this->handleError($verifKey); |
|
417 | - } else { |
|
418 | - $result = $this->changeUserSubscription($course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, 0); |
|
419 | - if($result instanceof WSError) { |
|
420 | - $this->handleError($result); |
|
421 | - } |
|
422 | - } |
|
423 | - } |
|
404 | + /** |
|
405 | + * Unsusbscribe user from course |
|
406 | + * |
|
407 | + * @param string API secret key |
|
408 | + * @param string Course id field name. Use "chamilo_course_id" to use internal id |
|
409 | + * @param string Course id value. |
|
410 | + * @param string User id field name. Use "chamilo_user_id" to use internal id |
|
411 | + * @param string User id value |
|
412 | + */ |
|
413 | + public function UnsubscribeUserFromCourse($secret_key, $course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value) { |
|
414 | + $verifKey = $this->verifyKey($secret_key); |
|
415 | + if($verifKey instanceof WSError) { |
|
416 | + $this->handleError($verifKey); |
|
417 | + } else { |
|
418 | + $result = $this->changeUserSubscription($course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, 0); |
|
419 | + if($result instanceof WSError) { |
|
420 | + $this->handleError($result); |
|
421 | + } |
|
422 | + } |
|
423 | + } |
|
424 | 424 | |
425 | - /** |
|
426 | - * Returns the descriptions of a course, along with their id |
|
427 | - * |
|
428 | - * @param string API secret key |
|
429 | - * @param string Course id field name |
|
430 | - * @param string Course id value |
|
431 | - * @return array Returns an array with elements of the form ('course_desc_id' => 1, 'course_desc_title' => 'Title', 'course_desc_content' => 'Content') |
|
432 | - */ |
|
433 | - public function GetCourseDescriptions($secret_key, $course_id_field_name, $course_id_value) { |
|
434 | - $verifKey = $this->verifyKey($secret_key); |
|
435 | - if($verifKey instanceof WSError) { |
|
436 | - $this->handleError($verifKey); |
|
437 | - } else { |
|
438 | - $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
|
439 | - if($course_id instanceof WSError) { |
|
440 | - return $course_id; |
|
441 | - } else { |
|
442 | - // Course exists, get its descriptions |
|
443 | - $descriptions = CourseDescription::get_descriptions($course_id); |
|
444 | - $results = array(); |
|
445 | - foreach($descriptions as $description) { |
|
446 | - $results[] = array('course_desc_id' => $description->get_description_type(), |
|
447 | - 'course_desc_title' => $description->get_title(), |
|
448 | - 'course_desc_content' => $description->get_content()); |
|
449 | - } |
|
450 | - return $results; |
|
451 | - } |
|
452 | - } |
|
453 | - } |
|
425 | + /** |
|
426 | + * Returns the descriptions of a course, along with their id |
|
427 | + * |
|
428 | + * @param string API secret key |
|
429 | + * @param string Course id field name |
|
430 | + * @param string Course id value |
|
431 | + * @return array Returns an array with elements of the form ('course_desc_id' => 1, 'course_desc_title' => 'Title', 'course_desc_content' => 'Content') |
|
432 | + */ |
|
433 | + public function GetCourseDescriptions($secret_key, $course_id_field_name, $course_id_value) { |
|
434 | + $verifKey = $this->verifyKey($secret_key); |
|
435 | + if($verifKey instanceof WSError) { |
|
436 | + $this->handleError($verifKey); |
|
437 | + } else { |
|
438 | + $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
|
439 | + if($course_id instanceof WSError) { |
|
440 | + return $course_id; |
|
441 | + } else { |
|
442 | + // Course exists, get its descriptions |
|
443 | + $descriptions = CourseDescription::get_descriptions($course_id); |
|
444 | + $results = array(); |
|
445 | + foreach($descriptions as $description) { |
|
446 | + $results[] = array('course_desc_id' => $description->get_description_type(), |
|
447 | + 'course_desc_title' => $description->get_title(), |
|
448 | + 'course_desc_content' => $description->get_content()); |
|
449 | + } |
|
450 | + return $results; |
|
451 | + } |
|
452 | + } |
|
453 | + } |
|
454 | 454 | |
455 | 455 | |
456 | - /** |
|
457 | - * Edit course description |
|
458 | - * |
|
459 | - * @param string API secret key |
|
460 | - * @param string Course id field name |
|
461 | - * @param string Course id value |
|
462 | - * @param int Category id from course description |
|
463 | - * @param string Description title |
|
464 | - * @param string Course description content |
|
465 | - */ |
|
466 | - public function EditCourseDescription($secret_key, $course_id_field_name, $course_id_value, $course_desc_id, $course_desc_title, $course_desc_content) { |
|
467 | - $verifKey = $this->verifyKey($secret_key); |
|
468 | - if($verifKey instanceof WSError) { |
|
469 | - $this->handleError($verifKey); |
|
470 | - } else { |
|
471 | - $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
|
472 | - if($course_id instanceof WSError) { |
|
473 | - return $course_id; |
|
474 | - } else { |
|
475 | - // Create the new course description |
|
476 | - $cd = new CourseDescription(); |
|
477 | - $cd->set_description_type($course_desc_id); |
|
478 | - $cd->set_title($course_desc_title); |
|
479 | - $cd->set_content($course_desc_content); |
|
480 | - $cd->set_session_id(0); |
|
481 | - // Get course info |
|
482 | - $course_info = CourseManager::get_course_information(CourseManager::get_course_code_from_course_id($course_id)); |
|
456 | + /** |
|
457 | + * Edit course description |
|
458 | + * |
|
459 | + * @param string API secret key |
|
460 | + * @param string Course id field name |
|
461 | + * @param string Course id value |
|
462 | + * @param int Category id from course description |
|
463 | + * @param string Description title |
|
464 | + * @param string Course description content |
|
465 | + */ |
|
466 | + public function EditCourseDescription($secret_key, $course_id_field_name, $course_id_value, $course_desc_id, $course_desc_title, $course_desc_content) { |
|
467 | + $verifKey = $this->verifyKey($secret_key); |
|
468 | + if($verifKey instanceof WSError) { |
|
469 | + $this->handleError($verifKey); |
|
470 | + } else { |
|
471 | + $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
|
472 | + if($course_id instanceof WSError) { |
|
473 | + return $course_id; |
|
474 | + } else { |
|
475 | + // Create the new course description |
|
476 | + $cd = new CourseDescription(); |
|
477 | + $cd->set_description_type($course_desc_id); |
|
478 | + $cd->set_title($course_desc_title); |
|
479 | + $cd->set_content($course_desc_content); |
|
480 | + $cd->set_session_id(0); |
|
481 | + // Get course info |
|
482 | + $course_info = CourseManager::get_course_information(CourseManager::get_course_code_from_course_id($course_id)); |
|
483 | 483 | $cd->set_course_id($course_info['real_id']); |
484 | - // Check if this course description exists |
|
485 | - $descriptions = CourseDescription::get_descriptions($course_id); |
|
486 | - $exists = false; |
|
487 | - foreach($descriptions as $description) { |
|
488 | - if($description->get_description_type() == $course_desc_id) { |
|
489 | - $exists = true; |
|
490 | - } |
|
491 | - } |
|
492 | - if (!$exists) { |
|
493 | - $cd->set_progress(0); |
|
494 | - $cd->insert(); |
|
495 | - } else { |
|
496 | - $cd->update(); |
|
497 | - } |
|
498 | - } |
|
499 | - } |
|
500 | - } |
|
484 | + // Check if this course description exists |
|
485 | + $descriptions = CourseDescription::get_descriptions($course_id); |
|
486 | + $exists = false; |
|
487 | + foreach($descriptions as $description) { |
|
488 | + if($description->get_description_type() == $course_desc_id) { |
|
489 | + $exists = true; |
|
490 | + } |
|
491 | + } |
|
492 | + if (!$exists) { |
|
493 | + $cd->set_progress(0); |
|
494 | + $cd->insert(); |
|
495 | + } else { |
|
496 | + $cd->update(); |
|
497 | + } |
|
498 | + } |
|
499 | + } |
|
500 | + } |
|
501 | 501 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | */ |
22 | 22 | protected function deleteCourseHelper($course_id_field_name, $course_id_value) { |
23 | 23 | $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
24 | - if($course_id instanceof WSError) { |
|
24 | + if ($course_id instanceof WSError) { |
|
25 | 25 | return $course_id; |
26 | 26 | } else { |
27 | 27 | $course_code = CourseManager::get_course_code_from_course_id($course_id); |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function DeleteCourse($secret_key, $course_id_field_name, $course_id_value) { |
41 | 41 | $verifKey = $this->verifyKey($secret_key); |
42 | - if($verifKey instanceof WSError) { |
|
42 | + if ($verifKey instanceof WSError) { |
|
43 | 43 | $this->handleError($verifKey); |
44 | 44 | } else { |
45 | 45 | $result = $this->deleteCourseHelper($course_id_field_name, $course_id_value); |
46 | - if($result instanceof WSError) { |
|
46 | + if ($result instanceof WSError) { |
|
47 | 47 | $this->handleError($result); |
48 | 48 | } |
49 | 49 | } |
@@ -59,15 +59,15 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function DeleteCourses($secret_key, $courses) { |
61 | 61 | $verifKey = $this->verifyKey($secret_key); |
62 | - if($verifKey instanceof WSError) { |
|
62 | + if ($verifKey instanceof WSError) { |
|
63 | 63 | $this->handleError($verifKey); |
64 | 64 | } else { |
65 | 65 | $results = array(); |
66 | - foreach($courses as $course) { |
|
66 | + foreach ($courses as $course) { |
|
67 | 67 | $result_tmp = array(); |
68 | 68 | $result_op = $this->deleteCourseHelper($course['course_id_field_name'], $course['course_id_value']); |
69 | 69 | $result_tmp['course_id_value'] = $course['course_id_value']; |
70 | - if($result_op instanceof WSError) { |
|
70 | + if ($result_op instanceof WSError) { |
|
71 | 71 | // Return the error in the results |
72 | 72 | $result_tmp['result'] = $result_op->toArray(); |
73 | 73 | } else { |
@@ -97,17 +97,17 @@ discard block |
||
97 | 97 | protected function createCourseHelper($title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras) { |
98 | 98 | // Add the original course id field name and value to the extra fields if needed |
99 | 99 | $extras_associative = array(); |
100 | - if($course_id_field_name != "chamilo_course_id") { |
|
100 | + if ($course_id_field_name != "chamilo_course_id") { |
|
101 | 101 | $extras_associative[$course_id_field_name] = $course_id_value; |
102 | 102 | } |
103 | - foreach($extras as $extra) { |
|
103 | + foreach ($extras as $extra) { |
|
104 | 104 | $extras_associative[$extra['field_name']] = $extra['field_value']; |
105 | 105 | } |
106 | 106 | $course_admin_id = $this->getUserId($course_admin_user_id_field_name, $course_admin_user_id_value); |
107 | - if($course_admin_id instanceof WSError) { |
|
107 | + if ($course_admin_id instanceof WSError) { |
|
108 | 108 | return $course_admin_id; |
109 | 109 | } |
110 | - if($wanted_code == '') { |
|
110 | + if ($wanted_code == '') { |
|
111 | 111 | $wanted_code = CourseManager::generate_course_code($title); |
112 | 112 | } |
113 | 113 | $result = create_course($wanted_code, $title, $tutor_name, $category_code, $language, $course_admin_id, $this->_configuration['db_prefix'], 0); |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | return new WSError(202, 'There was an error creating the course'); |
116 | 116 | } else { |
117 | 117 | // Update extra fields |
118 | - foreach($extras_associative as $fname => $fvalue) { |
|
118 | + foreach ($extras_associative as $fname => $fvalue) { |
|
119 | 119 | CourseManager::update_course_extra_field_value($result, $fname, $fvalue); |
120 | 120 | } |
121 | 121 | // Get course id |
@@ -143,11 +143,11 @@ discard block |
||
143 | 143 | public function CreateCourse($secret_key, $title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras) { |
144 | 144 | // First, verify the secret key |
145 | 145 | $verifKey = $this->verifyKey($secret_key); |
146 | - if($verifKey instanceof WSError) { |
|
146 | + if ($verifKey instanceof WSError) { |
|
147 | 147 | $this->handleError($verifKey); |
148 | 148 | } else { |
149 | 149 | $result = $this->createCourseHelper($title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras); |
150 | - if($result instanceof WSError) { |
|
150 | + if ($result instanceof WSError) { |
|
151 | 151 | $this->handleError($result); |
152 | 152 | } else { |
153 | 153 | return $result; |
@@ -165,17 +165,17 @@ discard block |
||
165 | 165 | public function CreateCourses($secret_key, $courses) { |
166 | 166 | // First, verify the secret key |
167 | 167 | $verifKey = $this->verifyKey($secret_key); |
168 | - if($verifKey instanceof WSError) { |
|
168 | + if ($verifKey instanceof WSError) { |
|
169 | 169 | $this->handleError($verifKey); |
170 | 170 | } else { |
171 | 171 | $results = array(); |
172 | - foreach($courses as $course) { |
|
172 | + foreach ($courses as $course) { |
|
173 | 173 | $result_tmp = array(); |
174 | 174 | // re-initialize variables just in case |
175 | 175 | $title = $category_code = $wanted_code = $tutor_name = $course_admin_user_id_field_name = $course_admin_user_id_value = $language = $course_id_field_name = $course_id_value = $extras = 0; |
176 | 176 | extract($course); |
177 | 177 | $result = $this->createCourseHelper($title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras); |
178 | - if($result instanceof WSError) { |
|
178 | + if ($result instanceof WSError) { |
|
179 | 179 | $result_tmp['result'] = $result->toArray(); |
180 | 180 | $result_tmp['course_id_value'] = $course_id_value; |
181 | 181 | $result_tmp['course_id_generated'] = 0; |
@@ -209,47 +209,47 @@ discard block |
||
209 | 209 | */ |
210 | 210 | protected function editCourseHelper($course_id_field_name, $course_id_value, $title, $category_code, $department_name, $department_url, $language, $visibility, $subscribe, $unsubscribe, $visual_code, $extras) { |
211 | 211 | $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
212 | - if($course_id instanceof WSError) { |
|
212 | + if ($course_id instanceof WSError) { |
|
213 | 213 | return $course_id; |
214 | 214 | } else { |
215 | 215 | $attributes = array(); |
216 | - if(!empty($title)) { |
|
216 | + if (!empty($title)) { |
|
217 | 217 | $attributes['title'] = $title; |
218 | 218 | } |
219 | - if(!empty($category_code)) { |
|
219 | + if (!empty($category_code)) { |
|
220 | 220 | $attributes['category_code'] = $category_code; |
221 | 221 | } |
222 | - if(!empty($department_name)) { |
|
222 | + if (!empty($department_name)) { |
|
223 | 223 | $attributes['department_name'] = $department_name; |
224 | 224 | } |
225 | - if(!empty($department_url)) { |
|
225 | + if (!empty($department_url)) { |
|
226 | 226 | $attributes['department_url'] = $department_url; |
227 | 227 | } |
228 | - if(!empty($language)) { |
|
228 | + if (!empty($language)) { |
|
229 | 229 | $attributes['course_language'] = $language; |
230 | 230 | } |
231 | - if($visibility != '') { |
|
232 | - $attributes['visibility'] = (int)$visibility; |
|
231 | + if ($visibility != '') { |
|
232 | + $attributes['visibility'] = (int) $visibility; |
|
233 | 233 | } |
234 | - if($subscribe != '') { |
|
235 | - $attributes['subscribe'] = (int)$subscribe; |
|
234 | + if ($subscribe != '') { |
|
235 | + $attributes['subscribe'] = (int) $subscribe; |
|
236 | 236 | } |
237 | - if($unsubscribe != '') { |
|
238 | - $attributes['unsubscribe'] = (int)$unsubscribe; |
|
237 | + if ($unsubscribe != '') { |
|
238 | + $attributes['unsubscribe'] = (int) $unsubscribe; |
|
239 | 239 | } |
240 | - if(!empty($visual_code)) { |
|
240 | + if (!empty($visual_code)) { |
|
241 | 241 | $attributes['visual_code'] = $visual_code; |
242 | 242 | } |
243 | - if(!empty($attributes)) { |
|
243 | + if (!empty($attributes)) { |
|
244 | 244 | CourseManager::update_attributes($course_id, $attributes); |
245 | 245 | } |
246 | - if(!empty($extras)) { |
|
246 | + if (!empty($extras)) { |
|
247 | 247 | $course_code = CourseManager::get_course_code_from_course_id($course_id); |
248 | 248 | $extras_associative = array(); |
249 | - foreach($extras as $extra) { |
|
249 | + foreach ($extras as $extra) { |
|
250 | 250 | $extras_associative[$extra['field_name']] = $extra['field_value']; |
251 | 251 | } |
252 | - foreach($extras_associative as $fname => $fvalue) { |
|
252 | + foreach ($extras_associative as $fname => $fvalue) { |
|
253 | 253 | CourseManager::update_extra_field_value($course_code, $fname, $fvalue); |
254 | 254 | } |
255 | 255 | } |
@@ -276,11 +276,11 @@ discard block |
||
276 | 276 | */ |
277 | 277 | public function EditCourse($secret_key, $course_id_field_name, $course_id_value, $title, $category_code, $department_name, $department_url, $language, $visibility, $subscribe, $unsubscribe, $visual_code, $extras) { |
278 | 278 | $verifKey = $this->verifyKey($secret_key); |
279 | - if($verifKey instanceof WSError) { |
|
279 | + if ($verifKey instanceof WSError) { |
|
280 | 280 | $this->handleError($verifKey); |
281 | 281 | } else { |
282 | 282 | $result = $this->editCourseHelper($course_id_field_name, $course_id_value, $title, $category_code, $department_name, $department_url, $language, $visibility, $subscribe, $unsubscribe, $visual_code, $extras); |
283 | - if($result instanceof WSError) { |
|
283 | + if ($result instanceof WSError) { |
|
284 | 284 | $this->handleError($result); |
285 | 285 | } |
286 | 286 | } |
@@ -296,10 +296,10 @@ discard block |
||
296 | 296 | */ |
297 | 297 | public function ListCourses($secret_key, $visibility = 'public,public-registered,private,closed') { |
298 | 298 | $verifKey = $this->verifyKey($secret_key); |
299 | - if($verifKey instanceof WSError) { |
|
299 | + if ($verifKey instanceof WSError) { |
|
300 | 300 | $this->handleError($verifKey); |
301 | 301 | } else { |
302 | - $visibilities = split(',',$visibility); |
|
302 | + $visibilities = split(',', $visibility); |
|
303 | 303 | $vis = array('public' => '3', 'public-registered' => '2', 'private' => '1', 'closed' => '0'); |
304 | 304 | foreach ($visibilities as $p => $visibility) { |
305 | 305 | $visibilities[$p] = $vis[$visibility]; |
@@ -308,9 +308,9 @@ discard block |
||
308 | 308 | $category_names = array(); |
309 | 309 | |
310 | 310 | $courses = CourseManager::get_courses_list(); |
311 | - foreach($courses as $course) { |
|
311 | + foreach ($courses as $course) { |
|
312 | 312 | //skip elements that do not match required visibility |
313 | - if (!in_array($course['visibility'],$visibilities)) { continue; } |
|
313 | + if (!in_array($course['visibility'], $visibilities)) { continue; } |
|
314 | 314 | $course_tmp = array(); |
315 | 315 | $course_tmp['id'] = $course['id']; |
316 | 316 | $course_tmp['code'] = $course['code']; |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | $course_tmp['visibility'] = $course['visibility']; |
320 | 320 | |
321 | 321 | // Determining category name |
322 | - if($category_names[$course['category_code']]) { |
|
322 | + if ($category_names[$course['category_code']]) { |
|
323 | 323 | $course_tmp['category_name'] = $category_names[$course['category_code']]; |
324 | 324 | } else { |
325 | 325 | $category = CourseManager::get_course_category($course['category_code']); |
@@ -355,21 +355,21 @@ discard block |
||
355 | 355 | */ |
356 | 356 | protected function changeUserSubscription($course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, $state, $status = STUDENT) { |
357 | 357 | $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
358 | - if($course_id instanceof WSError) { |
|
358 | + if ($course_id instanceof WSError) { |
|
359 | 359 | return $course_id; |
360 | 360 | } else { |
361 | 361 | $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
362 | - if($user_id instanceof WSError) { |
|
362 | + if ($user_id instanceof WSError) { |
|
363 | 363 | return $user_id; |
364 | 364 | } else { |
365 | 365 | $course_code = CourseManager::get_course_code_from_course_id($course_id); |
366 | - if($state == 0) { |
|
366 | + if ($state == 0) { |
|
367 | 367 | // Unsubscribe user |
368 | 368 | CourseManager::unsubscribe_user($user_id, $course_code); |
369 | 369 | return true; |
370 | 370 | } else { |
371 | 371 | // Subscribe user |
372 | - if(CourseManager::subscribe_user($user_id, $course_code, $status)) { |
|
372 | + if (CourseManager::subscribe_user($user_id, $course_code, $status)) { |
|
373 | 373 | return true; |
374 | 374 | } else { |
375 | 375 | return new WSError(203, 'An error occured subscribing to this course'); |
@@ -391,11 +391,11 @@ discard block |
||
391 | 391 | */ |
392 | 392 | public function SubscribeUserToCourse($secret_key, $course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, $status) { |
393 | 393 | $verifKey = $this->verifyKey($secret_key); |
394 | - if($verifKey instanceof WSError) { |
|
394 | + if ($verifKey instanceof WSError) { |
|
395 | 395 | $this->handleError($verifKey); |
396 | 396 | } else { |
397 | 397 | $result = $this->changeUserSubscription($course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, 1, $status); |
398 | - if($result instanceof WSError) { |
|
398 | + if ($result instanceof WSError) { |
|
399 | 399 | $this->handleError($result); |
400 | 400 | } |
401 | 401 | } |
@@ -412,11 +412,11 @@ discard block |
||
412 | 412 | */ |
413 | 413 | public function UnsubscribeUserFromCourse($secret_key, $course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value) { |
414 | 414 | $verifKey = $this->verifyKey($secret_key); |
415 | - if($verifKey instanceof WSError) { |
|
415 | + if ($verifKey instanceof WSError) { |
|
416 | 416 | $this->handleError($verifKey); |
417 | 417 | } else { |
418 | 418 | $result = $this->changeUserSubscription($course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, 0); |
419 | - if($result instanceof WSError) { |
|
419 | + if ($result instanceof WSError) { |
|
420 | 420 | $this->handleError($result); |
421 | 421 | } |
422 | 422 | } |
@@ -432,17 +432,17 @@ discard block |
||
432 | 432 | */ |
433 | 433 | public function GetCourseDescriptions($secret_key, $course_id_field_name, $course_id_value) { |
434 | 434 | $verifKey = $this->verifyKey($secret_key); |
435 | - if($verifKey instanceof WSError) { |
|
435 | + if ($verifKey instanceof WSError) { |
|
436 | 436 | $this->handleError($verifKey); |
437 | 437 | } else { |
438 | 438 | $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
439 | - if($course_id instanceof WSError) { |
|
439 | + if ($course_id instanceof WSError) { |
|
440 | 440 | return $course_id; |
441 | 441 | } else { |
442 | 442 | // Course exists, get its descriptions |
443 | 443 | $descriptions = CourseDescription::get_descriptions($course_id); |
444 | 444 | $results = array(); |
445 | - foreach($descriptions as $description) { |
|
445 | + foreach ($descriptions as $description) { |
|
446 | 446 | $results[] = array('course_desc_id' => $description->get_description_type(), |
447 | 447 | 'course_desc_title' => $description->get_title(), |
448 | 448 | 'course_desc_content' => $description->get_content()); |
@@ -465,11 +465,11 @@ discard block |
||
465 | 465 | */ |
466 | 466 | public function EditCourseDescription($secret_key, $course_id_field_name, $course_id_value, $course_desc_id, $course_desc_title, $course_desc_content) { |
467 | 467 | $verifKey = $this->verifyKey($secret_key); |
468 | - if($verifKey instanceof WSError) { |
|
468 | + if ($verifKey instanceof WSError) { |
|
469 | 469 | $this->handleError($verifKey); |
470 | 470 | } else { |
471 | 471 | $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
472 | - if($course_id instanceof WSError) { |
|
472 | + if ($course_id instanceof WSError) { |
|
473 | 473 | return $course_id; |
474 | 474 | } else { |
475 | 475 | // Create the new course description |
@@ -484,8 +484,8 @@ discard block |
||
484 | 484 | // Check if this course description exists |
485 | 485 | $descriptions = CourseDescription::get_descriptions($course_id); |
486 | 486 | $exists = false; |
487 | - foreach($descriptions as $description) { |
|
488 | - if($description->get_description_type() == $course_desc_id) { |
|
487 | + foreach ($descriptions as $description) { |
|
488 | + if ($description->get_description_type() == $course_desc_id) { |
|
489 | 489 | $exists = true; |
490 | 490 | } |
491 | 491 | } |
@@ -342,6 +342,7 @@ |
||
342 | 342 | * @param string User id value |
343 | 343 | * @param int Set to 1 to subscribe, 0 to unsubscribe |
344 | 344 | * @param int Status (STUDENT or TEACHER) Used for subscription only |
345 | + * @param integer $state |
|
345 | 346 | * @return mixed True if subscription or unsubscription was successful, false otherwise |
346 | 347 | */ |
347 | 348 | protected function changeUserSubscription($course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, $state, $status = STUDENT) { |