@@ -32,7 +32,7 @@ |
||
32 | 32 | if (isset($_POST['submit'])) { |
33 | 33 | $id = aiken_import_file($_FILES['userFile']); |
34 | 34 | if (is_numeric($id) && !empty($id)) { |
35 | - header('Location: admin.php?' . api_get_cidreq() . '&exerciseId=' . $id); |
|
35 | + header('Location: admin.php?'.api_get_cidreq().'&exerciseId='.$id); |
|
36 | 36 | exit; |
37 | 37 | } |
38 | 38 | } |
@@ -19,13 +19,13 @@ discard block |
||
19 | 19 | $tool_name = get_lang('Search'); |
20 | 20 | $interbreadcrumb[] = array('url' => 'profile.php', 'name' => get_lang('SocialNetwork')); |
21 | 21 | |
22 | -$query = isset($_GET['q']) ? Security::remove_XSS($_GET['q']): null; |
|
23 | -$query_search_type = isset($_GET['search_type']) && in_array($_GET['search_type'], array('0','1','2')) ? $_GET['search_type'] : null; |
|
22 | +$query = isset($_GET['q']) ? Security::remove_XSS($_GET['q']) : null; |
|
23 | +$query_search_type = isset($_GET['search_type']) && in_array($_GET['search_type'], array('0', '1', '2')) ? $_GET['search_type'] : null; |
|
24 | 24 | $extra_fields = UserManager::get_extra_filtrable_fields(); |
25 | 25 | $query_vars = array('q' => $query, 'search_type' => $query_search_type); |
26 | 26 | if (!empty($extra_fields)) { |
27 | 27 | foreach ($extra_fields as $extra_field) { |
28 | - $field_name = 'field_' . $extra_field['variable']; |
|
28 | + $field_name = 'field_'.$extra_field['variable']; |
|
29 | 29 | if (isset($_GET[$field_name]) && $_GET[$field_name] != '0') { |
30 | 30 | $query_vars[$field_name] = $_GET[$field_name]; |
31 | 31 | } |
@@ -45,10 +45,10 @@ discard block |
||
45 | 45 | $usergroup = new UserGroup(); |
46 | 46 | |
47 | 47 | // I'm searching something |
48 | -if ($query != '' || ($query_vars['search_type']=='1' && count($query_vars)>2) ) { |
|
48 | +if ($query != '' || ($query_vars['search_type'] == '1' && count($query_vars) > 2)) { |
|
49 | 49 | $itemPerPage = 8; |
50 | 50 | |
51 | - if ($_GET['search_type']=='0' || $_GET['search_type']=='1') { |
|
51 | + if ($_GET['search_type'] == '0' || $_GET['search_type'] == '1') { |
|
52 | 52 | $page = isset($_GET['users_page_nr']) ? intval($_GET['users_page_nr']) : 1; |
53 | 53 | $totalUsers = UserManager::get_all_user_tags($_GET['q'], 0, 0, $itemPerPage, true); |
54 | 54 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | $users = UserManager::get_all_user_tags($_GET['q'], 0, $from, $itemPerPage); |
58 | 58 | } |
59 | 59 | |
60 | - if ($_GET['search_type']=='0' || $_GET['search_type']=='2') { |
|
60 | + if ($_GET['search_type'] == '0' || $_GET['search_type'] == '2') { |
|
61 | 61 | $pageGroup = isset($_GET['groups_page_nr']) ? intval($_GET['groups_page_nr']) : 1; |
62 | 62 | // Groups |
63 | 63 | $fromGroups = intval(($pageGroup - 1) * $itemPerPage); |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | |
84 | 84 | // Show send invitation icon if they are not friends yet |
85 | 85 | if ($relation_type != 3 && $relation_type != 4 && $user_info['user_id'] != api_get_user_id()) { |
86 | - $sendInvitation = '<a href="#" class="'.$buttonClass.' btn-to-send-invitation" data-send-to="' . $user_info['user_id'] . '"> |
|
86 | + $sendInvitation = '<a href="#" class="'.$buttonClass.' btn-to-send-invitation" data-send-to="'.$user_info['user_id'].'"> |
|
87 | 87 | <em class="fa fa-user"></em> '.get_lang('SendInvitation').'</a>'; |
88 | 88 | } |
89 | 89 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | </div> |
130 | 130 | <div class="user-info"> |
131 | 131 | <p>'.$user_info['complete_name'].'</p> |
132 | - <div class="items-user-status">' . $status_icon . $user_icon . '</div> |
|
132 | + <div class="items-user-status">' . $status_icon.$user_icon.'</div> |
|
133 | 133 | <div class="toolbar"> |
134 | 134 | '.$invitations.' |
135 | 135 | </div> |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | $tags = null; |
187 | 187 | $group['picture'] = '<img class="img-responsive img-circle" src="'.$picture['file'].'" />'; |
188 | 188 | |
189 | - $members = Display::returnFontAwesomeIcon('user') . '( ' .$count_users_group . ' )'; |
|
189 | + $members = Display::returnFontAwesomeIcon('user').'( '.$count_users_group.' )'; |
|
190 | 190 | $item_1 = Display::tag('p', $url_open.$name.$url_close); |
191 | 191 | |
192 | 192 | $block_groups .= ' |
@@ -197,10 +197,10 @@ discard block |
||
197 | 197 | </div> |
198 | 198 | <div class="user-info"> |
199 | 199 | '.$item_1.' |
200 | - <p>' . $members . '</p> |
|
201 | - <p>' . $group['description'] . '</p> |
|
202 | - <p>' . $tags . '</p> |
|
203 | - <p>' . $url_open.get_lang('SeeMore') . $url_close . '</p> |
|
200 | + <p>' . $members.'</p> |
|
201 | + <p>' . $group['description'].'</p> |
|
202 | + <p>' . $tags.'</p> |
|
203 | + <p>' . $url_open.get_lang('SeeMore').$url_close.'</p> |
|
204 | 204 | </div> |
205 | 205 | </div> |
206 | 206 | </div>'; |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | $tpl->assign('social_search', $block_search); |
241 | 241 | $tpl->assign('search_form', $searchForm); |
242 | 242 | |
243 | -$formModalTpl = new Template(); |
|
243 | +$formModalTpl = new Template(); |
|
244 | 244 | $formModalTpl->assign('invitation_form', MessageManager::generate_invitation_form('send_invitation')); |
245 | 245 | $formModals = $formModalTpl->fetch('default/social/form_modals.tpl'); |
246 | 246 |
@@ -17,56 +17,56 @@ discard block |
||
17 | 17 | $message = ''; |
18 | 18 | |
19 | 19 | if (isset($_POST['activeExtension'])) { |
20 | - switch ($_POST['extension_code']) { |
|
21 | - case 'ppt2lp': |
|
22 | - $sql = 'UPDATE '.$tbl_settings_current.' SET |
|
20 | + switch ($_POST['extension_code']) { |
|
21 | + case 'ppt2lp': |
|
22 | + $sql = 'UPDATE '.$tbl_settings_current.' SET |
|
23 | 23 | selected_value="true" |
24 | 24 | WHERE variable="service_ppt2lp" |
25 | 25 | AND subkey="active"'; |
26 | 26 | |
27 | - $rs = Database::query($sql); |
|
27 | + $rs = Database::query($sql); |
|
28 | 28 | |
29 | - if (Database::affected_rows($rs)>0){ |
|
30 | - $message = get_lang('ServiceActivated'); |
|
31 | - } |
|
29 | + if (Database::affected_rows($rs)>0){ |
|
30 | + $message = get_lang('ServiceActivated'); |
|
31 | + } |
|
32 | 32 | |
33 | - $sql = 'UPDATE '.$tbl_settings_current.' SET |
|
33 | + $sql = 'UPDATE '.$tbl_settings_current.' SET |
|
34 | 34 | selected_value="'.addslashes($_POST['host']).'" |
35 | 35 | WHERE variable="service_ppt2lp" |
36 | 36 | AND subkey="host"'; |
37 | - Database::query($sql); |
|
37 | + Database::query($sql); |
|
38 | 38 | |
39 | - $sql = 'UPDATE '.$tbl_settings_current.' SET |
|
39 | + $sql = 'UPDATE '.$tbl_settings_current.' SET |
|
40 | 40 | selected_value="'.addslashes($_POST['port']).'" |
41 | 41 | WHERE variable="service_ppt2lp" |
42 | 42 | AND subkey="port"'; |
43 | - Database::query($sql); |
|
43 | + Database::query($sql); |
|
44 | 44 | |
45 | - $sql = 'UPDATE '.$tbl_settings_current.' SET |
|
45 | + $sql = 'UPDATE '.$tbl_settings_current.' SET |
|
46 | 46 | selected_value="'.addslashes($_POST['ftp_password']).'" |
47 | 47 | WHERE variable="service_ppt2lp" |
48 | 48 | AND subkey="ftp_password"'; |
49 | - Database::query($sql); |
|
49 | + Database::query($sql); |
|
50 | 50 | |
51 | - $sql = 'UPDATE '.$tbl_settings_current.' SET |
|
51 | + $sql = 'UPDATE '.$tbl_settings_current.' SET |
|
52 | 52 | selected_value="'.addslashes($_POST['user']).'" |
53 | 53 | WHERE variable="service_ppt2lp" |
54 | 54 | AND subkey="user"'; |
55 | - Database::query($sql); |
|
55 | + Database::query($sql); |
|
56 | 56 | |
57 | - $sql = 'UPDATE '.$tbl_settings_current.' SET |
|
57 | + $sql = 'UPDATE '.$tbl_settings_current.' SET |
|
58 | 58 | selected_value="'.addslashes($_POST['path_to_lzx']).'" |
59 | 59 | WHERE variable="service_ppt2lp" |
60 | 60 | AND subkey="path_to_lzx"'; |
61 | - Database::query($sql); |
|
61 | + Database::query($sql); |
|
62 | 62 | |
63 | - $sql = 'UPDATE '.$tbl_settings_current.' SET |
|
63 | + $sql = 'UPDATE '.$tbl_settings_current.' SET |
|
64 | 64 | selected_value="'.addslashes($_POST['size']).'" |
65 | 65 | WHERE variable="service_ppt2lp" |
66 | 66 | AND subkey="size"'; |
67 | - Database::query($sql); |
|
68 | - break; |
|
69 | - } |
|
67 | + Database::query($sql); |
|
68 | + break; |
|
69 | + } |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | $listActiveServices = array(); |
@@ -77,13 +77,13 @@ discard block |
||
77 | 77 | |
78 | 78 | $rs = Database::query($sql); |
79 | 79 | while($row = Database::fetch_array($rs)){ |
80 | - $listActiveServices[] = $row['variable']; |
|
80 | + $listActiveServices[] = $row['variable']; |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | // javascript to handle accordion behaviour |
84 | 84 | $javascript_message = ''; |
85 | 85 | if(!empty($message)){ |
86 | - $javascript_message = ' |
|
86 | + $javascript_message = ' |
|
87 | 87 | document.getElementById("message").style.display = "block"; |
88 | 88 | var timer = setTimeout(hideMessage, 5000);'; |
89 | 89 | } |
@@ -135,9 +135,9 @@ discard block |
||
135 | 135 | ?> |
136 | 136 | <div id="message" style="display: none"> |
137 | 137 | <?php |
138 | - if(!empty($message)) |
|
139 | - Display::display_normal_message($message) |
|
140 | - ?> |
|
138 | + if(!empty($message)) |
|
139 | + Display::display_normal_message($message) |
|
140 | + ?> |
|
141 | 141 | </div> |
142 | 142 | |
143 | 143 | <div id="content" align="center"> |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | </div> |
201 | 201 | </div> |
202 | 202 | <?php |
203 | - /* |
|
203 | + /* |
|
204 | 204 | <!-- EPHORUS --> |
205 | 205 | <div id="main_ephorus"> |
206 | 206 | <div id="extension_header_ephorus" class="accordion_header"> |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | |
27 | 27 | $rs = Database::query($sql); |
28 | 28 | |
29 | - if (Database::affected_rows($rs)>0){ |
|
29 | + if (Database::affected_rows($rs) > 0) { |
|
30 | 30 | $message = get_lang('ServiceActivated'); |
31 | 31 | } |
32 | 32 | |
@@ -76,18 +76,18 @@ discard block |
||
76 | 76 | WHERE variable LIKE "service_%" AND subkey="active" and selected_value="true"'; |
77 | 77 | |
78 | 78 | $rs = Database::query($sql); |
79 | -while($row = Database::fetch_array($rs)){ |
|
79 | +while ($row = Database::fetch_array($rs)) { |
|
80 | 80 | $listActiveServices[] = $row['variable']; |
81 | 81 | } |
82 | 82 | |
83 | 83 | // javascript to handle accordion behaviour |
84 | 84 | $javascript_message = ''; |
85 | -if(!empty($message)){ |
|
85 | +if (!empty($message)) { |
|
86 | 86 | $javascript_message = ' |
87 | 87 | document.getElementById("message").style.display = "block"; |
88 | 88 | var timer = setTimeout(hideMessage, 5000);'; |
89 | 89 | } |
90 | -$htmlHeadXtra[]= '<script> |
|
90 | +$htmlHeadXtra[] = '<script> |
|
91 | 91 | var listeDiv; |
92 | 92 | var extensionsHeader = new Array(); |
93 | 93 | var extensionsContent = new Array(); |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | ?> |
136 | 136 | <div id="message" style="display: none"> |
137 | 137 | <?php |
138 | - if(!empty($message)) |
|
138 | + if (!empty($message)) |
|
139 | 139 | Display::display_normal_message($message) |
140 | 140 | ?> |
141 | 141 | </div> |
@@ -135,8 +135,8 @@ discard block |
||
135 | 135 | ?> |
136 | 136 | <div id="message" style="display: none"> |
137 | 137 | <?php |
138 | - if(!empty($message)) |
|
139 | - Display::display_normal_message($message) |
|
138 | + if(!empty($message)) { |
|
139 | + Display::display_normal_message($message) |
|
140 | 140 | ?> |
141 | 141 | </div> |
142 | 142 | |
@@ -150,7 +150,9 @@ discard block |
||
150 | 150 | </div> |
151 | 151 | <div class="row"> |
152 | 152 | <div class="col-md-5"> |
153 | - <?php Display::display_icon('screenshot_ppt2lp.jpg', get_lang('Ppt2lp'), array('class'=>'img-responsive')); ?> |
|
153 | + <?php Display::display_icon('screenshot_ppt2lp.jpg', get_lang('Ppt2lp'), array('class'=>'img-responsive')); |
|
154 | + } |
|
155 | + ?> |
|
154 | 156 | </div> |
155 | 157 | <div class="col-md-7"> |
156 | 158 | <form method="POST" class="form-horizontal" action="<?php echo api_get_self(); ?>"> |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | * current configuration file. |
14 | 14 | * @package chamilo.install |
15 | 15 | */ |
16 | -error_log("Starting " . basename(__FILE__)); |
|
16 | +error_log("Starting ".basename(__FILE__)); |
|
17 | 17 | |
18 | 18 | global $debug; |
19 | 19 | |
@@ -24,16 +24,16 @@ discard block |
||
24 | 24 | // The main/exercice path was moved to main/exercise, so the code from 1.11 |
25 | 25 | // should just create the new directory, and we should delete the previous |
26 | 26 | // one to avoid the web server to use the old |
27 | - $exercisePath = api_get_path(SYS_CODE_PATH) . 'exercice'; |
|
27 | + $exercisePath = api_get_path(SYS_CODE_PATH).'exercice'; |
|
28 | 28 | if (is_dir($exercisePath)) { |
29 | 29 | @rrmdir($exercisePath); |
30 | 30 | } |
31 | 31 | // Same with main/newscorm, renamed main/lp |
32 | - $lpPath = api_get_path(SYS_CODE_PATH) . 'newscorm'; |
|
32 | + $lpPath = api_get_path(SYS_CODE_PATH).'newscorm'; |
|
33 | 33 | if (is_dir($lpPath)) { |
34 | 34 | @rrmdir($lpPath); |
35 | 35 | } |
36 | - $ticketPluginPath = api_get_path(SYS_PLUGIN_PATH) . 'ticket'; |
|
36 | + $ticketPluginPath = api_get_path(SYS_PLUGIN_PATH).'ticket'; |
|
37 | 37 | if (is_dir($ticketPluginPath)) { |
38 | 38 | @rrmdir($ticketPluginPath); |
39 | 39 | } |
@@ -43,5 +43,5 @@ discard block |
||
43 | 43 | } |
44 | 44 | |
45 | 45 | } else { |
46 | - echo 'You are not allowed here !'. __FILE__; |
|
46 | + echo 'You are not allowed here !'.__FILE__; |
|
47 | 47 | } |
@@ -22,16 +22,16 @@ discard block |
||
22 | 22 | $objSkill = new Skill(); |
23 | 23 | $skill = $objSkill->get($skillId); |
24 | 24 | |
25 | -$htmlHeadXtra[] = '<link href="'. api_get_path(WEB_LIBRARY_JS_PATH) .'badge-studio/media/css/core.css" rel="stylesheet">'; |
|
25 | +$htmlHeadXtra[] = '<link href="'.api_get_path(WEB_LIBRARY_JS_PATH).'badge-studio/media/css/core.css" rel="stylesheet">'; |
|
26 | 26 | |
27 | 27 | // Add badge studio paths |
28 | 28 | |
29 | 29 | $badgeStudio = [ |
30 | - 'core' => api_get_path(WEB_LIBRARY_JS_PATH) .'badge-studio/', |
|
31 | - 'media' => api_get_path(WEB_LIBRARY_JS_PATH) .'badge-studio/media/', |
|
32 | - 'templates' => api_get_path(WEB_LIBRARY_JS_PATH) .'badge-studio/media/images/templates/', |
|
33 | - 'masks' => api_get_path(WEB_LIBRARY_JS_PATH) .'badge-studio/media/images/masks/', |
|
34 | - 'script_js' => '<script src="'. api_get_path(WEB_LIBRARY_JS_PATH) .'badge-studio/media/js/studio.js?"></script>' |
|
30 | + 'core' => api_get_path(WEB_LIBRARY_JS_PATH).'badge-studio/', |
|
31 | + 'media' => api_get_path(WEB_LIBRARY_JS_PATH).'badge-studio/media/', |
|
32 | + 'templates' => api_get_path(WEB_LIBRARY_JS_PATH).'badge-studio/media/images/templates/', |
|
33 | + 'masks' => api_get_path(WEB_LIBRARY_JS_PATH).'badge-studio/media/images/masks/', |
|
34 | + 'script_js' => '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'badge-studio/media/js/studio.js?"></script>' |
|
35 | 35 | ]; |
36 | 36 | |
37 | 37 | |
@@ -59,10 +59,10 @@ discard block |
||
59 | 59 | if ($existsBadgesDirectory) { |
60 | 60 | |
61 | 61 | if (!empty($skill['icon'])) { |
62 | - $iconFileAbsolutePath = $badgePath . $skill['icon']; |
|
62 | + $iconFileAbsolutePath = $badgePath.$skill['icon']; |
|
63 | 63 | |
64 | 64 | if (Security::check_abs_path($iconFileAbsolutePath, $badgePath)) { |
65 | - unlink($badgePath . $skill['icon']); |
|
65 | + unlink($badgePath.$skill['icon']); |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
@@ -85,24 +85,24 @@ discard block |
||
85 | 85 | |
86 | 86 | $objSkill->update($params); |
87 | 87 | |
88 | - header('Location: ' . api_get_path(WEB_CODE_PATH) . 'admin/skill_badge_list.php'); |
|
88 | + header('Location: '.api_get_path(WEB_CODE_PATH).'admin/skill_badge_list.php'); |
|
89 | 89 | exit; |
90 | 90 | } |
91 | 91 | |
92 | 92 | $interbreadcrumb = array( |
93 | 93 | array( |
94 | - 'url' => api_get_path(WEB_CODE_PATH) . 'admin/index.php', |
|
94 | + 'url' => api_get_path(WEB_CODE_PATH).'admin/index.php', |
|
95 | 95 | 'name' => get_lang('Administration') |
96 | 96 | ), |
97 | 97 | array( |
98 | - 'url' => api_get_path(WEB_CODE_PATH) . 'admin/skill_badge.php', |
|
98 | + 'url' => api_get_path(WEB_CODE_PATH).'admin/skill_badge.php', |
|
99 | 99 | 'name' => get_lang('Badges') |
100 | 100 | ) |
101 | 101 | ); |
102 | 102 | |
103 | 103 | $toolbar = Display::toolbarButton( |
104 | 104 | get_lang('ManageSkills'), |
105 | - api_get_path(WEB_CODE_PATH) . 'admin/skill_list.php', |
|
105 | + api_get_path(WEB_CODE_PATH).'admin/skill_list.php', |
|
106 | 106 | 'list', |
107 | 107 | 'primary', |
108 | 108 | ['title' => get_lang('ManageSkills')] |
@@ -39,8 +39,8 @@ discard block |
||
39 | 39 | * Deletes a file or a directory |
40 | 40 | * |
41 | 41 | * @author - Hugues Peeters |
42 | - * @param $file (String) - the path of file or directory to delete |
|
43 | - * @return boolean - true if the delete succeed, false otherwise. |
|
42 | + * @param string $file (String) - the path of file or directory to delete |
|
43 | + * @return boolean|null - true if the delete succeed, false otherwise. |
|
44 | 44 | * @see - delete() uses check_name_exist() and removeDir() functions |
45 | 45 | */ |
46 | 46 | function my_delete($file) |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * @author Hugues Peeters <[email protected]> |
128 | 128 | * @param string $file_path complete path of the file or the directory |
129 | 129 | * @param string $new_file_name new name for the file or the directory |
130 | - * @return boolean true if succeed, false otherwise |
|
130 | + * @return string|false true if succeed, false otherwise |
|
131 | 131 | * @see rename() uses the check_name_exist() and php2phps() functions |
132 | 132 | */ |
133 | 133 | function my_rename($file_path, $new_file_name) { |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | * @param string $target the path of the new area |
175 | 175 | * @param bool $forceMove Whether to force a move or to make a copy (safer but slower) and then delete the original |
176 | 176 | * @param bool $moveContent In some cases (including migrations), we need to move the *content* and not the folder itself |
177 | - * @return bool true if the move succeed, false otherwise. |
|
177 | + * @return boolean|null true if the move succeed, false otherwise. |
|
178 | 178 | * @see move() uses check_name_exist() and copyDirTo() functions |
179 | 179 | */ |
180 | 180 | function move($source, $target, $forceMove = false, $moveContent = false) |
@@ -132,38 +132,38 @@ discard block |
||
132 | 132 | */ |
133 | 133 | function my_rename($file_path, $new_file_name) { |
134 | 134 | |
135 | - $save_dir = getcwd(); |
|
136 | - $path = dirname($file_path); |
|
137 | - $old_file_name = basename($file_path); |
|
138 | - $new_file_name = api_replace_dangerous_char($new_file_name); |
|
135 | + $save_dir = getcwd(); |
|
136 | + $path = dirname($file_path); |
|
137 | + $old_file_name = basename($file_path); |
|
138 | + $new_file_name = api_replace_dangerous_char($new_file_name); |
|
139 | 139 | |
140 | - // If no extension, take the old one |
|
141 | - if ((strpos($new_file_name, '.') === false) && ($dotpos = strrpos($old_file_name, '.'))) { |
|
142 | - $new_file_name .= substr($old_file_name, $dotpos); |
|
143 | - } |
|
140 | + // If no extension, take the old one |
|
141 | + if ((strpos($new_file_name, '.') === false) && ($dotpos = strrpos($old_file_name, '.'))) { |
|
142 | + $new_file_name .= substr($old_file_name, $dotpos); |
|
143 | + } |
|
144 | 144 | |
145 | - // Note: still possible: 'xx.yy' -rename-> '.yy' -rename-> 'zz' |
|
146 | - // This is useful for folder names, where otherwise '.' would be sticky |
|
145 | + // Note: still possible: 'xx.yy' -rename-> '.yy' -rename-> 'zz' |
|
146 | + // This is useful for folder names, where otherwise '.' would be sticky |
|
147 | 147 | |
148 | - // Extension PHP is not allowed, change to PHPS |
|
149 | - $new_file_name = php2phps($new_file_name); |
|
148 | + // Extension PHP is not allowed, change to PHPS |
|
149 | + $new_file_name = php2phps($new_file_name); |
|
150 | 150 | |
151 | - if ($new_file_name == $old_file_name) { |
|
152 | - return $old_file_name; |
|
153 | - } |
|
151 | + if ($new_file_name == $old_file_name) { |
|
152 | + return $old_file_name; |
|
153 | + } |
|
154 | 154 | |
155 | - if (strtolower($new_file_name) != strtolower($old_file_name) && check_name_exist($path.'/'.$new_file_name)) { |
|
156 | - return false; |
|
157 | - } |
|
158 | - // On a Windows server, it would be better not to do the above check |
|
159 | - // because it succeeds for some new names resembling the old name. |
|
160 | - // But on Unix/Linux the check must be done because rename overwrites. |
|
155 | + if (strtolower($new_file_name) != strtolower($old_file_name) && check_name_exist($path.'/'.$new_file_name)) { |
|
156 | + return false; |
|
157 | + } |
|
158 | + // On a Windows server, it would be better not to do the above check |
|
159 | + // because it succeeds for some new names resembling the old name. |
|
160 | + // But on Unix/Linux the check must be done because rename overwrites. |
|
161 | 161 | |
162 | - chdir($path); |
|
163 | - $res = rename($old_file_name, $new_file_name) ? $new_file_name : false; |
|
164 | - chdir($save_dir); |
|
162 | + chdir($path); |
|
163 | + $res = rename($old_file_name, $new_file_name) ? $new_file_name : false; |
|
164 | + chdir($save_dir); |
|
165 | 165 | |
166 | - return $res; |
|
166 | + return $res; |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | $file_name = basename($source); |
186 | 186 | // move onto self illegal: mv a/b/c a/b/c or mv a/b/c a/b |
187 | 187 | if (strcasecmp($target, dirname($source)) === 0) { |
188 | - return false; |
|
188 | + return false; |
|
189 | 189 | } |
190 | 190 | $isWindowsOS = api_is_windows_os(); |
191 | 191 | $canExec = function_exists('exec'); |
@@ -265,8 +265,8 @@ discard block |
||
265 | 265 | */ |
266 | 266 | function getextension($filename) |
267 | 267 | { |
268 | - $bouts = explode('.', $filename); |
|
269 | - return array(array_pop($bouts), implode('.', $bouts)); |
|
268 | + $bouts = explode('.', $filename); |
|
269 | + return array(array_pop($bouts), implode('.', $bouts)); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | /** |
@@ -277,17 +277,17 @@ discard block |
||
277 | 277 | * @param boolean $recursive if true , include subdirectory in total |
278 | 278 | */ |
279 | 279 | function dirsize($root, $recursive = true) { |
280 | - $dir = @opendir($root); |
|
281 | - $size = 0; |
|
282 | - while ($file = @readdir($dir)) { |
|
283 | - if (!in_array($file, array('.', '..'))) { |
|
284 | - if (is_dir($root.'/'.$file)) { |
|
285 | - $size += $recursive ? dirsize($root.'/'.$file) : 0; |
|
286 | - } else { |
|
287 | - $size += @filesize($root.'/'.$file); |
|
288 | - } |
|
289 | - } |
|
290 | - } |
|
291 | - @closedir($dir); |
|
292 | - return $size; |
|
280 | + $dir = @opendir($root); |
|
281 | + $size = 0; |
|
282 | + while ($file = @readdir($dir)) { |
|
283 | + if (!in_array($file, array('.', '..'))) { |
|
284 | + if (is_dir($root.'/'.$file)) { |
|
285 | + $size += $recursive ? dirsize($root.'/'.$file) : 0; |
|
286 | + } else { |
|
287 | + $size += @filesize($root.'/'.$file); |
|
288 | + } |
|
289 | + } |
|
290 | + } |
|
291 | + @closedir($dir); |
|
292 | + return $size; |
|
293 | 293 | } |
@@ -193,9 +193,9 @@ |
||
193 | 193 | /* File case */ |
194 | 194 | if (is_file($source)) { |
195 | 195 | if ($forceMove && !$isWindowsOS && $canExec) { |
196 | - exec('mv ' . $source . ' ' . $target . '/' . $file_name); |
|
196 | + exec('mv '.$source.' '.$target.'/'.$file_name); |
|
197 | 197 | } else { |
198 | - copy($source, $target . '/' . $file_name); |
|
198 | + copy($source, $target.'/'.$file_name); |
|
199 | 199 | unlink($source); |
200 | 200 | } |
201 | 201 | return true; |
@@ -86,31 +86,31 @@ discard block |
||
86 | 86 | |
87 | 87 | </script>'; |
88 | 88 | |
89 | -$allowed_views = array('mygroups','newest','pop'); |
|
89 | +$allowed_views = array('mygroups', 'newest', 'pop'); |
|
90 | 90 | $content = null; |
91 | 91 | |
92 | -if (isset($_GET['view']) && in_array($_GET['view'],$allowed_views)) { |
|
92 | +if (isset($_GET['view']) && in_array($_GET['view'], $allowed_views)) { |
|
93 | 93 | if ($_GET['view'] == 'mygroups') { |
94 | - $interbreadcrumb[]= array ('url' =>'groups.php','name' => get_lang('Groups')); |
|
95 | - $interbreadcrumb[]= array ('url' =>'#','name' => get_lang('MyGroups')); |
|
96 | - } else if ( $_GET['view'] == 'newest') { |
|
97 | - $interbreadcrumb[]= array ('url' =>'groups.php','name' => get_lang('Groups')); |
|
98 | - $interbreadcrumb[]= array ('url' =>'#','name' => get_lang('Newest')); |
|
99 | - } else { |
|
100 | - $interbreadcrumb[]= array ('url' =>'groups.php','name' => get_lang('Groups')); |
|
101 | - $interbreadcrumb[]= array ('url' =>'#','name' => get_lang('Popular')); |
|
94 | + $interbreadcrumb[] = array('url' =>'groups.php', 'name' => get_lang('Groups')); |
|
95 | + $interbreadcrumb[] = array('url' =>'#', 'name' => get_lang('MyGroups')); |
|
96 | + } else if ($_GET['view'] == 'newest') { |
|
97 | + $interbreadcrumb[] = array('url' =>'groups.php', 'name' => get_lang('Groups')); |
|
98 | + $interbreadcrumb[] = array('url' =>'#', 'name' => get_lang('Newest')); |
|
99 | + } else { |
|
100 | + $interbreadcrumb[] = array('url' =>'groups.php', 'name' => get_lang('Groups')); |
|
101 | + $interbreadcrumb[] = array('url' =>'#', 'name' => get_lang('Popular')); |
|
102 | 102 | } |
103 | 103 | } else { |
104 | - $interbreadcrumb[]= array ('url' =>'groups.php','name' => get_lang('Groups')); |
|
104 | + $interbreadcrumb[] = array('url' =>'groups.php', 'name' => get_lang('Groups')); |
|
105 | 105 | if (!isset($_GET['id'])) { |
106 | - $interbreadcrumb[]= array ('url' =>'#','name' => get_lang('GroupList')); |
|
106 | + $interbreadcrumb[] = array('url' =>'#', 'name' => get_lang('GroupList')); |
|
107 | 107 | } else { |
108 | 108 | //$interbreadcrumb[]= array ('url' =>'#','name' => get_lang('Group')); |
109 | 109 | } |
110 | 110 | } |
111 | 111 | |
112 | 112 | // getting group information |
113 | -$group_id = isset($_GET['id']) ? intval($_GET['id']) : null; |
|
113 | +$group_id = isset($_GET['id']) ? intval($_GET['id']) : null; |
|
114 | 114 | $relation_group_title = ''; |
115 | 115 | $role = 0; |
116 | 116 | |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | $group_info = $usergroup->get($group_id); |
121 | 121 | |
122 | 122 | |
123 | - $interbreadcrumb[]= array ('url' =>'#','name' => $group_info['name']); |
|
123 | + $interbreadcrumb[] = array('url' =>'#', 'name' => $group_info['name']); |
|
124 | 124 | |
125 | - if (isset($_GET['action']) && $_GET['action']=='leave') { |
|
125 | + if (isset($_GET['action']) && $_GET['action'] == 'leave') { |
|
126 | 126 | $user_leaved = intval($_GET['u']); |
127 | 127 | // I can "leave me myself" |
128 | 128 | if (api_get_user_id() == $user_leaved) { |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | } |
137 | 137 | |
138 | 138 | // add a user to a group if its open |
139 | - if (isset($_GET['action']) && $_GET['action']=='join') { |
|
139 | + if (isset($_GET['action']) && $_GET['action'] == 'join') { |
|
140 | 140 | // we add a user only if is a open group |
141 | 141 | $user_join = intval($_GET['u']); |
142 | 142 | if (api_get_user_id() == $user_join && !empty($group_id)) { |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | $group_info = $usergroup->get($group_id); |
166 | 166 | |
167 | 167 | //Loading group information |
168 | -if (isset($_GET['status']) && $_GET['status']=='sent') { |
|
168 | +if (isset($_GET['status']) && $_GET['status'] == 'sent') { |
|
169 | 169 | $social_right_content .= Display::return_message(get_lang('MessageHasBeenSent'), 'confirmation', false); |
170 | 170 | } |
171 | 171 | |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | |
175 | 175 | if (!$is_group_member && $group_info['visibility'] == GROUP_PERMISSION_CLOSED) { |
176 | 176 | if ($role == GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER) { |
177 | - $social_right_content .= Display::return_message(get_lang('YouAlreadySentAnInvitation')); |
|
177 | + $social_right_content .= Display::return_message(get_lang('YouAlreadySentAnInvitation')); |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | |
@@ -185,19 +185,19 @@ discard block |
||
185 | 185 | ) { |
186 | 186 | $social_right_content .= '<div class="group-tool">'; |
187 | 187 | $social_right_content .= '<div class="pull-right">'; |
188 | - $social_right_content .= '<a class="btn btn-default btn-sm" href="group_view.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'. |
|
188 | + $social_right_content .= '<a class="btn btn-default btn-sm" href="group_view.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'. |
|
189 | 189 | get_lang('JoinGroup').'</a>'; |
190 | - $social_right_content .= '</div>'; |
|
191 | - $social_right_content .= '</div>'; |
|
190 | + $social_right_content .= '</div>'; |
|
191 | + $social_right_content .= '</div>'; |
|
192 | 192 | } elseif ($role == GROUP_USER_PERMISSION_PENDING_INVITATION) { |
193 | 193 | $social_right_content .= '<div class="group-tool">'; |
194 | 194 | $social_right_content .= '<div class="pull-right">'; |
195 | - $social_right_content .= '<a class="btn btn-default btn-sm" href="group_view.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'. |
|
195 | + $social_right_content .= '<a class="btn btn-default btn-sm" href="group_view.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'. |
|
196 | 196 | Display::returnFontAwesomeIcon('envelope').' '. |
197 | 197 | get_lang('YouHaveBeenInvitedJoinNow').'</a>'; |
198 | 198 | } |
199 | - $social_right_content .= '</div>'; |
|
200 | - $social_right_content .= '</div>'; |
|
199 | + $social_right_content .= '</div>'; |
|
200 | + $social_right_content .= '</div>'; |
|
201 | 201 | } |
202 | 202 | $content = MessageManager::display_messages_for_group($group_id); |
203 | 203 | if ($is_group_member) { |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | 'action' => 'add_message_group' |
212 | 212 | ]); |
213 | 213 | $create_thread_link = Display::url( |
214 | - Display::returnFontAwesomeIcon('commenting') . ' ' . |
|
214 | + Display::returnFontAwesomeIcon('commenting').' '. |
|
215 | 215 | get_lang('YouShouldCreateATopic'), |
216 | 216 | $createThreadUrl, |
217 | 217 | [ |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | 'action' => 'add_message_group', |
232 | 232 | ]); |
233 | 233 | $create_thread_link = Display::url( |
234 | - Display::returnFontAwesomeIcon('commenting') . ' ' . |
|
234 | + Display::returnFontAwesomeIcon('commenting').' '. |
|
235 | 235 | get_lang('NewTopic'), |
236 | 236 | $createThreadUrl, |
237 | 237 | [ |
@@ -271,21 +271,21 @@ discard block |
||
271 | 271 | foreach ($members as $member) { |
272 | 272 | // if is a member |
273 | 273 | if (in_array($member['relation_type'], |
274 | - array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_READER,GROUP_USER_PERMISSION_MODERATOR)) |
|
274 | + array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_READER, GROUP_USER_PERMISSION_MODERATOR)) |
|
275 | 275 | ) { |
276 | 276 | //add icons |
277 | 277 | if ($member['relation_type'] == GROUP_USER_PERMISSION_ADMIN) { |
278 | - $icon= Display::return_icon('social_group_admin.png', get_lang('Admin')); |
|
278 | + $icon = Display::return_icon('social_group_admin.png', get_lang('Admin')); |
|
279 | 279 | } elseif ($member['relation_type'] == GROUP_USER_PERMISSION_MODERATOR) { |
280 | - $icon= Display::return_icon('social_group_moderator.png', get_lang('Moderator')); |
|
280 | + $icon = Display::return_icon('social_group_moderator.png', get_lang('Moderator')); |
|
281 | 281 | } else { |
282 | - $icon= ''; |
|
282 | + $icon = ''; |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | $userPicture = UserManager::getUserPicture($member['id']); |
286 | 286 | $member_content .= '<div class="col-md-3">'; |
287 | 287 | $member_content .= '<div class="items-user">'; |
288 | - $member_name = Display::url(api_get_person_name(cut($member['user_info']['firstname'],15),cut($member['user_info']['lastname'],15)).' '.$icon, $member['user_info']['profile_url']); |
|
288 | + $member_name = Display::url(api_get_person_name(cut($member['user_info']['firstname'], 15), cut($member['user_info']['lastname'], 15)).' '.$icon, $member['user_info']['profile_url']); |
|
289 | 289 | $member_content .= Display::div('<img class="img-circle" src="'.$userPicture.'"/>', array('class' => 'avatar')); |
290 | 290 | $member_content .= Display::div($member_name, array('class' => 'name')); |
291 | 291 | $member_content .= '</div>'; |
@@ -297,10 +297,10 @@ discard block |
||
297 | 297 | } |
298 | 298 | |
299 | 299 | if (!empty($create_thread_link)) { |
300 | - $create_thread_link = Display::div($create_thread_link, array('class'=>'pull-right')); |
|
300 | + $create_thread_link = Display::div($create_thread_link, array('class'=>'pull-right')); |
|
301 | 301 | } |
302 | 302 | $headers = array(get_lang('Discussions'), get_lang('Members')); |
303 | - $socialForum = Display::tabs($headers, array($content, $member_content),'tabs'); |
|
303 | + $socialForum = Display::tabs($headers, array($content, $member_content), 'tabs'); |
|
304 | 304 | |
305 | 305 | } else { |
306 | 306 | // if I already sent an invitation message |
@@ -312,9 +312,9 @@ discard block |
||
312 | 312 | ) |
313 | 313 | ) |
314 | 314 | ) { |
315 | - $social_right_content .= '<a class="btn" href="group_view.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.get_lang('JoinGroup').'</a>'; |
|
315 | + $social_right_content .= '<a class="btn" href="group_view.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.get_lang('JoinGroup').'</a>'; |
|
316 | 316 | } elseif ($role == GROUP_USER_PERMISSION_PENDING_INVITATION) { |
317 | - $social_right_content .= '<a class="btn" href="group_view.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.get_lang('YouHaveBeenInvitedJoinNow').'</a>'; |
|
317 | + $social_right_content .= '<a class="btn" href="group_view.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.get_lang('YouHaveBeenInvitedJoinNow').'</a>'; |
|
318 | 318 | } |
319 | 319 | } |
320 | 320 |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | |
19 | 19 | // Database Table Definitions |
20 | 20 | $tbl_user = Database::get_main_table(TABLE_MAIN_USER); |
21 | -$tbl_group_rel_user = Database::get_main_table(TABLE_USERGROUP_REL_USER); |
|
21 | +$tbl_group_rel_user = Database::get_main_table(TABLE_USERGROUP_REL_USER); |
|
22 | 22 | |
23 | 23 | // setting the name of the tool |
24 | 24 | $tool_name = get_lang('SubscribeUsersToGroup'); |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | } |
41 | 41 | } |
42 | 42 | |
43 | -$interbreadcrumb[] = array('url' =>'groups.php','name' => get_lang('Groups')); |
|
43 | +$interbreadcrumb[] = array('url' =>'groups.php', 'name' => get_lang('Groups')); |
|
44 | 44 | $interbreadcrumb[] = array('url' => 'group_view.php?id='.$group_id, 'name' => $group_info['name']); |
45 | 45 | $interbreadcrumb[] = array('url' =>'#', 'name' => get_lang('SubscribeUsersToGroup')); |
46 | 46 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | |
75 | 75 | if (is_array($user_list) && count($user_list) > 0) { |
76 | 76 | //send invitation message |
77 | - foreach ($user_list as $user_id){ |
|
77 | + foreach ($user_list as $user_id) { |
|
78 | 78 | $result = MessageManager::send_message( |
79 | 79 | $user_id, |
80 | 80 | $title, |
@@ -110,8 +110,8 @@ discard block |
||
110 | 110 | |
111 | 111 | if (!isset($group_friend_list[$group_id]) || |
112 | 112 | isset($group_friend_list[$group_id]) && |
113 | - $group_friend_list[$group_id]['relation_type'] == '' ) { |
|
114 | - $Users[$friend['friend_user_id']]= array( |
|
113 | + $group_friend_list[$group_id]['relation_type'] == '') { |
|
114 | + $Users[$friend['friend_user_id']] = array( |
|
115 | 115 | 'user_id' => $friend['friend_user_id'], |
116 | 116 | 'firstname' => $friend['firstName'], |
117 | 117 | 'lastname' => $friend['lastName'], |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | ); |
121 | 121 | } |
122 | 122 | } else { |
123 | - $Users[$friend['friend_user_id']]= array( |
|
123 | + $Users[$friend['friend_user_id']] = array( |
|
124 | 124 | 'user_id' => $friend['friend_user_id'], |
125 | 125 | 'firstname' =>$friend['firstName'], |
126 | 126 | 'lastname' => $friend['lastName'], |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | } |
132 | 132 | } |
133 | 133 | |
134 | -if (is_array($Users) && count($Users) > 0 ) { |
|
134 | +if (is_array($Users) && count($Users) > 0) { |
|
135 | 135 | foreach ($Users as $user) { |
136 | 136 | if ($user['group_id'] != $group_id) { |
137 | 137 | $nosessionUsersList[$user['user_id']] = api_get_person_name( |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | } |
144 | 144 | |
145 | 145 | $social_left_content = SocialManager::show_social_menu('invite_friends', $group_id); |
146 | -$social_right_content = '<h3 class="group-title">'.Security::remove_XSS($group_info['name'], STUDENT, true).'</h3>'; |
|
146 | +$social_right_content = '<h3 class="group-title">'.Security::remove_XSS($group_info['name'], STUDENT, true).'</h3>'; |
|
147 | 147 | |
148 | 148 | if (count($nosessionUsersList) == 0) { |
149 | 149 | $friends = SocialManager::get_friends(api_get_user_id()); |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | array(GROUP_USER_PERMISSION_PENDING_INVITATION) |
180 | 180 | ); |
181 | 181 | |
182 | -if (is_array($members) && count($members)>0) { |
|
182 | +if (is_array($members) && count($members) > 0) { |
|
183 | 183 | foreach ($members as &$member) { |
184 | 184 | $image = UserManager::getUserPicture($member['id']); |
185 | 185 | $member['image'] = '<img class="img-circle" src="'.$image.'" width="50px" height="50px" />'; |
@@ -306,7 +306,7 @@ |
||
306 | 306 | * @param int Whether the announcement should be visible to anonymous users (1) or not (0) |
307 | 307 | * @param string The language for which the announvement should be shown. Leave null for all langages |
308 | 308 | * @param int Whether to send an e-mail to all users (1) or not (0) |
309 | - * @return mixed insert_id on success, false on failure |
|
309 | + * @return false|string insert_id on success, false on failure |
|
310 | 310 | */ |
311 | 311 | public static function add_announcement( |
312 | 312 | $title, |
@@ -22,14 +22,14 @@ discard block |
||
22 | 22 | $tbl_announcement_group = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS_GROUPS); |
23 | 23 | $userGroup = new UserGroup(); |
24 | 24 | |
25 | - $temp_user_groups = $userGroup->get_groups_by_user(api_get_user_id(),0); |
|
25 | + $temp_user_groups = $userGroup->get_groups_by_user(api_get_user_id(), 0); |
|
26 | 26 | $groups = array(); |
27 | 27 | foreach ($temp_user_groups as $user_group) { |
28 | 28 | $groups = array_merge($groups, array($user_group['id'])); |
29 | 29 | $groups = array_merge($groups, $userGroup->get_parent_groups($user_group['id'])); |
30 | 30 | } |
31 | 31 | |
32 | - $groups_string = '('.implode($groups,',').')'; |
|
32 | + $groups_string = '('.implode($groups, ',').')'; |
|
33 | 33 | $now = api_get_utc_datetime(); |
34 | 34 | $sql = "SELECT *, DATE_FORMAT(date_start,'%d-%m-%Y %h:%i:%s') AS display_date |
35 | 35 | FROM $db_table |
@@ -104,13 +104,13 @@ discard block |
||
104 | 104 | * @param string $user_id |
105 | 105 | * @return string |
106 | 106 | */ |
107 | - public static function display_all_announcements($visible, $id = -1, $start = 0,$user_id='') |
|
107 | + public static function display_all_announcements($visible, $id = -1, $start = 0, $user_id = '') |
|
108 | 108 | { |
109 | 109 | $user_selected_language = api_get_interface_language(); |
110 | - $start = intval($start); |
|
110 | + $start = intval($start); |
|
111 | 111 | $userGroup = new UserGroup(); |
112 | 112 | $tbl_announcement_group = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS_GROUPS); |
113 | - $temp_user_groups = $userGroup->get_groups_by_user(api_get_user_id(),0); |
|
113 | + $temp_user_groups = $userGroup->get_groups_by_user(api_get_user_id(), 0); |
|
114 | 114 | $groups = array(); |
115 | 115 | foreach ($temp_user_groups as $user_group) { |
116 | 116 | $groups = array_merge($groups, array($user_group['id'])); |
@@ -118,10 +118,10 @@ discard block |
||
118 | 118 | } |
119 | 119 | |
120 | 120 | // Checks if tables exists to not break platform not updated |
121 | - $groups_string = '('.implode($groups,',').')'; |
|
121 | + $groups_string = '('.implode($groups, ',').')'; |
|
122 | 122 | |
123 | 123 | $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
124 | - $now = api_get_utc_datetime(); |
|
124 | + $now = api_get_utc_datetime(); |
|
125 | 125 | |
126 | 126 | $sql = "SELECT * FROM ".$db_table." |
127 | 127 | WHERE |
@@ -152,10 +152,10 @@ discard block |
||
152 | 152 | $sql .= " AND access_url_id IN ('1', '$current_access_url_id')"; |
153 | 153 | } |
154 | 154 | |
155 | - if(!isset($_GET['start']) || $_GET['start'] == 0) { |
|
155 | + if (!isset($_GET['start']) || $_GET['start'] == 0) { |
|
156 | 156 | $sql .= " ORDER BY date_start DESC LIMIT ".$start.",20"; |
157 | 157 | } else { |
158 | - $sql .= " ORDER BY date_start DESC LIMIT ".($start+1).",20"; |
|
158 | + $sql .= " ORDER BY date_start DESC LIMIT ".($start + 1).",20"; |
|
159 | 159 | } |
160 | 160 | $announcements = Database::query($sql); |
161 | 161 | $content = ''; |
@@ -204,10 +204,10 @@ discard block |
||
204 | 204 | */ |
205 | 205 | public static function display_arrow($user_id) |
206 | 206 | { |
207 | - $start = (int)$_GET['start']; |
|
207 | + $start = (int) $_GET['start']; |
|
208 | 208 | $nb_announcement = SystemAnnouncementManager :: count_nb_announcement($start, $user_id); |
209 | - $next = ((int)$_GET['start']+19); |
|
210 | - $prev = ((int)$_GET['start']-19); |
|
209 | + $next = ((int) $_GET['start'] + 19); |
|
210 | + $prev = ((int) $_GET['start'] - 19); |
|
211 | 211 | $content = ''; |
212 | 212 | if (!isset($_GET['start']) || $_GET['start'] == 0) { |
213 | 213 | if ($nb_announcement > 20) { |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | $sendEmailTest |
565 | 565 | ); |
566 | 566 | } else { |
567 | - if ($send_mail==1) { |
|
567 | + if ($send_mail == 1) { |
|
568 | 568 | SystemAnnouncementManager::send_system_announcement_by_email( |
569 | 569 | $title, |
570 | 570 | $content, |
@@ -675,7 +675,7 @@ discard block |
||
675 | 675 | $language = null, |
676 | 676 | $sendEmailTest = false |
677 | 677 | ) { |
678 | - $content = str_replace(array('\r\n', '\n', '\r'),'', $content); |
|
678 | + $content = str_replace(array('\r\n', '\n', '\r'), '', $content); |
|
679 | 679 | $now = api_get_utc_datetime(); |
680 | 680 | |
681 | 681 | if ($sendEmailTest) { |
@@ -701,7 +701,7 @@ discard block |
||
701 | 701 | WHERE status = '5' "; |
702 | 702 | } |
703 | 703 | |
704 | - if ($teacher<> 0 && $student <> 0) { |
|
704 | + if ($teacher <> 0 && $student <> 0) { |
|
705 | 705 | $sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition |
706 | 706 | WHERE 1 = 1 "; |
707 | 707 | } |
@@ -734,7 +734,7 @@ discard block |
||
734 | 734 | |
735 | 735 | $message_sent = false; |
736 | 736 | |
737 | - while ($row = Database::fetch_array($result,'ASSOC')) { |
|
737 | + while ($row = Database::fetch_array($result, 'ASSOC')) { |
|
738 | 738 | MessageManager::send_message_simple($row['user_id'], $title, $content); |
739 | 739 | $message_sent = true; |
740 | 740 | } |
@@ -755,7 +755,7 @@ discard block |
||
755 | 755 | $cut_size = 500; |
756 | 756 | $now = api_get_utc_datetime(); |
757 | 757 | |
758 | - $sql = "SELECT * FROM " . $table . " |
|
758 | + $sql = "SELECT * FROM ".$table." |
|
759 | 759 | WHERE |
760 | 760 | (lang = '$user_selected_language' OR lang = '') AND |
761 | 761 | ('$now' >= date_start AND '$now' <= date_end) "; |
@@ -10,12 +10,12 @@ discard block |
||
10 | 10 | const VISIBLE_STUDENT = 2; |
11 | 11 | const VISIBLE_TEACHER = 3; |
12 | 12 | |
13 | - /** |
|
14 | - * Displays all announcements |
|
15 | - * @param int $visible VISIBLE_GUEST, VISIBLE_STUDENT or VISIBLE_TEACHER |
|
16 | - * @param int $id The identifier of the announcement to display |
|
17 | - */ |
|
18 | - public static function display_announcements($visible, $id = -1) |
|
13 | + /** |
|
14 | + * Displays all announcements |
|
15 | + * @param int $visible VISIBLE_GUEST, VISIBLE_STUDENT or VISIBLE_TEACHER |
|
16 | + * @param int $id The identifier of the announcement to display |
|
17 | + */ |
|
18 | + public static function display_announcements($visible, $id = -1) |
|
19 | 19 | { |
20 | 20 | $user_selected_language = api_get_interface_language(); |
21 | 21 | $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
@@ -423,10 +423,10 @@ discard block |
||
423 | 423 | } |
424 | 424 | |
425 | 425 | /** |
426 | - * Makes the announcement id visible only for groups in groups_array |
|
427 | - * @param int $announcement_id |
|
428 | - * @param array $group_array array of group id |
|
429 | - **/ |
|
426 | + * Makes the announcement id visible only for groups in groups_array |
|
427 | + * @param int $announcement_id |
|
428 | + * @param array $group_array array of group id |
|
429 | + **/ |
|
430 | 430 | public static function announcement_for_groups($announcement_id, $group_array) |
431 | 431 | { |
432 | 432 | $tbl_announcement_group = Database:: get_main_table( |
@@ -459,10 +459,10 @@ discard block |
||
459 | 459 | } |
460 | 460 | |
461 | 461 | /** |
462 | - * Gets the groups of this announce |
|
463 | - * @param int announcement id |
|
464 | - * @return array array of group id |
|
465 | - **/ |
|
462 | + * Gets the groups of this announce |
|
463 | + * @param int announcement id |
|
464 | + * @return array array of group id |
|
465 | + **/ |
|
466 | 466 | public static function get_announcement_groups($announcement_id) |
467 | 467 | { |
468 | 468 | $tbl_announcement_group = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS_GROUPS); |
@@ -482,15 +482,15 @@ discard block |
||
482 | 482 | return $groups; |
483 | 483 | } |
484 | 484 | |
485 | - /** |
|
486 | - * Updates an announcement to the database |
|
487 | - * @param integer $id : id of the announcement |
|
488 | - * @param string $title : title of the announcement |
|
489 | - * @param string $content : content of the announcement |
|
490 | - * @param array $date_start: start date of announcement (0 => day ; 1 => month ; 2 => year ; 3 => hour ; 4 => minute) |
|
491 | - * @param array $date_end : end date of announcement (0 => day ; 1 => month ; 2 => year ; 3 => hour ; 4 => minute) |
|
492 | - * @return bool True on success, false on failure |
|
493 | - */ |
|
485 | + /** |
|
486 | + * Updates an announcement to the database |
|
487 | + * @param integer $id : id of the announcement |
|
488 | + * @param string $title : title of the announcement |
|
489 | + * @param string $content : content of the announcement |
|
490 | + * @param array $date_start: start date of announcement (0 => day ; 1 => month ; 2 => year ; 3 => hour ; 4 => minute) |
|
491 | + * @param array $date_end : end date of announcement (0 => day ; 1 => month ; 2 => year ; 3 => hour ; 4 => minute) |
|
492 | + * @return bool True on success, false on failure |
|
493 | + */ |
|
494 | 494 | public static function update_announcement( |
495 | 495 | $id, |
496 | 496 | $title, |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | $sendEmailTest = false |
506 | 506 | ) { |
507 | 507 | $em = Database::getManager(); |
508 | - $announcement = $em->find('ChamiloCoreBundle:SysAnnouncement', $id); |
|
508 | + $announcement = $em->find('ChamiloCoreBundle:SysAnnouncement', $id); |
|
509 | 509 | |
510 | 510 | if (!$announcement) { |
511 | 511 | return false; |
@@ -529,28 +529,28 @@ discard block |
||
529 | 529 | return false; |
530 | 530 | } |
531 | 531 | |
532 | - if (($date_end_to_compare[1] || |
|
532 | + if (($date_end_to_compare[1] || |
|
533 | 533 | $date_end_to_compare[2] || |
534 | 534 | $date_end_to_compare[0]) && |
535 | 535 | !checkdate($date_end_to_compare[1], $date_end_to_compare[2], $date_end_to_compare[0]) |
536 | 536 | ) { |
537 | - Display :: display_normal_message(get_lang('InvalidEndDate')); |
|
537 | + Display :: display_normal_message(get_lang('InvalidEndDate')); |
|
538 | 538 | |
539 | - return false; |
|
540 | - } |
|
539 | + return false; |
|
540 | + } |
|
541 | 541 | |
542 | - if (strlen(trim($title)) == 0) { |
|
543 | - Display::display_normal_message(get_lang('InvalidTitle')); |
|
542 | + if (strlen(trim($title)) == 0) { |
|
543 | + Display::display_normal_message(get_lang('InvalidTitle')); |
|
544 | 544 | |
545 | - return false; |
|
546 | - } |
|
545 | + return false; |
|
546 | + } |
|
547 | 547 | |
548 | 548 | $start = api_get_utc_datetime($date_start); |
549 | 549 | $end = api_get_utc_datetime($date_end); |
550 | 550 | |
551 | - //Fixing urls that are sent by email |
|
552 | - //$content = str_replace('src=\"/home/', 'src=\"'.api_get_path(WEB_PATH).'home/', $content); |
|
553 | - //$content = str_replace('file=/home/', 'file='.api_get_path(WEB_PATH).'home/', $content); |
|
551 | + //Fixing urls that are sent by email |
|
552 | + //$content = str_replace('src=\"/home/', 'src=\"'.api_get_path(WEB_PATH).'home/', $content); |
|
553 | + //$content = str_replace('file=/home/', 'file='.api_get_path(WEB_PATH).'home/', $content); |
|
554 | 554 | $content = str_replace('src=\"'.api_get_path(REL_HOME_PATH), 'src=\"'.api_get_path(WEB_PATH).api_get_path(REL_HOME_PATH), $content); |
555 | 555 | $content = str_replace('file='.api_get_path(REL_HOME_PATH), 'file='.api_get_path(WEB_PATH).api_get_path(REL_HOME_PATH), $content); |
556 | 556 | |
@@ -592,81 +592,81 @@ discard block |
||
592 | 592 | $em->merge($announcement); |
593 | 593 | $em->flush(); |
594 | 594 | |
595 | - return true; |
|
596 | - } |
|
595 | + return true; |
|
596 | + } |
|
597 | 597 | |
598 | - /** |
|
599 | - * Deletes an announcement |
|
600 | - * @param int $id The identifier of the announcement that should be |
|
601 | - * @return bool True on success, false on failure |
|
602 | - */ |
|
603 | - public static function delete_announcement($id) |
|
598 | + /** |
|
599 | + * Deletes an announcement |
|
600 | + * @param int $id The identifier of the announcement that should be |
|
601 | + * @return bool True on success, false on failure |
|
602 | + */ |
|
603 | + public static function delete_announcement($id) |
|
604 | 604 | { |
605 | - $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
606 | - $id = intval($id); |
|
607 | - $sql = "DELETE FROM ".$db_table." WHERE id =".$id; |
|
608 | - $res = Database::query($sql); |
|
605 | + $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
606 | + $id = intval($id); |
|
607 | + $sql = "DELETE FROM ".$db_table." WHERE id =".$id; |
|
608 | + $res = Database::query($sql); |
|
609 | 609 | if ($res === false) { |
610 | - return false; |
|
611 | - } |
|
612 | - return true; |
|
613 | - } |
|
614 | - |
|
615 | - /** |
|
616 | - * Gets an announcement |
|
617 | - * @param int $id The identifier of the announcement that should be |
|
618 | - * @return object Object of class StdClass or the required class, containing the query result row |
|
619 | - */ |
|
620 | - public static function get_announcement($id) |
|
610 | + return false; |
|
611 | + } |
|
612 | + return true; |
|
613 | + } |
|
614 | + |
|
615 | + /** |
|
616 | + * Gets an announcement |
|
617 | + * @param int $id The identifier of the announcement that should be |
|
618 | + * @return object Object of class StdClass or the required class, containing the query result row |
|
619 | + */ |
|
620 | + public static function get_announcement($id) |
|
621 | 621 | { |
622 | - $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
623 | - $id = intval($id); |
|
624 | - $sql = "SELECT * FROM ".$db_table." WHERE id = ".$id; |
|
625 | - $announcement = Database::fetch_object(Database::query($sql)); |
|
626 | - |
|
627 | - return $announcement; |
|
628 | - } |
|
629 | - |
|
630 | - /** |
|
631 | - * Change the visibility of an announcement |
|
632 | - * @param int $announcement_id |
|
633 | - * @param int $user For who should the visibility be changed |
|
622 | + $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
623 | + $id = intval($id); |
|
624 | + $sql = "SELECT * FROM ".$db_table." WHERE id = ".$id; |
|
625 | + $announcement = Database::fetch_object(Database::query($sql)); |
|
626 | + |
|
627 | + return $announcement; |
|
628 | + } |
|
629 | + |
|
630 | + /** |
|
631 | + * Change the visibility of an announcement |
|
632 | + * @param int $announcement_id |
|
633 | + * @param int $user For who should the visibility be changed |
|
634 | 634 | * (possible values are VISIBLE_TEACHER, VISIBLE_STUDENT, VISIBLE_GUEST) |
635 | - * @return bool True on success, false on failure |
|
636 | - */ |
|
637 | - public static function set_visibility($announcement_id, $user, $visible) |
|
635 | + * @return bool True on success, false on failure |
|
636 | + */ |
|
637 | + public static function set_visibility($announcement_id, $user, $visible) |
|
638 | 638 | { |
639 | - $db_table = Database::get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
640 | - $visible = intval($visible); |
|
641 | - $announcement_id = intval($announcement_id); |
|
639 | + $db_table = Database::get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
640 | + $visible = intval($visible); |
|
641 | + $announcement_id = intval($announcement_id); |
|
642 | 642 | |
643 | 643 | if (!in_array($user, array(self::VISIBLE_GUEST, self::VISIBLE_STUDENT, self::VISIBLE_TEACHER))) { |
644 | 644 | return false; |
645 | 645 | } |
646 | 646 | |
647 | - $field = ($user == self::VISIBLE_TEACHER ? 'visible_teacher' : ($user == self::VISIBLE_STUDENT ? 'visible_student' : 'visible_guest')); |
|
647 | + $field = ($user == self::VISIBLE_TEACHER ? 'visible_teacher' : ($user == self::VISIBLE_STUDENT ? 'visible_student' : 'visible_guest')); |
|
648 | 648 | |
649 | - $sql = "UPDATE ".$db_table." SET ".$field." = '".$visible."' |
|
649 | + $sql = "UPDATE ".$db_table." SET ".$field." = '".$visible."' |
|
650 | 650 | WHERE id='".$announcement_id."'"; |
651 | - $res = Database::query($sql); |
|
652 | - |
|
653 | - if ($res === false) { |
|
654 | - return false; |
|
655 | - } |
|
656 | - |
|
657 | - return true; |
|
658 | - } |
|
659 | - |
|
660 | - /** |
|
661 | - * Send a system announcement by e-mail to all teachers/students depending on parameters |
|
662 | - * @param string $title |
|
663 | - * @param string $content |
|
664 | - * @param int $teacher Whether to send to all teachers (1) or not (0) |
|
665 | - * @param int $student Whether to send to all students (1) or not (0) |
|
666 | - * @param string $language Language (optional, considered for all languages if left empty) |
|
651 | + $res = Database::query($sql); |
|
652 | + |
|
653 | + if ($res === false) { |
|
654 | + return false; |
|
655 | + } |
|
656 | + |
|
657 | + return true; |
|
658 | + } |
|
659 | + |
|
660 | + /** |
|
661 | + * Send a system announcement by e-mail to all teachers/students depending on parameters |
|
662 | + * @param string $title |
|
663 | + * @param string $content |
|
664 | + * @param int $teacher Whether to send to all teachers (1) or not (0) |
|
665 | + * @param int $student Whether to send to all students (1) or not (0) |
|
666 | + * @param string $language Language (optional, considered for all languages if left empty) |
|
667 | 667 | * @param bool $sendEmailTest |
668 | 668 | * @return bool True if the message was sent or there was no destination matching. False on database or e-mail sending error. |
669 | - */ |
|
669 | + */ |
|
670 | 670 | public static function send_system_announcement_by_email( |
671 | 671 | $title, |
672 | 672 | $content, |
@@ -692,26 +692,26 @@ discard block |
||
692 | 692 | } |
693 | 693 | |
694 | 694 | if ($teacher <> 0 && $student == 0) { |
695 | - $sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition |
|
695 | + $sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition |
|
696 | 696 | WHERE status = '1' "; |
697 | - } |
|
697 | + } |
|
698 | 698 | |
699 | - if ($teacher == 0 && $student <> 0) { |
|
700 | - $sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition |
|
699 | + if ($teacher == 0 && $student <> 0) { |
|
700 | + $sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition |
|
701 | 701 | WHERE status = '5' "; |
702 | - } |
|
702 | + } |
|
703 | 703 | |
704 | - if ($teacher<> 0 && $student <> 0) { |
|
705 | - $sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition |
|
704 | + if ($teacher<> 0 && $student <> 0) { |
|
705 | + $sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition |
|
706 | 706 | WHERE 1 = 1 "; |
707 | - } |
|
707 | + } |
|
708 | 708 | |
709 | - if (!empty($language)) { |
|
710 | - //special condition because language was already treated for SQL insert before |
|
711 | - $sql .= " AND language = '".Database::escape_string($language)."' "; |
|
712 | - } |
|
709 | + if (!empty($language)) { |
|
710 | + //special condition because language was already treated for SQL insert before |
|
711 | + $sql .= " AND language = '".Database::escape_string($language)."' "; |
|
712 | + } |
|
713 | 713 | |
714 | - if (api_is_multiple_url_enabled()) { |
|
714 | + if (api_is_multiple_url_enabled()) { |
|
715 | 715 | $sql .= " AND access_url_id = '".$current_access_url_id."' "; |
716 | 716 | } |
717 | 717 | |
@@ -721,36 +721,36 @@ discard block |
||
721 | 721 | // Expiration date |
722 | 722 | $sql .= " AND (expiration_date = '' OR expiration_date IS NULL OR expiration_date > '$now') "; |
723 | 723 | |
724 | - if ((empty($teacher) || $teacher == '0') && (empty($student) || $student == '0')) { |
|
724 | + if ((empty($teacher) || $teacher == '0') && (empty($student) || $student == '0')) { |
|
725 | 725 | |
726 | - return true; |
|
727 | - } |
|
726 | + return true; |
|
727 | + } |
|
728 | 728 | |
729 | - $result = Database::query($sql); |
|
730 | - if ($result === false) { |
|
729 | + $result = Database::query($sql); |
|
730 | + if ($result === false) { |
|
731 | 731 | |
732 | - return false; |
|
733 | - } |
|
732 | + return false; |
|
733 | + } |
|
734 | 734 | |
735 | 735 | $message_sent = false; |
736 | 736 | |
737 | - while ($row = Database::fetch_array($result,'ASSOC')) { |
|
737 | + while ($row = Database::fetch_array($result,'ASSOC')) { |
|
738 | 738 | MessageManager::send_message_simple($row['user_id'], $title, $content); |
739 | 739 | $message_sent = true; |
740 | - } |
|
740 | + } |
|
741 | 741 | |
742 | - // Minor validation to clean up the attachment files in the announcement |
|
743 | - if (!empty($_FILES)) { |
|
744 | - $attachments = $_FILES; |
|
745 | - foreach ($attachments as $attachment) { |
|
746 | - unlink($attachment['tmp_name']); |
|
747 | - } |
|
748 | - } |
|
749 | - |
|
750 | - return $message_sent; //true if at least one e-mail was sent |
|
751 | - } |
|
752 | - |
|
753 | - /** |
|
742 | + // Minor validation to clean up the attachment files in the announcement |
|
743 | + if (!empty($_FILES)) { |
|
744 | + $attachments = $_FILES; |
|
745 | + foreach ($attachments as $attachment) { |
|
746 | + unlink($attachment['tmp_name']); |
|
747 | + } |
|
748 | + } |
|
749 | + |
|
750 | + return $message_sent; //true if at least one e-mail was sent |
|
751 | + } |
|
752 | + |
|
753 | + /** |
|
754 | 754 | * Displays announcements as an slideshow |
755 | 755 | * @param int $visible VISIBLE_GUEST, VISIBLE_STUDENT or VISIBLE_TEACHER |
756 | 756 | * @param int $id The identifier of the announcement to display |