Skip to content

Commit c781905

Browse files
committed
Run phpcbf on whole codebase
1 parent e108772 commit c781905

File tree

10 files changed

+306
-251
lines changed

10 files changed

+306
-251
lines changed

cal_lib.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
/**
1818
* Functions for creating hislsf calendar instances
19+
* @package local_lsf_unification
1920
*/
2021
if (!defined('MOODLE_INTERNAL')) {
2122
die('Direct access to this script is forbidden.'); // It must be included from a Moodle page
@@ -29,6 +30,7 @@
2930
/**
3031
* Returns the CURRENT (because of the event ids instead of the user id being appended this URL changes when users subscribe to new events) userspecific ICal-URL
3132
* @param unknown_type $userid
33+
* @package local_lsf_unification
3234
*/
3335
function his_get_ical_url($userid) {
3436
global $DB, $CFG;
@@ -41,6 +43,7 @@ function his_get_ical_url($userid) {
4143
/**
4244
* returns a default hislsf calendar instance
4345
* @return stdClass
46+
* @package local_lsf_unification
4447
*/
4548
function create_default_his_subscription() {
4649
global $CFG;
@@ -54,6 +57,7 @@ function create_default_his_subscription() {
5457

5558
/**
5659
* Checks if a hislsf calendar instance already exists for the current user. If it doesn't find one, then it tries to create a new one.
60+
* @package local_lsf_unification
5761
*/
5862
function his_add_cal() {
5963
global $PAGE;
@@ -74,6 +78,7 @@ function his_add_cal() {
7478
/**
7579
* Returns if a hislsf calendar instance already exists for the current user
7680
* @return boolean
81+
* @package local_lsf_unification
7782
*/
7883
function his_already_imported_cal() {
7984
global $USER, $DB;
@@ -83,6 +88,7 @@ function his_already_imported_cal() {
8388
/**
8489
* Adds a link to "cal_import.php" to the form
8590
* @param $mform
91+
* @package local_lsf_unification
8692
*/
8793
function his_print_cal_import_form($mform) {
8894
global $PAGE, $CFG;

duplicate_course.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646

4747
$courseid = required_param('courseid', PARAM_INT);
4848
$acceptorid = get_course_acceptor($courseid);
49-
$files_backups = get_backup_files($acceptorid);
50-
$files_templates = get_template_files();
49+
$filesbackups = get_backup_files($acceptorid);
50+
$filestemplates = get_template_files();
5151
$filetype = optional_param('filetype', null, PARAM_RAW);
5252
$fileid = optional_param('fileid', null, PARAM_RAW);
5353
$fileinfo = null;
@@ -67,15 +67,15 @@
6767
}
6868
// restore backup
6969
if ($filetype == "t" && get_config('local_lsf_unification', 'restore_templates')) {
70-
if (empty($files_templates[$fileid])) {
70+
if (empty($filestemplates[$fileid])) {
7171
die("error #0");
7272
}
73-
$fileinfo = $files_templates[$fileid];
73+
$fileinfo = $filestemplates[$fileid];
7474
} else if ($filetype == "b" && get_config('local_lsf_unification', 'restore_old_courses')) {
75-
if (empty($files_backups[$fileid])) {
75+
if (empty($filesbackups[$fileid])) {
7676
die("error #0");
7777
}
78-
$fileinfo = $files_backups[$fileid];
78+
$fileinfo = $filesbackups[$fileid];
7979
} else {
8080
die("error #x");
8181
}

hup_stats.php

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@
2424
die("no access");
2525
}
2626

27-
$reqSem = optional_param('semester', null, PARAM_INT); // his category origin id
27+
$reqsem = optional_param('semester', null, PARAM_INT); // his category origin id
2828

2929
set_time_limit(30 * 60);
3030

3131

3232
function create_aggregate() {
33-
global $pgDB;
34-
pg_query($pgDB->connection, "DROP AGGREGATE IF EXISTS textcat_all(text);");
35-
pg_query($pgDB->connection, "CREATE AGGREGATE textcat_all(
33+
global $pgdb;
34+
pg_query($pgdb->connection, "DROP AGGREGATE IF EXISTS textcat_all(text);");
35+
pg_query($pgdb->connection, "CREATE AGGREGATE textcat_all(
3636
basetype = text,
3737
sfunc = textcat,
3838
stype = text,
@@ -41,69 +41,69 @@ function create_aggregate() {
4141
}
4242

4343
function get_cat_sem($ueid) {
44-
global $pgDB, $hup_stats_sem_table;
44+
global $pgdb, $hupstatssemtable;
4545
// read or (if not existing) create array
46-
if (!isset($hup_stats_sem_table)) {
47-
$hup_stats_sem_table = [];
48-
$q_main = pg_query($pgDB->connection, "SELECT ueid, semester FROM " . HIS_UEBERSCHRIFT);
49-
while ($hislsf_title = pg_fetch_object($q_main)) {
50-
$hup_stats_sem_table[$hislsf_title->ueid] = $hislsf_title->semester;
46+
if (!isset($hupstatssemtable)) {
47+
$hupstatssemtable = [];
48+
$qmain = pg_query($pgdb->connection, "SELECT ueid, semester FROM " . HIS_UEBERSCHRIFT);
49+
while ($hislsftitle = pg_fetch_object($qmain)) {
50+
$hupstatssemtable[$hislsftitle->ueid] = $hislsftitle->semester;
5151
}
5252
}
53-
return isset($hup_stats_sem_table[$ueid]) ? $hup_stats_sem_table[$ueid] : null;
53+
return isset($hupstatssemtable[$ueid]) ? $hupstatssemtable[$ueid] : null;
5454
}
5555

5656
function get_cat_veranstids_and_count($ueids) {
57-
global $pgDB;
58-
$hup_stats_veranstcount_table = [];
57+
global $pgdb;
58+
$hupstatsveranstcounttable = [];
5959
if (!empty($ueids)) {
60-
$q_main = pg_query($pgDB->connection, "SELECT veranstaltungsart, textcat_all(DISTINCT " . HIS_UEBERSCHRIFT . ".veranstid || ',') as veranstids, COUNT(DISTINCT " . HIS_UEBERSCHRIFT . ".veranstid) as c FROM " . HIS_UEBERSCHRIFT . " JOIN " . HIS_VERANSTALTUNG . " on " . HIS_UEBERSCHRIFT . ".veranstid = " . HIS_VERANSTALTUNG . ".veranstid WHERE ueid IN (" . $ueids . ") GROUP BY veranstaltungsart");
61-
while ($hislsf_title = pg_fetch_object($q_main)) {
62-
$hup_stats_veranstcount_table[$hislsf_title->veranstaltungsart] = ["veranstids" => explode(",", $hislsf_title->veranstids), "count" => $hislsf_title->c];
60+
$qmain = pg_query($pgdb->connection, "SELECT veranstaltungsart, textcat_all(DISTINCT " . HIS_UEBERSCHRIFT . ".veranstid || ',') as veranstids, COUNT(DISTINCT " . HIS_UEBERSCHRIFT . ".veranstid) as c FROM " . HIS_UEBERSCHRIFT . " JOIN " . HIS_VERANSTALTUNG . " on " . HIS_UEBERSCHRIFT . ".veranstid = " . HIS_VERANSTALTUNG . ".veranstid WHERE ueid IN (" . $ueids . ") GROUP BY veranstaltungsart");
61+
while ($hislsftitle = pg_fetch_object($qmain)) {
62+
$hupstatsveranstcounttable[$hislsftitle->veranstaltungsart] = ["veranstids" => explode(",", $hislsftitle->veranstids), "count" => $hislsftitle->c];
6363
}
6464
}
65-
return $hup_stats_veranstcount_table;
65+
return $hupstatsveranstcounttable;
6666
}
6767

6868

69-
$pgDB = new pg_lite();
70-
echo "<p>Verbindung: " . ($pgDB->connect() ? "ja" : "nein") . " (" . $pgDB->connection . ")</p>";
69+
$pgdb = new pg_lite();
70+
echo "<p>Verbindung: " . ($pgdb->connect() ? "ja" : "nein") . " (" . $pgdb->connection . ")</p>";
7171
create_aggregate();
7272

7373
echo "<p><pre>";
7474
// Root-Knoten herausfinden
75-
$toplevel_origins = get_his_toplevel_originids();
75+
$toplevelorigins = get_his_toplevel_originids();
7676
// echo "TOPLEVEL_IDs = ".print_r($toplevel_origins,true)."\n\n";
7777
// Kategorien herausfinden
78-
$secondlevel_orinins = get_newest_sublevels(implode(", ", $toplevel_origins));
79-
foreach ($secondlevel_orinins as $secondndlevel) {
78+
$secondlevelorinins = get_newest_sublevels(implode(", ", $toplevelorigins));
79+
foreach ($secondlevelorinins as $secondndlevel) {
8080
// Kategoriekopien herausfinden
8181
$secondndlevel->txt = mb_convert_encoding($secondndlevel->txt, 'UTF-8', 'ISO-8859-1');
8282
$secondndlevel->copies = $DB->get_records("local_lsf_category", ["origin" => $secondndlevel->origin], null, "ueid");
83-
foreach ($secondndlevel->copies as $secondlevel_copy) {
83+
foreach ($secondndlevel->copies as $secondlevelcopy) {
8484
// Semester bestimmen
85-
$secondlevel_copy->semester = get_cat_sem($secondlevel_copy->ueid);
86-
if (empty($reqSem) || ($reqSem == $secondlevel_copy->semester)) {
85+
$secondlevelcopy->semester = get_cat_sem($secondlevelcopy->ueid);
86+
if (empty($reqsem) || ($reqsem == $secondlevelcopy->semester)) {
8787
// Alle Unterkategorien der jeweiligen Kategoriekopien sammeln
88-
$secondlevel_copy->subs = array_keys($DB->get_records("local_lsf_categoryparenthood", ["parent" => $secondlevel_copy->ueid], null, "child"));
88+
$secondlevelcopy->subs = array_keys($DB->get_records("local_lsf_categoryparenthood", ["parent" => $secondlevelcopy->ueid], null, "child"));
8989
// Bestimme die Veranstatlungstypen und Anazahlen der jeweiligen Kategoriekopien
90-
$secondlevel_copy->veranstcount = get_cat_veranstids_and_count(implode(",", $secondlevel_copy->subs));
90+
$secondlevelcopy->veranstcount = get_cat_veranstids_and_count(implode(",", $secondlevelcopy->subs));
9191
// Semesterarray erstellen (daten umformatieren)
92-
if (!isset($sem_stats[$secondlevel_copy->semester])) {
93-
$sem_stats[$secondlevel_copy->semester] = [];
92+
if (!isset($semstats[$secondlevelcopy->semester])) {
93+
$semstats[$secondlevelcopy->semester] = [];
9494
}
95-
if (!isset($sem_stats[$secondlevel_copy->semester][$secondndlevel->txt])) {
96-
$sem_stats[$secondlevel_copy->semester][$secondndlevel->txt] = [];
95+
if (!isset($semstats[$secondlevelcopy->semester][$secondndlevel->txt])) {
96+
$semstats[$secondlevelcopy->semester][$secondndlevel->txt] = [];
9797
}
98-
foreach ($secondlevel_copy->veranstcount as $typ => $veranstids_and_count) {
99-
if (!isset($sem_stats[$secondlevel_copy->semester][$secondndlevel->txt][$typ])) {
100-
$sem_stats[$secondlevel_copy->semester][$secondndlevel->txt][$typ] = ["imported" => 0, "existing" => 0, "veranstids" => []];
98+
foreach ($secondlevelcopy->veranstcount as $typ => $veranstidsandcount) {
99+
if (!isset($semstats[$secondlevelcopy->semester][$secondndlevel->txt][$typ])) {
100+
$semstats[$secondlevelcopy->semester][$secondndlevel->txt][$typ] = ["imported" => 0, "existing" => 0, "veranstids" => []];
101101
}
102-
$sem_stats[$secondlevel_copy->semester][$secondndlevel->txt][$typ]["veranstids"] = array_filter(array_merge($sem_stats[$secondlevel_copy->semester][$secondndlevel->txt][$typ]["veranstids"], $veranstids_and_count["veranstids"]));
103-
$sem_stats[$secondlevel_copy->semester][$secondndlevel->txt][$typ]["existing"] += $veranstids_and_count["count"];
102+
$semstats[$secondlevelcopy->semester][$secondndlevel->txt][$typ]["veranstids"] = array_filter(array_merge($semstats[$secondlevelcopy->semester][$secondndlevel->txt][$typ]["veranstids"], $veranstidsandcount["veranstids"]));
103+
$semstats[$secondlevelcopy->semester][$secondndlevel->txt][$typ]["existing"] += $veranstidsandcount["count"];
104104
// zaehle bestehende kurse
105-
foreach ($sem_stats[$secondlevel_copy->semester][$secondndlevel->txt][$typ]["veranstids"] as $veranstid) {
106-
$sem_stats[$secondlevel_copy->semester][$secondndlevel->txt][$typ]["imported"] += $DB->record_exists("course", ["idnumber" => $veranstid]) ? 1 : 0;
105+
foreach ($semstats[$secondlevelcopy->semester][$secondndlevel->txt][$typ]["veranstids"] as $veranstid) {
106+
$semstats[$secondlevelcopy->semester][$secondndlevel->txt][$typ]["imported"] += $DB->record_exists("course", ["idnumber" => $veranstid]) ? 1 : 0;
107107
}
108108
}
109109
}
@@ -114,7 +114,7 @@ function get_cat_veranstids_and_count($ueids) {
114114

115115
// write CSV
116116
echo "Semester;Kategorie;Typ;AnzahlGesamt;AnzahlImportiert\n";
117-
foreach ($sem_stats as $sem => $stats) {
117+
foreach ($semstats as $sem => $stats) {
118118
foreach ($stats as $cat => $catstats) {
119119
if (!empty($catstats)) {
120120
foreach ($catstats as $typ => $count) {
@@ -127,5 +127,5 @@ function get_cat_veranstids_and_count($ueids) {
127127

128128
echo "</pre></p>";
129129

130-
$pgDB->dispose();
131-
echo "<p>Verbindung geschlossen: " . (($pgDB->connection == null) ? "ja" : "nein") . "</p>";
130+
$pgdb->dispose();
131+
echo "<p>Verbindung geschlossen: " . (($pgdb->connection == null) ? "ja" : "nein") . "</p>";

lib.php

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
/**
1818
* Functions that aid core functionality
19+
* @package local_lsf_unification
1920
*/
2021
defined('MOODLE_INTERNAL') || die();
2122

@@ -28,6 +29,7 @@
2829
*
2930
* @param $courseid
3031
* @return $externid | -1
32+
* @package local_lsf_unification
3133
*/
3234
function get_course_by_idnumber($courseid, $silent = false) {
3335
global $DB;
@@ -45,16 +47,17 @@ function get_course_by_idnumber($courseid, $silent = false) {
4547
*
4648
* @param $title
4749
* @return $parent_title | null
50+
* @package local_lsf_unification
4851
*/
49-
function find_or_create_category($title, $parent_title) {
52+
function find_or_create_category($title, $parenttitle) {
5053
global $DB;
5154
if (
5255
$category = $DB->get_record("course_categories", ["name" => $title,
5356
])
5457
) {
5558
return $category;
5659
}
57-
$parent = empty($parent_title) ? 0 : (find_or_create_category($parent_title, null)->id);
60+
$parent = empty($parenttitle) ? 0 : (find_or_create_category($parenttitle, null)->id);
5861
$parent = empty($parent) ? 0 : $parent;
5962
$newcategory = new stdClass();
6063
$newcategory->name = $title;
@@ -134,6 +137,7 @@ function get_course_acceptor($mdlid) {
134137
*
135138
* @param $id
136139
* @return null
140+
* @package local_lsf_unification
137141
*/
138142
function enable_manual_enrolment($course) {
139143
global $DB;
@@ -156,8 +160,9 @@ function enable_manual_enrolment($course) {
156160
*
157161
* @param $id
158162
* @return null
163+
* @package local_lsf_unification
159164
*/
160-
function enable_lsf_enrolment($id, $enrolment_start, $enrolment_end) {
165+
function enable_lsf_enrolment($id, $enrolmentstart, $enrolmentend) {
161166
global $DB;
162167

163168
$course = $DB->get_record('course', ['id' => $id,
@@ -167,8 +172,8 @@ function enable_lsf_enrolment($id, $enrolment_start, $enrolment_end) {
167172
'status' => ENROL_INSTANCE_ENABLED,
168173
'enrolperiod' => null,
169174
'roleid' => get_config('local_lsf_webservices', 'role_student'),
170-
'customint1' => $enrolment_start,
171-
'customint2' => $enrolment_end,
175+
'customint1' => $enrolmentstart,
176+
'customint2' => $enrolmentend,
172177
];
173178
$plugin->add_instance($course, $fields);
174179
}
@@ -179,6 +184,7 @@ function enable_lsf_enrolment($id, $enrolment_start, $enrolment_end) {
179184
* @param $course
180185
* @param $password
181186
* @return null
187+
* @package local_lsf_unification
182188
*/
183189
function enable_self_enrolment($course, $password) {
184190
global $DB;
@@ -204,6 +210,7 @@ function enable_self_enrolment($course, $password) {
204210
*
205211
* @param $course
206212
* @return null
213+
* @package local_lsf_unification
207214
*/
208215
function enable_database_enrolment($course) {
209216
global $DB;
@@ -236,6 +243,7 @@ function create_guest_enrolment($course, $password = "", $enable = false) {
236243
*
237244
* @param $courseid
238245
* @return $password | ""
246+
* @package local_lsf_unification
239247
*/
240248
function self_enrolment_status($courseid) {
241249
global $DB;
@@ -252,6 +260,7 @@ function self_enrolment_status($courseid) {
252260
* @param $shortname
253261
* @param $startdate
254262
* @return $course
263+
* @package local_lsf_unification
255264
*/
256265
function get_default_course($fullname, $idnumber, $summary, $shortname) {
257266
// check&format content
@@ -301,6 +310,7 @@ function get_default_course($fullname, $idnumber, $summary, $shortname) {
301310
* @param $shortname
302311
* @param $startdate
303312
* @return $course
313+
* @package local_lsf_unification
304314
*/
305315
function get_or_create_support_user() {
306316
global $DB, $CFG;
@@ -336,6 +346,7 @@ function get_or_create_user($username, $email) {
336346
*
337347
* @param array that maps id to name
338348
* @return array that maps id to path
349+
* @package local_lsf_unification
339350
*/
340351
function add_path_description($choices) {
341352
global $DB;
@@ -370,15 +381,16 @@ function add_path_description($choices) {
370381
*
371382
* NOTE: Since 2.7.2 this function is run by scheduled task rather
372383
* than standard cron.
384+
* @package local_lsf_unification
373385
*/
374386
function local_lsf_unification_cron() {
375-
global $CFG, $pgDB;
387+
global $CFG, $pgdb;
376388
include_once(dirname(__FILE__) . '/class_pg_lite.php');
377389
include_once(dirname(__FILE__) . '/lib_features.php');
378390

379-
$pgDB = new pg_lite();
380-
$connected = $pgDB->connect();
381-
$recourceid = $pgDB->connection;
391+
$pgdb = new pg_lite();
392+
$connected = $pgdb->connect();
393+
$recourceid = $pgdb->connection;
382394

383395
mtrace(
384396
'! = unknown category found, ? = unknown linkage found;' . 'Verbindung: ' .
@@ -387,5 +399,5 @@ function local_lsf_unification_cron() {
387399

388400
insert_missing_helptable_entries(true, false);
389401

390-
$pgDB->dispose();
402+
$pgdb->dispose();
391403
}

0 commit comments

Comments
 (0)