@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | api_block_anonymous_users(); |
18 | 18 | |
19 | 19 | $interbreadcrumb[] = array( |
20 | - "url" => api_is_student_boss()?"#":api_get_path(WEB_CODE_PATH) . "mySpace/index.php?".api_get_cidreq(), |
|
20 | + "url" => api_is_student_boss() ? "#" : api_get_path(WEB_CODE_PATH)."mySpace/index.php?".api_get_cidreq(), |
|
21 | 21 | "name" => get_lang("MySpace") |
22 | 22 | ); |
23 | 23 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | } |
112 | 112 | |
113 | 113 | if (!is_null($gradebook)) { |
114 | - $exportAllLink = api_get_path(WEB_CODE_PATH) . "gradebook/gradebook_display_certificate.php?"; |
|
114 | + $exportAllLink = api_get_path(WEB_CODE_PATH)."gradebook/gradebook_display_certificate.php?"; |
|
115 | 115 | $exportAllLink .= http_build_query(array( |
116 | 116 | "action" => "export_all_certificates", |
117 | 117 | "cidReq" => $selectedCourseInfo['code'], |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | $searchBySessionCourseDateForm = new FormValidator( |
251 | 251 | 'certificate_report_form', |
252 | 252 | 'post', |
253 | - api_get_path(WEB_CODE_PATH) . 'gradebook/certificate_report.php' |
|
253 | + api_get_path(WEB_CODE_PATH).'gradebook/certificate_report.php' |
|
254 | 254 | ); |
255 | 255 | $searchBySessionCourseDateForm->addSelect('session', get_lang('Sessions'), $sessions, ['id' => 'session']); |
256 | 256 | $searchBySessionCourseDateForm->addSelect('course', get_lang('Courses'), $courses, ['id' => 'course']); |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | $searchByStudentForm = new FormValidator( |
284 | 284 | 'certificate_report_form', |
285 | 285 | 'post', |
286 | - api_get_path(WEB_CODE_PATH) . 'gradebook/certificate_report.php' |
|
286 | + api_get_path(WEB_CODE_PATH).'gradebook/certificate_report.php' |
|
287 | 287 | ); |
288 | 288 | $searchByStudentForm->addSelect('student', get_lang('Students'), $students, ['id' => 'student']); |
289 | 289 | $searchByStudentForm->addButtonSearch(); |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | api_not_allowed(true); |
17 | 17 | } |
18 | 18 | |
19 | -$interbreadcrumb[] = array ('url' => api_is_student_boss()?'#':'index.php', 'name' => get_lang('MySpace')); |
|
19 | +$interbreadcrumb[] = array('url' => api_is_student_boss() ? '#' : 'index.php', 'name' => get_lang('MySpace')); |
|
20 | 20 | $tool_name = get_lang('Report'); |
21 | 21 | |
22 | 22 | $this_section = SECTION_TRACKING; |
@@ -42,13 +42,13 @@ discard block |
||
42 | 42 | |
43 | 43 | //Column config |
44 | 44 | $column_model = array( |
45 | - array('name'=>'course', 'index'=>'title', 'width'=>'180', 'align'=>'left', 'wrap_cell' => 'true'), |
|
46 | - array('name'=>'user', 'index'=>'user', 'width'=>'100', 'align'=>'left','sortable'=>'false', 'wrap_cell' => 'true'), |
|
47 | - array('name'=>'email', 'index'=>'email', 'width'=>'100', 'align'=>'left','sortable'=>'false', 'wrap_cell' => 'true'), |
|
48 | - array('name'=>'time', 'index'=>'time', 'width'=>'50', 'align'=>'left','sortable'=>'false'), |
|
49 | - array('name'=>'certificate', 'index'=>'certificate', 'width'=>'50', 'align'=>'left','sortable'=>'false'), |
|
50 | - array('name'=>'progress_100', 'index'=>'progress_100', 'width'=>'50', 'align'=>'left','sortable'=>'false'), |
|
51 | - array('name'=>'progress', 'index'=>'progress', 'width'=>'50', 'align'=>'left','sortable'=>'false') |
|
45 | + array('name'=>'course', 'index'=>'title', 'width'=>'180', 'align'=>'left', 'wrap_cell' => 'true'), |
|
46 | + array('name'=>'user', 'index'=>'user', 'width'=>'100', 'align'=>'left', 'sortable'=>'false', 'wrap_cell' => 'true'), |
|
47 | + array('name'=>'email', 'index'=>'email', 'width'=>'100', 'align'=>'left', 'sortable'=>'false', 'wrap_cell' => 'true'), |
|
48 | + array('name'=>'time', 'index'=>'time', 'width'=>'50', 'align'=>'left', 'sortable'=>'false'), |
|
49 | + array('name'=>'certificate', 'index'=>'certificate', 'width'=>'50', 'align'=>'left', 'sortable'=>'false'), |
|
50 | + array('name'=>'progress_100', 'index'=>'progress_100', 'width'=>'50', 'align'=>'left', 'sortable'=>'false'), |
|
51 | + array('name'=>'progress', 'index'=>'progress', 'width'=>'50', 'align'=>'left', 'sortable'=>'false') |
|
52 | 52 | ); |
53 | 53 | |
54 | 54 | if (!empty($extra_fields)) { |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | } |
68 | 68 | |
69 | 69 | if (api_is_student_boss()) { |
70 | - $column_model[] = array('name'=>'group', 'index'=>'group', 'width'=>'50', 'align'=>'left','sortable'=>'false'); |
|
70 | + $column_model[] = array('name'=>'group', 'index'=>'group', 'width'=>'50', 'align'=>'left', 'sortable'=>'false'); |
|
71 | 71 | $columns[] = get_lang('Group'); |
72 | 72 | } |
73 | 73 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | |
79 | 79 | $htmlHeadXtra[] = '<script> |
80 | 80 | $(function() { |
81 | - '.Display::grid_js('user_course_report', $url, $columns, $column_model, $extra_params, array(), null, true).' |
|
81 | + '.Display::grid_js('user_course_report', $url, $columns, $column_model, $extra_params, array(), null, true).' |
|
82 | 82 | jQuery("#user_course_report").jqGrid("navGrid","#user_course_report_pager",{ |
83 | 83 | view:false, |
84 | 84 | edit:false, |
@@ -102,11 +102,11 @@ discard block |
||
102 | 102 | if (api_is_student_boss()) { |
103 | 103 | $actions .= Display::url( |
104 | 104 | Display::return_icon('stats.png', get_lang('MyStats'), '', ICON_SIZE_MEDIUM), |
105 | - api_get_path(WEB_CODE_PATH) . "auth/my_progress.php" |
|
105 | + api_get_path(WEB_CODE_PATH)."auth/my_progress.php" |
|
106 | 106 | ); |
107 | 107 | $actions .= Display::url( |
108 | 108 | Display::return_icon('user.png', get_lang('Students'), array(), ICON_SIZE_MEDIUM), |
109 | - api_get_path(WEB_CODE_PATH) . "mySpace/student.php" |
|
109 | + api_get_path(WEB_CODE_PATH)."mySpace/student.php" |
|
110 | 110 | ); |
111 | 111 | $actions .= Display::url( |
112 | 112 | Display::return_icon("statistics.png", get_lang("CompanyReport"), array(), ICON_SIZE_MEDIUM), |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | [], |
120 | 120 | ICON_SIZE_MEDIUM |
121 | 121 | ), |
122 | - api_get_path(WEB_CODE_PATH) . "gradebook/certificate_report.php" |
|
122 | + api_get_path(WEB_CODE_PATH)."gradebook/certificate_report.php" |
|
123 | 123 | ); |
124 | 124 | } |
125 | 125 | |
@@ -130,13 +130,13 @@ discard block |
||
130 | 130 | } |
131 | 131 | $content .= Display::url( |
132 | 132 | get_lang("CompanyReportResumed"), |
133 | - api_get_path(WEB_CODE_PATH) . "mySpace/company_reports_resumed.php", |
|
133 | + api_get_path(WEB_CODE_PATH)."mySpace/company_reports_resumed.php", |
|
134 | 134 | array( |
135 | 135 | 'class' => 'btn btn-success' |
136 | 136 | ) |
137 | 137 | ); |
138 | 138 | $content .= '</div>'; |
139 | -$content .= '<h1 class="page-header">' . get_lang('CompanyReport') . '</h1>'; |
|
139 | +$content .= '<h1 class="page-header">'.get_lang('CompanyReport').'</h1>'; |
|
140 | 140 | $content .= Display::grid_html('user_course_report'); |
141 | 141 | |
142 | 142 | $tpl = new Template($tool_name); |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | api_not_allowed(true); |
16 | 16 | } |
17 | 17 | |
18 | -$interbreadcrumb[] = array('url' => api_is_student_boss()?'#':'index.php', 'name' => get_lang('MySpace')); |
|
18 | +$interbreadcrumb[] = array('url' => api_is_student_boss() ? '#' : 'index.php', 'name' => get_lang('MySpace')); |
|
19 | 19 | |
20 | 20 | $tool_name = get_lang('Report'); |
21 | 21 | $this_section = SECTION_TRACKING; |
@@ -89,15 +89,15 @@ discard block |
||
89 | 89 | if (api_is_student_boss()) { |
90 | 90 | $actions .= Display::url( |
91 | 91 | Display::return_icon('stats.png', get_lang('MyStats'), '', ICON_SIZE_MEDIUM), |
92 | - api_get_path(WEB_CODE_PATH) . "auth/my_progress.php" |
|
92 | + api_get_path(WEB_CODE_PATH)."auth/my_progress.php" |
|
93 | 93 | ); |
94 | 94 | $actions .= Display::url( |
95 | 95 | Display::return_icon('user.png', get_lang('Students'), array(), ICON_SIZE_MEDIUM), |
96 | - api_get_path(WEB_CODE_PATH) . "mySpace/student.php" |
|
96 | + api_get_path(WEB_CODE_PATH)."mySpace/student.php" |
|
97 | 97 | ); |
98 | 98 | $actions .= Display::url( |
99 | 99 | Display::return_icon("statistics.png", get_lang("CompanyReport"), array(), ICON_SIZE_MEDIUM), |
100 | - api_get_path(WEB_CODE_PATH) . "mySpace/company_reports.php" |
|
100 | + api_get_path(WEB_CODE_PATH)."mySpace/company_reports.php" |
|
101 | 101 | ); |
102 | 102 | $actions .= Display::url( |
103 | 103 | Display::return_icon( |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | [], |
107 | 107 | ICON_SIZE_MEDIUM |
108 | 108 | ), |
109 | - api_get_path(WEB_CODE_PATH) . "gradebook/certificate_report.php" |
|
109 | + api_get_path(WEB_CODE_PATH)."gradebook/certificate_report.php" |
|
110 | 110 | ); |
111 | 111 | } |
112 | 112 | |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | if (!api_is_student_boss()) { |
120 | 120 | $content .= Display::url( |
121 | 121 | get_lang("CompanyReport"), |
122 | - api_get_path(WEB_CODE_PATH) . "mySpace/company_reports.php", |
|
122 | + api_get_path(WEB_CODE_PATH)."mySpace/company_reports.php", |
|
123 | 123 | array( |
124 | 124 | 'class' => 'btn btn-success' |
125 | 125 | ) |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | } |
128 | 128 | |
129 | 129 | $content .= '</div>'; |
130 | -$content .= '<h1 class="page-header">' . get_lang('CompanyReportResumed') . '</h1>'; |
|
130 | +$content .= '<h1 class="page-header">'.get_lang('CompanyReportResumed').'</h1>'; |
|
131 | 131 | $content .= Display::grid_html('user_course_report'); |
132 | 132 | |
133 | 133 | $tpl = new Template($tool_name); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | Display::addFlash( |
48 | 48 | Display::return_message($messageText, 'info', false) |
49 | 49 | ); |
50 | - header('Location: ' . api_get_path(WEB_PATH)); |
|
50 | + header('Location: '.api_get_path(WEB_PATH)); |
|
51 | 51 | exit; |
52 | 52 | } |
53 | 53 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | Display::addFlash( |
75 | 75 | Display::return_message($messageText, 'error', false) |
76 | 76 | ); |
77 | - header('Location: ' . api_get_self()); |
|
77 | + header('Location: '.api_get_self()); |
|
78 | 78 | exit; |
79 | 79 | } |
80 | 80 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | Display::addFlash( |
95 | 95 | Display::return_message($messageText, 'info', false) |
96 | 96 | ); |
97 | - header('Location: ' . api_get_path(WEB_PATH)); |
|
97 | + header('Location: '.api_get_path(WEB_PATH)); |
|
98 | 98 | exit; |
99 | 99 | } |
100 | 100 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | Display::addFlash( |
103 | 103 | Display::return_message(get_lang('CouldNotResetPassword'), 'info', false) |
104 | 104 | ); |
105 | - header('Location: ' . api_get_path(WEB_PATH)); |
|
105 | + header('Location: '.api_get_path(WEB_PATH)); |
|
106 | 106 | exit; |
107 | 107 | } |
108 | 108 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | exit; |
122 | 122 | } |
123 | 123 | |
124 | - header('Location: ' . api_get_path(WEB_PATH)); |
|
124 | + header('Location: '.api_get_path(WEB_PATH)); |
|
125 | 125 | exit; |
126 | 126 | } |
127 | 127 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | Display::addFlash( |
139 | 139 | Display::return_message($messageText, 'info', false) |
140 | 140 | ); |
141 | - header('Location: ' . api_get_path(WEB_PATH)); |
|
141 | + header('Location: '.api_get_path(WEB_PATH)); |
|
142 | 142 | exit; |
143 | 143 | } |
144 | 144 |
@@ -38,9 +38,9 @@ |
||
38 | 38 | api_not_allowed(true); |
39 | 39 | } |
40 | 40 | |
41 | -$courseDir = $_course['path'] . "/document"; |
|
41 | +$courseDir = $_course['path']."/document"; |
|
42 | 42 | $sys_course_path = api_get_path(SYS_COURSE_PATH); |
43 | -$base_work_dir = $sys_course_path . $courseDir; |
|
43 | +$base_work_dir = $sys_course_path.$courseDir; |
|
44 | 44 | $noPHP_SELF = true; |
45 | 45 | $max_filled_space = DocumentManager::get_course_quota(); |
46 | 46 |
@@ -39,7 +39,7 @@ |
||
39 | 39 | $doc_url = str_replace(' ', '+', $doc_url); |
40 | 40 | $doc_url = str_replace(array('../', '\\..', '\\0', '..\\'), array('', '', '', ''), $doc_url); //echo $doc_url; |
41 | 41 | |
42 | -if (strpos($doc_url,'../') || strpos($doc_url,'/..')) { |
|
42 | +if (strpos($doc_url, '../') || strpos($doc_url, '/..')) { |
|
43 | 43 | $doc_url = ''; |
44 | 44 | } |
45 | 45 |
@@ -31,13 +31,13 @@ discard block |
||
31 | 31 | global $VCRON; |
32 | 32 | |
33 | 33 | $VCRON = new StdClass; |
34 | -$VCRON->ACTIVATION = 'cli'; // choose how individual cron are launched, 'cli' or 'web' |
|
35 | -$VCRON->STRATEGY = ROUND_ROBIN ; // choose vcron rotation mode |
|
36 | -$VCRON->PERIOD = 15 * MINSECS ; // used if LOWEST_POSSIBLE_GAP to setup the max gap |
|
37 | -$VCRON->TIMEOUT = 300; // time out for CURL call to effective cron |
|
34 | +$VCRON->ACTIVATION = 'cli'; // choose how individual cron are launched, 'cli' or 'web' |
|
35 | +$VCRON->STRATEGY = ROUND_ROBIN; // choose vcron rotation mode |
|
36 | +$VCRON->PERIOD = 15 * MINSECS; // used if LOWEST_POSSIBLE_GAP to setup the max gap |
|
37 | +$VCRON->TIMEOUT = 300; // time out for CURL call to effective cron |
|
38 | 38 | // $VCRON->TRACE = $_configuration['root_sys'].'plugin/vchamilo/log/vcrontrace.log'; // Trace file where to collect cron outputs |
39 | -$VCRON->TRACE = '/data/log/chamilo/vcrontrace.log'; // Trace file where to collect cron outputs |
|
40 | -$VCRON->TRACE_ENABLE = true; // enables tracing |
|
39 | +$VCRON->TRACE = '/data/log/chamilo/vcrontrace.log'; // Trace file where to collect cron outputs |
|
40 | +$VCRON->TRACE_ENABLE = true; // enables tracing |
|
41 | 41 | |
42 | 42 | if (!is_dir($_configuration['root_sys'].'plugin/vchamilo/log')) { |
43 | 43 | mkdir($_configuration['root_sys'].'plugin/vchamilo/log', 0777, true); |
@@ -98,32 +98,32 @@ discard block |
||
98 | 98 | $timestamp_receive = time(); |
99 | 99 | |
100 | 100 | if ($rawresponse === false) { |
101 | - $error = curl_errno($ch) .':'. curl_error($ch); |
|
102 | - if ($VCRON->TRACE_ENABLE){ |
|
103 | - if ($CRONTRACE){ |
|
104 | - fputs($CRONTRACE, "VCron start on $vhost->root_web : ".api_time_to_hms($timestamp_send)."\n" ); |
|
101 | + $error = curl_errno($ch).':'.curl_error($ch); |
|
102 | + if ($VCRON->TRACE_ENABLE) { |
|
103 | + if ($CRONTRACE) { |
|
104 | + fputs($CRONTRACE, "VCron start on $vhost->root_web : ".api_time_to_hms($timestamp_send)."\n"); |
|
105 | 105 | fputs($CRONTRACE, "VCron Error : $error \n"); |
106 | - fputs($CRONTRACE, "VCron stop on $vhost->root_web : $timestamp_receive\n#################\n\n" ); |
|
106 | + fputs($CRONTRACE, "VCron stop on $vhost->root_web : $timestamp_receive\n#################\n\n"); |
|
107 | 107 | fclose($CRONTRACE); |
108 | 108 | } |
109 | 109 | } |
110 | - echo("VCron started on $vhost->root_web : ".api_time_to_hms($timestamp_send)."\n" ); |
|
110 | + echo("VCron started on $vhost->root_web : ".api_time_to_hms($timestamp_send)."\n"); |
|
111 | 111 | echo("VCron Error : $error \n"); |
112 | - echo("VCron stop on $vhost->root_web : ".api_time_to_hms($timestamp_receive)."\n#################\n\n" ); |
|
112 | + echo("VCron stop on $vhost->root_web : ".api_time_to_hms($timestamp_receive)."\n#################\n\n"); |
|
113 | 113 | return false; |
114 | 114 | } |
115 | 115 | |
116 | 116 | if ($VCRON->TRACE_ENABLE) { |
117 | 117 | if ($CRONTRACE) { |
118 | - fputs($CRONTRACE, "VCron start on $vhost->vhostname : ".api_time_to_hms($timestamp_send)."\n" ); |
|
118 | + fputs($CRONTRACE, "VCron start on $vhost->vhostname : ".api_time_to_hms($timestamp_send)."\n"); |
|
119 | 119 | fputs($CRONTRACE, $rawresponse."\n"); |
120 | - fputs($CRONTRACE, "VCron stop on $vhost->vhostname : ".api_time_to_hms($timestamp_receive)."\n#################\n\n" ); |
|
120 | + fputs($CRONTRACE, "VCron stop on $vhost->vhostname : ".api_time_to_hms($timestamp_receive)."\n#################\n\n"); |
|
121 | 121 | fclose($CRONTRACE); |
122 | 122 | } |
123 | 123 | } |
124 | - echo("VCron start on $vhost->root_web : ".api_time_to_hms($timestamp_send)."\n" ); |
|
124 | + echo("VCron start on $vhost->root_web : ".api_time_to_hms($timestamp_send)."\n"); |
|
125 | 125 | echo($rawresponse."\n"); |
126 | - echo("VCron stop on $vhost->root_web : ".api_time_to_hms($timestamp_receive)."\n#################\n\n" ); |
|
126 | + echo("VCron stop on $vhost->root_web : ".api_time_to_hms($timestamp_receive)."\n#################\n\n"); |
|
127 | 127 | $vhost->lastcrongap = time() - $vhost->lastcron; |
128 | 128 | $vhost->lastcron = $timestamp_send; |
129 | 129 | $vhost->croncount++; |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | $vhostid = $vhost->id; |
132 | 132 | unset($vhost->id); |
133 | 133 | |
134 | - Database::update('vchamilo', (array)$vhost, array('id = ?' => $vhostid)); |
|
134 | + Database::update('vchamilo', (array) $vhost, array('id = ?' => $vhostid)); |
|
135 | 135 | |
136 | 136 | } |
137 | 137 | |
@@ -155,9 +155,9 @@ discard block |
||
155 | 155 | |
156 | 156 | if ($VCRON->TRACE_ENABLE) { |
157 | 157 | if ($CRONTRACE) { |
158 | - fputs($CRONTRACE, "VCron start on $vhost->root_web : $timestamp_send\n" ); |
|
158 | + fputs($CRONTRACE, "VCron start on $vhost->root_web : $timestamp_send\n"); |
|
159 | 159 | fputs($CRONTRACE, $rawresponse."\n"); |
160 | - fputs($CRONTRACE, "VCron stop on $vhost->root_web : $timestamp_receive\n#################\n\n" ); |
|
160 | + fputs($CRONTRACE, "VCron stop on $vhost->root_web : $timestamp_receive\n#################\n\n"); |
|
161 | 161 | fclose($CRONTRACE); |
162 | 162 | } |
163 | 163 | } |
@@ -210,14 +210,14 @@ discard block |
||
210 | 210 | $match = trim($match); |
211 | 211 | |
212 | 212 | // try for IP match (Left side) |
213 | - $lhs = substr($host,0,strlen($match)); |
|
214 | - if (strcasecmp($match,$lhs)==0) { |
|
213 | + $lhs = substr($host, 0, strlen($match)); |
|
214 | + if (strcasecmp($match, $lhs) == 0) { |
|
215 | 215 | return true; |
216 | 216 | } |
217 | 217 | |
218 | 218 | // try for host match (Right side) |
219 | - $rhs = substr($host,-strlen($match)); |
|
220 | - if (strcasecmp($match,$rhs)==0) { |
|
219 | + $rhs = substr($host, -strlen($match)); |
|
220 | + if (strcasecmp($match, $rhs) == 0) { |
|
221 | 221 | return true; |
222 | 222 | } |
223 | 223 | } |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | |
229 | 229 | // Main execution sequence |
230 | 230 | |
231 | -if (!$vchamilos = Database::select('*', 'vchamilo', array(), 'all')){ |
|
231 | +if (!$vchamilos = Database::select('*', 'vchamilo', array(), 'all')) { |
|
232 | 232 | die("Nothing to do. No Vhosts"); |
233 | 233 | } |
234 | 234 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | if ($VCRON->STRATEGY == ROUND_ROBIN) { |
242 | 242 | $rr = 0; |
243 | 243 | foreach ($allvhosts as $vhostassoc) { |
244 | - $vhost = (object)$vhostassoc; |
|
244 | + $vhost = (object) $vhostassoc; |
|
245 | 245 | if ($rr == 1) { |
246 | 246 | api_set_setting('vchamilo_cron_lasthost', $vhost->id); |
247 | 247 | echo("Round Robin : ".$vhost->root_web."\n"); |
@@ -253,13 +253,13 @@ discard block |
||
253 | 253 | |
254 | 254 | die('Done.'); |
255 | 255 | } |
256 | - if ($vhost->id == api_get_setting('vchamilo_cron_lasthost', 'vchamilo')){ |
|
256 | + if ($vhost->id == api_get_setting('vchamilo_cron_lasthost', 'vchamilo')) { |
|
257 | 257 | $rr = 1; // take next one |
258 | 258 | } |
259 | 259 | } |
260 | 260 | |
261 | 261 | // We were at last. Loop back and take first. |
262 | - $firsthost = (object)$allvhosts[0]; |
|
262 | + $firsthost = (object) $allvhosts[0]; |
|
263 | 263 | api_set_setting('vchamilo_cron_lasthost', $firsthost->id, 'vchamilo'); |
264 | 264 | echo("Round Robin : ".$firsthost->root_web."\n"); |
265 | 265 | if ($VCRON->ACTIVATION == 'cli') { |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | $hostsperturn = max(1, $VCRON->PERIOD / api_get_setting('vcrontickperiod', 'vchamilo') * count($allvhosts)); |
279 | 279 | $i = 0; |
280 | 280 | foreach ($allvhosts as $vhostassoc) { |
281 | - $vhost = (object)$vhostassoc; |
|
281 | + $vhost = (object) $vhostassoc; |
|
282 | 282 | if ((time() - $vhost->lastcron) > $VCRON->PERIOD) { |
283 | 283 | if ($VCRON->ACTIVATION == 'cli') { |
284 | 284 | exec_vhost_cron($vhost); |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | return $this->_form->display(); |
45 | 45 | } |
46 | 46 | |
47 | - public function definition_after_data(){ |
|
47 | + public function definition_after_data() { |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | public function return_form() |
@@ -64,9 +64,9 @@ discard block |
||
64 | 64 | * @param bool $slashed true means return data with addslashes applied |
65 | 65 | * @return object submitted data; NULL if not valid or not submitted |
66 | 66 | */ |
67 | - public function get_data($slashed=true) |
|
67 | + public function get_data($slashed = true) |
|
68 | 68 | { |
69 | - $cform =& $this->_form; |
|
69 | + $cform = & $this->_form; |
|
70 | 70 | |
71 | 71 | if ($this->is_submitted() and $this->is_validated()) { |
72 | 72 | $data = $cform->exportValues(null, $slashed); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | if (empty($data)) { |
75 | 75 | return null; |
76 | 76 | } else { |
77 | - return (object)$data; |
|
77 | + return (object) $data; |
|
78 | 78 | } |
79 | 79 | } else { |
80 | 80 | return null; |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | * @param bool $slashed true means return data with addslashes applied |
88 | 88 | * @return object submitted data; NULL if not submitted |
89 | 89 | */ |
90 | - public function get_submitted_data($slashed=true) |
|
90 | + public function get_submitted_data($slashed = true) |
|
91 | 91 | { |
92 | - $cform =& $this->_form; |
|
92 | + $cform = & $this->_form; |
|
93 | 93 | |
94 | 94 | if ($this->is_submitted()) { |
95 | 95 | $data = $cform->exportValues(null, $slashed); |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | if (empty($data)) { |
98 | 98 | return null; |
99 | 99 | } else { |
100 | - return (object)$data; |
|
100 | + return (object) $data; |
|
101 | 101 | } |
102 | 102 | } else { |
103 | 103 | return null; |
@@ -121,10 +121,10 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public function is_cancelled() |
123 | 123 | { |
124 | - $cform =& $this->_form; |
|
125 | - if ($cform->isSubmitted()){ |
|
126 | - foreach ($cform->_cancelButtons as $cancelbutton){ |
|
127 | - if (optional_param($cancelbutton, 0, PARAM_RAW)){ |
|
124 | + $cform = & $this->_form; |
|
125 | + if ($cform->isSubmitted()) { |
|
126 | + foreach ($cform->_cancelButtons as $cancelbutton) { |
|
127 | + if (optional_param($cancelbutton, 0, PARAM_RAW)) { |
|
128 | 128 | return true; |
129 | 129 | } |
130 | 130 | } |
@@ -168,12 +168,12 @@ discard block |
||
168 | 168 | * |
169 | 169 | * @return bool true if form data valid |
170 | 170 | */ |
171 | - public function validate_defined_fields($validateonnosubmit=false) |
|
171 | + public function validate_defined_fields($validateonnosubmit = false) |
|
172 | 172 | { |
173 | 173 | static $validated = null; // one validation is enough |
174 | - $cform =& $this->_form; |
|
174 | + $cform = & $this->_form; |
|
175 | 175 | |
176 | - if ($this->no_submit_button_pressed() && empty($validateonnosubmit)){ |
|
176 | + if ($this->no_submit_button_pressed() && empty($validateonnosubmit)) { |
|
177 | 177 | return false; |
178 | 178 | } elseif ($validated === null) { |
179 | 179 | $internal_val = $cform->validate(); |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | |
192 | 192 | $data = $cform->exportValues(null, true); |
193 | 193 | $chamilo_val = $this->validation($data, $files); |
194 | - if ((is_array($chamilo_val) && count($chamilo_val)!==0)) { |
|
194 | + if ((is_array($chamilo_val) && count($chamilo_val) !== 0)) { |
|
195 | 195 | // non-empty array means errors |
196 | 196 | foreach ($chamilo_val as $element => $msg) { |
197 | 197 | $cform->setElementError($element, $msg); |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | return $nosubmit; |
218 | 218 | } |
219 | 219 | |
220 | - $cform =& $this->_form; |
|
220 | + $cform = & $this->_form; |
|
221 | 221 | $nosubmit = false; |
222 | 222 | if (!$this->is_submitted()) { |
223 | 223 | return false; |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | public function set_data($default_values, $slashed = false) |
247 | 247 | { |
248 | 248 | if (is_object($default_values)) { |
249 | - $default_values = (array)$default_values; |
|
249 | + $default_values = (array) $default_values; |
|
250 | 250 | } |
251 | 251 | $filter = $slashed ? 'stripslashes' : NULL; |
252 | 252 | $this->_form->setDefaults($default_values, $filter); |
@@ -266,14 +266,14 @@ discard block |
||
266 | 266 | } |
267 | 267 | |
268 | 268 | $errors = array(); |
269 | - $mform =& $this->_form; |
|
269 | + $mform = & $this->_form; |
|
270 | 270 | |
271 | 271 | // check the files |
272 | 272 | $status = $this->_upload_manager->preprocess_files(); |
273 | 273 | |
274 | 274 | // now check that we really want each file |
275 | 275 | foreach ($_FILES as $elname=>$file) { |
276 | - if ($mform->elementExists($elname) and $mform->getElementType($elname)=='file') { |
|
276 | + if ($mform->elementExists($elname) and $mform->getElementType($elname) == 'file') { |
|
277 | 277 | $required = $mform->isElementRequired($elname); |
278 | 278 | if (!empty($this->_upload_manager->files[$elname]['uploadlog']) && |
279 | 279 | empty($this->_upload_manager->files[$elname]['clear']) |
@@ -78,16 +78,16 @@ discard block |
||
78 | 78 | // res=-1 -> the user does not exist in the ldap database |
79 | 79 | // res=1 -> invalid password (user does exist) |
80 | 80 | |
81 | - if ($res==1) { //WRONG PASSWORD |
|
81 | + if ($res == 1) { //WRONG PASSWORD |
|
82 | 82 | //$errorMessage = "LDAP User or password incorrect, try again.<br />"; |
83 | 83 | if (isset($log)) unset($log); if (isset($uid)) unset($uid); |
84 | 84 | $loginLdapSucces = false; |
85 | 85 | } |
86 | - if ($res==-1) { //WRONG USERNAME |
|
86 | + if ($res == -1) { //WRONG USERNAME |
|
87 | 87 | //$errorMessage = "LDAP User or password incorrect, try again.<br />"; |
88 | 88 | $login_ldap_success = false; |
89 | 89 | } |
90 | - if ($res==0) { //LOGIN & PASSWORD OK - SUCCES |
|
90 | + if ($res == 0) { //LOGIN & PASSWORD OK - SUCCES |
|
91 | 91 | //$errorMessage = "Successful login w/ LDAP.<br>"; |
92 | 92 | $login_ldap_success = true; |
93 | 93 | } |
@@ -103,30 +103,30 @@ discard block |
||
103 | 103 | * @author Stefan De Wannemacker |
104 | 104 | * @author Roan Embrechts |
105 | 105 | */ |
106 | -function ldap_find_user_info ($login) { |
|
106 | +function ldap_find_user_info($login) { |
|
107 | 107 | //error_log('Entering ldap_find_user_info('.$login.')',0); |
108 | 108 | global $ldap_host, $ldap_port, $ldap_basedn, $ldap_rdn, $ldap_pass, $ldap_search_dn; |
109 | 109 | // basic sequence with LDAP is connect, bind, search, |
110 | 110 | // interpret search result, close connection |
111 | 111 | |
112 | 112 | //echo "Connecting ..."; |
113 | - $ldap_connect = ldap_connect( $ldap_host, $ldap_port); |
|
113 | + $ldap_connect = ldap_connect($ldap_host, $ldap_port); |
|
114 | 114 | ldap_set_version($ldap_connect); |
115 | 115 | if ($ldap_connect) { |
116 | 116 | //echo " Connect to LDAP server successful "; |
117 | 117 | //echo "Binding ..."; |
118 | 118 | $ldap_bind = false; |
119 | - $ldap_bind_res = ldap_handle_bind($ldap_connect,$ldap_bind); |
|
119 | + $ldap_bind_res = ldap_handle_bind($ldap_connect, $ldap_bind); |
|
120 | 120 | if ($ldap_bind_res) { |
121 | 121 | //echo " LDAP bind successful... "; |
122 | 122 | //echo " Searching for uid... "; |
123 | 123 | // Search surname entry |
124 | 124 | //OLD: $sr=ldap_search($ldapconnect,"dc=rug, dc=ac, dc=be", "uid=$login"); |
125 | 125 | //echo "<p> ldapDc = '$LDAPbasedn' </p>"; |
126 | - if(!empty($ldap_search_dn)) { |
|
127 | - $sr=ldap_search($ldap_connect, $ldap_search_dn, "uid=$login"); |
|
126 | + if (!empty($ldap_search_dn)) { |
|
127 | + $sr = ldap_search($ldap_connect, $ldap_search_dn, "uid=$login"); |
|
128 | 128 | } else { |
129 | - $sr=ldap_search($ldap_connect, $ldap_basedn, "uid=$login"); |
|
129 | + $sr = ldap_search($ldap_connect, $ldap_basedn, "uid=$login"); |
|
130 | 130 | } |
131 | 131 | //echo " Search result is ".$sr; |
132 | 132 | //echo " Number of entries returned is ".ldap_count_entries($ldapconnect,$sr); |
@@ -177,25 +177,25 @@ discard block |
||
177 | 177 | $password1 = $ldap_pass_placeholder; |
178 | 178 | $official_code = ''; |
179 | 179 | |
180 | - define ("STUDENT",5); |
|
181 | - define ("COURSEMANAGER",1); |
|
180 | + define("STUDENT", 5); |
|
181 | + define("COURSEMANAGER", 1); |
|
182 | 182 | |
183 | 183 | $tutor_field = api_get_setting('ldap_filled_tutor_field'); |
184 | 184 | $tutor_value = api_get_setting('ldap_filled_tutor_field_value'); |
185 | - if(empty($tutor_field)) { |
|
185 | + if (empty($tutor_field)) { |
|
186 | 186 | $status = STUDENT; |
187 | 187 | } else { |
188 | - if(empty($tutor_value)) { |
|
188 | + if (empty($tutor_value)) { |
|
189 | 189 | //in this case, we are assuming that the admin didn't give a criteria |
190 | 190 | // so that if the field is not empty, it is a tutor |
191 | - if(!empty($info_array[$tutor_field])) { |
|
191 | + if (!empty($info_array[$tutor_field])) { |
|
192 | 192 | $status = COURSEMANAGER; |
193 | 193 | } else { |
194 | 194 | $status = STUDENT; |
195 | 195 | } |
196 | 196 | } else { |
197 | 197 | //the tutor_value is filled, so we need to check the contents of the LDAP field |
198 | - if (is_array($info_array[$tutor_field]) && in_array($tutor_value,$info_array[$tutor_field])) { |
|
198 | + if (is_array($info_array[$tutor_field]) && in_array($tutor_value, $info_array[$tutor_field])) { |
|
199 | 199 | $status = COURSEMANAGER; |
200 | 200 | } else { |
201 | 201 | $status = STUDENT; |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | if (empty($language)) { $language = 'english'; } |
213 | 213 | $_userId = UserManager::create_user($prenom, $nom, $status, |
214 | 214 | $email, $uname, $password, $official_code, |
215 | - $language,'', '', 'ldap'); |
|
215 | + $language, '', '', 'ldap'); |
|
216 | 216 | |
217 | 217 | //echo "new user added to Chamilo, id = $_userId"; |
218 | 218 | |
@@ -246,58 +246,58 @@ discard block |
||
246 | 246 | * @param string password given by user |
247 | 247 | * @return int 0 if authentication succeeded, 1 if password was incorrect, -1 if it didn't belong to LDAP |
248 | 248 | */ |
249 | -function ldap_authentication_check ($uname, $passwd) { |
|
249 | +function ldap_authentication_check($uname, $passwd) { |
|
250 | 250 | //error_log('Entering ldap_authentication_check('.$uname.','.$passwd.')',0); |
251 | - global $ldap_host, $ldap_port, $ldap_basedn, $ldap_host2, $ldap_port2,$ldap_rdn,$ldap_pass; |
|
251 | + global $ldap_host, $ldap_port, $ldap_basedn, $ldap_host2, $ldap_port2, $ldap_rdn, $ldap_pass; |
|
252 | 252 | //error_log('Entering ldap_authentication_check('.$uname.','.$passwd.')',0); |
253 | 253 | // Establish anonymous connection with LDAP server |
254 | 254 | // Etablissement de la connexion anonyme avec le serveur LDAP |
255 | - $ds=ldap_connect($ldap_host,$ldap_port); |
|
255 | + $ds = ldap_connect($ldap_host, $ldap_port); |
|
256 | 256 | ldap_set_version($ds); |
257 | 257 | |
258 | 258 | $test_bind = false; |
259 | - $test_bind_res = ldap_handle_bind($ds,$test_bind); |
|
259 | + $test_bind_res = ldap_handle_bind($ds, $test_bind); |
|
260 | 260 | //if problem, use the replica |
261 | - if ($test_bind_res===false) { |
|
262 | - $ds=ldap_connect($ldap_host2,$ldap_port2); |
|
261 | + if ($test_bind_res === false) { |
|
262 | + $ds = ldap_connect($ldap_host2, $ldap_port2); |
|
263 | 263 | ldap_set_version($ds); |
264 | 264 | } else { |
265 | 265 | //error_log('Connected to server '.$ldap_host); |
266 | 266 | } |
267 | - if ($ds!==false) { |
|
267 | + if ($ds !== false) { |
|
268 | 268 | //Creation of filter containing values input by the user |
269 | 269 | // Here it might be necessary to use $filter="(samaccountName=$uname)"; - see http://support.chamilo.org/issues/4675 |
270 | - $filter="(uid=$uname)"; |
|
270 | + $filter = "(uid=$uname)"; |
|
271 | 271 | // Open anonymous LDAP connection |
272 | - $result=false; |
|
273 | - $ldap_bind_res = ldap_handle_bind($ds,$result); |
|
272 | + $result = false; |
|
273 | + $ldap_bind_res = ldap_handle_bind($ds, $result); |
|
274 | 274 | // Executing the search with the $filter parametr |
275 | 275 | //error_log('Searching for '.$filter.' on LDAP server',0); |
276 | - $sr=ldap_search($ds,$ldap_basedn,$filter); |
|
276 | + $sr = ldap_search($ds, $ldap_basedn, $filter); |
|
277 | 277 | $info = ldap_get_entries($ds, $sr); |
278 | - $dn=($info[0]["dn"]); |
|
278 | + $dn = ($info[0]["dn"]); |
|
279 | 279 | // debug !! echo"<br> dn = $dn<br> pass = $passwd<br>"; |
280 | 280 | // closing 1st connection |
281 | 281 | ldap_close($ds); |
282 | 282 | } |
283 | 283 | |
284 | 284 | // test the Distinguish Name from the 1st connection |
285 | - if ($dn=="") { |
|
286 | - return (-1); // doesn't belong to the addressbook |
|
285 | + if ($dn == "") { |
|
286 | + return (-1); // doesn't belong to the addressbook |
|
287 | 287 | } |
288 | 288 | //bug ldap.. if password empty, return 1! |
289 | - if ($passwd=="") { |
|
289 | + if ($passwd == "") { |
|
290 | 290 | return(1); |
291 | 291 | } |
292 | 292 | // Opening 2nd LDAP connection : Connection user for password check |
293 | - $ds=ldap_connect($ldap_host,$ldap_port); |
|
293 | + $ds = ldap_connect($ldap_host, $ldap_port); |
|
294 | 294 | ldap_set_version($ds); |
295 | 295 | if (!$test_bind) { |
296 | - $ds=ldap_connect($ldap_host2,$ldap_port2); |
|
296 | + $ds = ldap_connect($ldap_host2, $ldap_port2); |
|
297 | 297 | ldap_set_version($ds); |
298 | 298 | } |
299 | 299 | // return in case of wrong password connection error |
300 | - if (@ldap_bind( $ds, $dn , $passwd) === false) { |
|
300 | + if (@ldap_bind($ds, $dn, $passwd) === false) { |
|
301 | 301 | return (1); // invalid password |
302 | 302 | } else {// connection successfull |
303 | 303 | return (0); |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | function ldap_set_version(&$resource) { |
312 | 312 | //error_log('Entering ldap_set_version(&$resource)',0); |
313 | 313 | global $ldap_version; |
314 | - if ($ldap_version>2) { |
|
314 | + if ($ldap_version > 2) { |
|
315 | 315 | if (ldap_set_option($resource, LDAP_OPT_PROTOCOL_VERSION, 3)) { |
316 | 316 | //ok - don't do anything |
317 | 317 | } else { |
@@ -325,14 +325,14 @@ discard block |
||
325 | 325 | * @param resource The LDAP bind handler we will be modifying |
326 | 326 | * @return boolean Status of the bind assignment. True for success, false for failure. |
327 | 327 | */ |
328 | -function ldap_handle_bind(&$ldap_handler,&$ldap_bind) { |
|
328 | +function ldap_handle_bind(&$ldap_handler, &$ldap_bind) { |
|
329 | 329 | //error_log('Entering ldap_handle_bind(&$ldap_handler,&$ldap_bind)',0); |
330 | - global $ldap_rdn,$ldap_pass, $extldap_config; |
|
330 | + global $ldap_rdn, $ldap_pass, $extldap_config; |
|
331 | 331 | $ldap_rdn = $extldap_config['admin_dn']; |
332 | 332 | $ldap_pass = $extldap_config['admin_password']; |
333 | 333 | if (!empty($ldap_rdn) and !empty($ldap_pass)) { |
334 | 334 | //error_log('Trying authenticated login :'.$ldap_rdn.'/'.$ldap_pass,0); |
335 | - $ldap_bind = ldap_bind($ldap_handler,$ldap_rdn,$ldap_pass); |
|
335 | + $ldap_bind = ldap_bind($ldap_handler, $ldap_rdn, $ldap_pass); |
|
336 | 336 | if (!$ldap_bind) { |
337 | 337 | //error_log('Authenticated login failed',0); |
338 | 338 | //try in anonymous mode, you never know... |
@@ -358,40 +358,40 @@ discard block |
||
358 | 358 | |
359 | 359 | global $ldap_basedn, $ldap_host, $ldap_port, $ldap_rdn, $ldap_pass, $ldap_search_dn, $extldap_user_correspondance; |
360 | 360 | |
361 | - $keyword_firstname = isset($_GET['keyword_firstname']) ? trim(Database::escape_string($_GET['keyword_firstname'])): ''; |
|
361 | + $keyword_firstname = isset($_GET['keyword_firstname']) ? trim(Database::escape_string($_GET['keyword_firstname'])) : ''; |
|
362 | 362 | $keyword_lastname = isset($_GET['keyword_lastname']) ? trim(Database::escape_string($_GET['keyword_lastname'])) : ''; |
363 | 363 | $keyword_username = isset($_GET['keyword_username']) ? trim(Database::escape_string($_GET['keyword_username'])) : ''; |
364 | 364 | $keyword_type = isset($_GET['keyword_type']) ? Database::escape_string($_GET['keyword_type']) : ''; |
365 | 365 | |
366 | - $ldap_query=array(); |
|
366 | + $ldap_query = array(); |
|
367 | 367 | |
368 | 368 | if ($keyword_username != "") { |
369 | 369 | $ldap_query[] = str_replace('%username%', $keyword_username, $ldap_search_dn); |
370 | 370 | } else { |
371 | - if ($keyword_lastname!=""){ |
|
372 | - $ldap_query[]="(".$extldap_user_correspondance['lastname']."=".$keyword_lastname."*)"; |
|
371 | + if ($keyword_lastname != "") { |
|
372 | + $ldap_query[] = "(".$extldap_user_correspondance['lastname']."=".$keyword_lastname."*)"; |
|
373 | 373 | } |
374 | - if ($keyword_firstname!="") { |
|
375 | - $ldap_query[]="(".$extldap_user_correspondance['firstname']."=".$keyword_firstname."*)"; |
|
374 | + if ($keyword_firstname != "") { |
|
375 | + $ldap_query[] = "(".$extldap_user_correspondance['firstname']."=".$keyword_firstname."*)"; |
|
376 | 376 | } |
377 | 377 | } |
378 | - if ($keyword_type !="" && $keyword_type !="all") { |
|
379 | - $ldap_query[]="(employeeType=".$keyword_type.")"; |
|
378 | + if ($keyword_type != "" && $keyword_type != "all") { |
|
379 | + $ldap_query[] = "(employeeType=".$keyword_type.")"; |
|
380 | 380 | } |
381 | 381 | |
382 | - if (count($ldap_query)>1){ |
|
383 | - $str_query.="(& "; |
|
384 | - foreach ($ldap_query as $query){ |
|
385 | - $str_query.=" $query"; |
|
382 | + if (count($ldap_query) > 1) { |
|
383 | + $str_query .= "(& "; |
|
384 | + foreach ($ldap_query as $query) { |
|
385 | + $str_query .= " $query"; |
|
386 | 386 | } |
387 | - $str_query.=" )"; |
|
387 | + $str_query .= " )"; |
|
388 | 388 | } else { |
389 | - $str_query= count($ldap_query) > 0 ? $ldap_query[0] : null; |
|
389 | + $str_query = count($ldap_query) > 0 ? $ldap_query[0] : null; |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | $ds = ldap_connect($ldap_host, $ldap_port); |
393 | 393 | ldap_set_version($ds); |
394 | - if ($ds && count($ldap_query)>0) { |
|
394 | + if ($ds && count($ldap_query) > 0) { |
|
395 | 395 | $r = false; |
396 | 396 | $res = ldap_handle_bind($ds, $r); |
397 | 397 | //$sr = ldap_search($ds, "ou=test-ou,$ldap_basedn", $str_query); |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | return $info; |
402 | 402 | |
403 | 403 | } else { |
404 | - if (count($ldap_query)!=0) |
|
404 | + if (count($ldap_query) != 0) |
|
405 | 405 | Display :: display_error_message(get_lang('LDAPConnectionError')); |
406 | 406 | return array(); |
407 | 407 | } |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | */ |
415 | 415 | function ldap_get_number_of_users() { |
416 | 416 | $info = ldap_get_users(); |
417 | - if (count($info)>0) { |
|
417 | + if (count($info) > 0) { |
|
418 | 418 | return $info['count']; |
419 | 419 | } else { |
420 | 420 | return 0; |
@@ -434,9 +434,9 @@ discard block |
||
434 | 434 | $is_western_name_order = api_is_western_name_order(); |
435 | 435 | if (isset($_GET['submit'])) { |
436 | 436 | $info = ldap_get_users(); |
437 | - if ($info['count']>0) { |
|
438 | - for ($key = 0; $key < $info["count"]; $key ++) { |
|
439 | - $user=array(); |
|
437 | + if ($info['count'] > 0) { |
|
438 | + for ($key = 0; $key < $info["count"]; $key++) { |
|
439 | + $user = array(); |
|
440 | 440 | // Get uid from dn |
441 | 441 | //YW: this might be a variation between LDAP 2 and LDAP 3, but in LDAP 3, the uid is in |
442 | 442 | //the corresponding index of the array |
@@ -470,9 +470,9 @@ discard block |
||
470 | 470 | * @return string Some HTML-code with modify-buttons |
471 | 471 | * @author Mustapha Alouani |
472 | 472 | */ |
473 | -function modify_filter($user_id,$url_params, $row) { |
|
474 | - $query_string="id[]=".$row[0]; |
|
475 | - if (!empty($_GET['id_session'])){ |
|
473 | +function modify_filter($user_id, $url_params, $row) { |
|
474 | + $query_string = "id[]=".$row[0]; |
|
475 | + if (!empty($_GET['id_session'])) { |
|
476 | 476 | $query_string .= '&id_session='.Security::remove_XSS($_GET['id_session']); |
477 | 477 | } |
478 | 478 | //$url_params_id="id=".$row[0]; |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | $firstname = api_convert_encoding($data['cn'][0], api_get_system_encoding(), 'UTF-8'); |
498 | 498 | $email = $data['mail'][0]; |
499 | 499 | // Get uid from dn |
500 | - $dn_array=ldap_explode_dn($data['dn'],1); |
|
500 | + $dn_array = ldap_explode_dn($data['dn'], 1); |
|
501 | 501 | $username = $dn_array[0]; // uid is first key |
502 | 502 | $outab[] = $data['edupersonprimaryaffiliation'][0]; // Here, "student" |
503 | 503 | //$val = ldap_get_values_len($ds, $entry, "userPassword"); |
@@ -505,29 +505,29 @@ discard block |
||
505 | 505 | //$password = $val[0]; |
506 | 506 | // TODO the password, if encrypted at the source, will be encrypted twice, which makes it useless. Try to fix that. |
507 | 507 | $password = $data['userPassword'][0]; |
508 | - $structure=$data['edupersonprimaryorgunitdn'][0]; |
|
509 | - $array_structure=explode(",", $structure); |
|
510 | - $array_val=explode("=", $array_structure[0]); |
|
511 | - $etape=$array_val[1]; |
|
512 | - $array_val=explode("=", $array_structure[1]); |
|
513 | - $annee=$array_val[1]; |
|
508 | + $structure = $data['edupersonprimaryorgunitdn'][0]; |
|
509 | + $array_structure = explode(",", $structure); |
|
510 | + $array_val = explode("=", $array_structure[0]); |
|
511 | + $etape = $array_val[1]; |
|
512 | + $array_val = explode("=", $array_structure[1]); |
|
513 | + $annee = $array_val[1]; |
|
514 | 514 | // To ease management, we add the step-year (etape-annee) code |
515 | - $official_code=$etape."-".$annee; |
|
516 | - $auth_source='ldap'; |
|
515 | + $official_code = $etape."-".$annee; |
|
516 | + $auth_source = 'ldap'; |
|
517 | 517 | // No expiration date for students (recover from LDAP's shadow expiry) |
518 | - $expiration_date=''; |
|
519 | - $active=1; |
|
520 | - if(empty($status)){$status = 5;} |
|
521 | - if(empty($phone)){$phone = '';} |
|
522 | - if(empty($picture_uri)){$picture_uri = '';} |
|
518 | + $expiration_date = ''; |
|
519 | + $active = 1; |
|
520 | + if (empty($status)) {$status = 5; } |
|
521 | + if (empty($phone)) {$phone = ''; } |
|
522 | + if (empty($picture_uri)) {$picture_uri = ''; } |
|
523 | 523 | // Adding user |
524 | 524 | $user_id = 0; |
525 | 525 | if (UserManager::is_username_available($username)) { |
526 | - $user_id = UserManager::create_user($firstname,$lastname,$status,$email,$username,$password,$official_code,api_get_setting('platformLanguage'),$phone,$picture_uri,$auth_source,$expiration_date,$active); |
|
526 | + $user_id = UserManager::create_user($firstname, $lastname, $status, $email, $username, $password, $official_code, api_get_setting('platformLanguage'), $phone, $picture_uri, $auth_source, $expiration_date, $active); |
|
527 | 527 | } else { |
528 | 528 | if ($update_if_exists) { |
529 | 529 | $user = api_get_user_info($username); |
530 | - $user_id=$user['user_id']; |
|
530 | + $user_id = $user['user_id']; |
|
531 | 531 | UserManager::update_user($user_id, $firstname, $lastname, $username, null, null, $email, $status, $official_code, $phone, $picture_uri, $expiration_date, $active); |
532 | 532 | } |
533 | 533 | } |
@@ -544,21 +544,21 @@ discard block |
||
544 | 544 | |
545 | 545 | // Database Table Definitions |
546 | 546 | $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); |
547 | - $tbl_session_rel_class = Database::get_main_table(TABLE_MAIN_SESSION_CLASS); |
|
547 | + $tbl_session_rel_class = Database::get_main_table(TABLE_MAIN_SESSION_CLASS); |
|
548 | 548 | $tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); |
549 | 549 | $tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
550 | 550 | $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE); |
551 | 551 | $tbl_user = Database::get_main_table(TABLE_MAIN_USER); |
552 | 552 | $tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER); |
553 | - $tbl_class = Database::get_main_table(TABLE_MAIN_CLASS); |
|
554 | - $tbl_class_user = Database::get_main_table(TABLE_MAIN_CLASS_USER); |
|
553 | + $tbl_class = Database::get_main_table(TABLE_MAIN_CLASS); |
|
554 | + $tbl_class_user = Database::get_main_table(TABLE_MAIN_CLASS_USER); |
|
555 | 555 | |
556 | 556 | $id_session = (int) $id_session; |
557 | 557 | // Once users are imported in the users base, we can assign them to the session |
558 | - $result=Database::query("SELECT c_id FROM $tbl_session_rel_course WHERE session_id ='$id_session'"); |
|
559 | - $CourseList=array(); |
|
560 | - while ($row=Database::fetch_array($result)) { |
|
561 | - $CourseList[]=$row['c_id']; |
|
558 | + $result = Database::query("SELECT c_id FROM $tbl_session_rel_course WHERE session_id ='$id_session'"); |
|
559 | + $CourseList = array(); |
|
560 | + while ($row = Database::fetch_array($result)) { |
|
561 | + $CourseList[] = $row['c_id']; |
|
562 | 562 | } |
563 | 563 | foreach ($CourseList as $enreg_course) { |
564 | 564 | foreach ($UserList as $enreg_user) { |
@@ -569,21 +569,21 @@ discard block |
||
569 | 569 | "('$id_session','$enreg_course','$enreg_user')"); |
570 | 570 | } |
571 | 571 | $sql = "SELECT COUNT(user_id) as nbUsers ". |
572 | - " FROM $tbl_session_rel_course_rel_user " . |
|
572 | + " FROM $tbl_session_rel_course_rel_user ". |
|
573 | 573 | " WHERE session_id='$id_session' ". |
574 | 574 | " AND c_id='$enreg_course'"; |
575 | 575 | $rs = Database::query($sql); |
576 | 576 | list($nbr_users) = Database::fetch_array($rs); |
577 | 577 | Database::query("UPDATE $tbl_session_rel_course ". |
578 | - " SET nbr_users=$nbr_users " . |
|
578 | + " SET nbr_users=$nbr_users ". |
|
579 | 579 | " WHERE session_id='$id_session' ". |
580 | 580 | " AND c_id='$enreg_course'"); |
581 | 581 | } |
582 | 582 | foreach ($UserList as $enreg_user) { |
583 | 583 | $enreg_user = (int) $enreg_user; |
584 | 584 | Database::query("INSERT IGNORE INTO $tbl_session_rel_user ". |
585 | - " (session_id, user_id, registered_at) " . |
|
586 | - " VALUES('$id_session','$enreg_user', '" . api_get_utc_datetime() . "')"); |
|
585 | + " (session_id, user_id, registered_at) ". |
|
586 | + " VALUES('$id_session','$enreg_user', '".api_get_utc_datetime()."')"); |
|
587 | 587 | } |
588 | 588 | // We update the number of users in the session |
589 | 589 | $sql = "SELECT COUNT(user_id) as nbUsers FROM $tbl_session_rel_user ". |
@@ -598,13 +598,13 @@ discard block |
||
598 | 598 | function syncro_users() { |
599 | 599 | global $ldap_basedn, $ldap_host, $ldap_port, $ldap_rdn, $ldap_pass, $ldap_search_dn; |
600 | 600 | echo "Connecting ..."; |
601 | - $ldap_connect = ldap_connect( $ldap_host, $ldap_port); |
|
601 | + $ldap_connect = ldap_connect($ldap_host, $ldap_port); |
|
602 | 602 | ldap_set_version($ldap_connect); |
603 | 603 | if ($ldap_connect) { |
604 | 604 | //echo " Connect to LDAP server successful "; |
605 | 605 | //echo "Binding ..."; |
606 | 606 | $ldap_bind = false; |
607 | - $ldap_bind_res = ldap_handle_bind($ldap_connect,$ldap_bind); |
|
607 | + $ldap_bind_res = ldap_handle_bind($ldap_connect, $ldap_bind); |
|
608 | 608 | if ($ldap_bind_res) { |
609 | 609 | //echo " LDAP bind successful... "; |
610 | 610 | //echo " Searching for uid... "; |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | //OLD: $sr=ldap_search($ldapconnect,"dc=rug, dc=ac, dc=be", "uid=$login"); |
613 | 613 | //echo "<p> ldapDc = '$LDAPbasedn' </p>"; |
614 | 614 | $all_user_query = "uid=*"; |
615 | - if(!empty($ldap_search_dn)) { |
|
615 | + if (!empty($ldap_search_dn)) { |
|
616 | 616 | $sr = ldap_search($ldap_connect, $ldap_search_dn, $all_user_query); |
617 | 617 | } else { |
618 | 618 | $sr = ldap_search($ldap_connect, $ldap_basedn, $all_user_query); |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | //echo " Number of entries returned is ".ldap_count_entries($ldapconnect,$sr); |
621 | 621 | //echo " Getting entries ..."; |
622 | 622 | $info = ldap_get_entries($ldap_connect, $sr); |
623 | - for ($key = 0; $key < $info['count']; $key ++) { |
|
623 | + for ($key = 0; $key < $info['count']; $key++) { |
|
624 | 624 | $user_id = ldap_add_user_by_array($info[$key], false); |
625 | 625 | if ($user_id) { |
626 | 626 | echo "User #$user_id created "; |