Skip to content

Commit

Permalink
Linting
Browse files Browse the repository at this point in the history
  • Loading branch information
georgmaisser authored and ibernhardf committed Jan 21, 2025
1 parent 5b4b7b8 commit ab3c508
Show file tree
Hide file tree
Showing 40 changed files with 309 additions and 251 deletions.
1 change: 1 addition & 0 deletions allekurse.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Add dates to option.
*
Expand Down
12 changes: 6 additions & 6 deletions classes/contractmanager.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class contractmanager {

/**
* Calculate the hourly rate of a teacher for a certain booking option
* using the contract formula.
Expand All @@ -37,11 +36,11 @@ class contractmanager {
public static function get_hourrate(int $userid) {

global $CFG, $DB;
require_once($CFG->dirroot.'/user/profile/lib.php'); // Needed for profile_load_data.
require_once($CFG->dirroot . '/user/profile/lib.php'); // Needed for profile_load_data.

$hourrate = 0.0; // Default value.

if (!$user = $DB->get_record('user', array('id' => $userid))) {
if (!$user = $DB->get_record('user', ['id' => $userid])) {
return (float) 0.0;
}

Expand All @@ -56,7 +55,6 @@ public static function get_hourrate(int $userid) {
}

foreach ($jsonobject as $formulacomponent) {

// For invalid JSON.
if (is_string($formulacomponent)) {
// We return an hour rate of 0 if the formula is invalid.
Expand All @@ -68,9 +66,11 @@ public static function get_hourrate(int $userid) {

if ($key === 'customfield') {
foreach ($value as $cfval) {
if (empty($cfval->hourrate)
if (
empty($cfval->hourrate)
|| empty($cfval->value)
|| empty($user->{'profile_field_' . $cfval->name})) {
|| empty($user->{'profile_field_' . $cfval->name})
) {
continue;
}
if ($user->{'profile_field_' . $cfval->name} === $cfval->value) {
Expand Down
10 changes: 4 additions & 6 deletions classes/external/get_all_itemids.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,16 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class get_all_itemids extends external_api {

/**
* Describes the paramters for add_item_to_cart.
*
* @return external_function_parameters
*/
public static function execute_parameters(): external_function_parameters {
return new external_function_parameters(array(
return new external_function_parameters([
'component' => new external_value(PARAM_RAW, 'component', VALUE_DEFAULT),
'area' => new external_value(PARAM_RAW, 'area', VALUE_DEFAULT),
)
);
]);
}

/**
Expand Down Expand Up @@ -117,10 +115,10 @@ public static function execute(string $component, string $area): array {
public static function execute_returns(): external_multiple_structure {
return new external_multiple_structure(
new external_single_structure(
array(
[
'id' => new external_value(PARAM_INT, 'Item id'),
'name' => new external_value(PARAM_TEXT, 'Item name'),
)
]
)
);
}
Expand Down
20 changes: 12 additions & 8 deletions classes/form/botags_modal_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@
/**
* Modal form to create single option dates which are not part of the date series.
*
* @package mod_booking
* @package local_musi
* @copyright 2022 Wunderbyte GmbH <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class botags_modal_form extends \core_form\dynamic_form {

protected function get_context_for_dynamic_submission(): \context {
return \context_system::instance();
}
Expand All @@ -42,13 +41,18 @@ public function definition() {

$existingbotagsarray = self::get_existing_botags_array();

$mform->addElement('autocomplete', 'botags', get_string('editbotags', 'local_musi'),
$existingbotagsarray, [
$mform->addElement(
'autocomplete',
'botags',
get_string('editbotags', 'local_musi'),
$existingbotagsarray,
[
'tags' => true,
'multiple' => true,
'placeholder' => get_string('createbotag', 'local_musi'),
'showsuggestions' => false
]);
'showsuggestions' => false,
]
);

$mform->addElement('html', get_string('createbotag:helptext', 'local_musi'));
}
Expand Down Expand Up @@ -86,7 +90,7 @@ public function process_dynamic_submission() {

foreach ($data->botags as $key => $value) {
if (!$DB->get_record('local_musi_botags', ['botag' => $value])) {
$newbotagrecord = new stdClass;
$newbotagrecord = new stdClass();
$newbotagrecord->botag = $value;
$DB->insert_record('local_musi_botags', $newbotagrecord);
}
Expand All @@ -109,7 +113,7 @@ protected function get_page_url_for_dynamic_submission(): \moodle_url {
*
* @return array array of existing botags
*/
private static function get_existing_botags_array (): array {
private static function get_existing_botags_array(): array {
global $DB;
$existingbotagrecords = $DB->get_records('local_musi_botags');
$existingbotagsarray = [];
Expand Down
1 change: 0 additions & 1 deletion classes/form/easy_availability_modal_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class easy_availability_modal_form extends \core_form\dynamic_form {

/**
* {@inheritDoc}
* @see moodleform::definition()
Expand Down
6 changes: 3 additions & 3 deletions classes/form/sports_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
* @copyright Wunderbyte GmbH <[email protected]>
* @author Bernhard Fischer
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @package local_musi
*/
class sports_form extends dynamic_form {

/**
* {@inheritdoc}
* @see moodleform::definition()
Expand Down Expand Up @@ -145,7 +145,7 @@ protected function get_page_url_for_dynamic_submission(): moodle_url {
if (!$cmid) {
$cmid = $this->optional_param('cmid', '', PARAM_RAW);
}
return new moodle_url('/local/musi/editoptions', array('id' => $cmid));
return new moodle_url('/local/musi/editoptions', ['id' => $cmid]);
}

/**
Expand All @@ -156,7 +156,7 @@ protected function get_page_url_for_dynamic_submission(): moodle_url {
*/
public function validation($data, $files) {

$errors = array();
$errors = [];

return $errors;
}
Expand Down
21 changes: 14 additions & 7 deletions classes/form/substitutionspool_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class substitutionspool_form extends \core_form\dynamic_form {

protected function get_context_for_dynamic_submission(): \context {
return context_system::instance();
}
Expand All @@ -51,7 +50,7 @@ public function definition() {
'multiple' => true,
'noselectionstring' => get_string('choose...', 'mod_booking'),
'ajax' => 'local_shopping_cart/form_users_selector',
'valuehtmlcallback' => function($value) {
'valuehtmlcallback' => function ($value) {
global $OUTPUT;
if (empty($value)) {
return null;
Expand All @@ -64,11 +63,18 @@ public function definition() {
'lastname' => $user->lastname,
];
return $OUTPUT->render_from_template(
'mod_booking/form-user-selector-suggestion', $details);
}
'mod_booking/form-user-selector-suggestion',
$details
);
},
];
$mform->addElement('autocomplete', 'substitutionspoolteachers',
get_string('substitutionspool:infotext', 'local_musi', $sport), [], $options);
$mform->addElement(
'autocomplete',
'substitutionspoolteachers',
get_string('substitutionspool:infotext', 'local_musi', $sport),
[],
$options
);
}

/**
Expand Down Expand Up @@ -123,7 +129,8 @@ public function process_dynamic_submission() {
public static function add_or_update_substitution_for_sport(
string $sport,
array $teacheridsarr,
bool $overwriteteachers): bool {
bool $overwriteteachers
): bool {
global $DB, $USER;
$now = time();

Expand Down
6 changes: 0 additions & 6 deletions classes/musi_payment_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class musi_payment_helper {

/**
* Helper function to get name of the orderid column for each gateway table.
* We currently do not need it here, but we'll need it later, so keep it!
Expand Down Expand Up @@ -63,9 +62,7 @@ public static function get_supported_payment_gateways(): array {
// We need the accounts to run through all the gateways.
$accounts = \core_payment\helper::get_payment_accounts_to_manage(context_system::instance());
foreach ($accounts as $account) {

foreach ($account->get_gateways() as $gateway) {

if (empty($gateway->get('enabled'))) {
continue;
}
Expand Down Expand Up @@ -100,9 +97,7 @@ public static function get_unsupported_payment_gateways(): array {
// We need the accounts to run through all the gateways.
$accounts = \core_payment\helper::get_payment_accounts_to_manage(context_system::instance());
foreach ($accounts as $account) {

foreach ($account->get_gateways() as $gateway) {

$name = $gateway->get('gateway');

// Check if there is an openorders table. If not, the gateway is not supported by transactions list.
Expand All @@ -115,5 +110,4 @@ public static function get_unsupported_payment_gateways(): array {

return $unsupportedgateways;
}

}
3 changes: 1 addition & 2 deletions classes/observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
* Event observer for local_musi.
*/
class observer {

/**
* Observer for the payment_added event
*/
Expand Down Expand Up @@ -74,7 +73,7 @@ public static function bookingoption_updated(\mod_booking\event\bookingoption_up
$teacherids = array_keys($settings->teachers);
if (
isset($settings->customfieldsfortemplates['sport'])
&& isset ($settings->customfieldsfortemplates['sport']['value'])
&& isset($settings->customfieldsfortemplates['sport']['value'])
) {
$value = $settings->customfieldsfortemplates['sport']['value'];
// Depending on the type of customfield handle differently.
Expand Down
7 changes: 3 additions & 4 deletions classes/output/allcourses.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class allcourses implements renderable, templatable {

/** @var stdClass $cards */
public $cards = [];

Expand All @@ -59,9 +58,9 @@ public function __construct($card = null) {
*/
public function export_for_template(renderer_base $output) {

$returnarray = array(
'cards' => (array)$this->cards
);
$returnarray = [
'cards' => (array)$this->cards,
];

return $returnarray;
}
Expand Down
7 changes: 3 additions & 4 deletions classes/output/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class card implements renderable, templatable {

/** @var string $title */
public $title = null;

Expand Down Expand Up @@ -73,12 +72,12 @@ public function __construct($title = null, $content = null, $footer = null, $hea
*/
public function export_for_template(renderer_base $output) {

$returnarray = array(
$returnarray = [
'title' => $this->title,
'content' => $this->content,
'footer' => $this->footer,
'headerbgcolor' => $this->headerbgcolor
);
'headerbgcolor' => $this->headerbgcolor,
];

return $returnarray;
}
Expand Down
4 changes: 1 addition & 3 deletions classes/output/card_content_entities.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class card_content_entities implements renderable, templatable {

/** @var stdClass $title */
public $data = null;

Expand Down Expand Up @@ -83,9 +82,8 @@ public function export_for_template(renderer_base $output) {

// We transform the data object to an array where we can read key & value.
foreach ($this->data as $key => $value) {

$item = [
'key' => get_string($key, 'local_musi')
'key' => get_string($key, 'local_musi'),
];

// We only have value & link at the time as types, but might have more at one point.
Expand Down
3 changes: 0 additions & 3 deletions classes/output/card_content_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class card_content_settings implements renderable, templatable {

/** @var stdClass $title */
public $data = null;

Expand Down Expand Up @@ -70,7 +69,6 @@ private static function return_content() {

$url = new moodle_url('/mod/booking/view.php', ['id' => $cmid, 'whichview' => 'showall']);
$data->editbookings = ['link' => $url->out(false)];

} else {
$url = new moodle_url('/admin/category.php?category=local_musi');
$data->addbookinginstance = ['link' => $url->out(false)];
Expand Down Expand Up @@ -119,7 +117,6 @@ public function export_for_template(renderer_base $output) {

// We transform the data object to an array where we can read key & value.
foreach ($this->data as $key => $value) {

$item = [
'key' => get_string($key, 'local_musi'),
];
Expand Down
7 changes: 3 additions & 4 deletions classes/output/card_content_sports.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class card_content_sports implements renderable, templatable {

/** @var stdClass $title */
public $data = null;

Expand Down Expand Up @@ -75,7 +74,8 @@ private static function return_sports_stats() {
ON m.id = cm.module
WHERE m.name = 'page'
AND (p.content LIKE '%allekurse%category%'
OR p.intro LIKE '%allekurse%category%')");
OR p.intro LIKE '%allekurse%category%')"
);

foreach ($sportspages as $sportspage) {
$url = new moodle_url('/mod/page/view.php', ['id' => $sportspage->id]);
Expand All @@ -97,9 +97,8 @@ public function export_for_template(renderer_base $output) {

// We transform the data object to an array where we can read key & value.
foreach ($this->data as $key => $value) {

$item = [
'key' => $key
'key' => $key,
];

// We only have value & link at the time as types, but might have more at one point.
Expand Down
Loading

0 comments on commit ab3c508

Please sign in to comment.