Skip to content

Commit

Permalink
Use phpcbf to convert long array syntax to short
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjnelson committed Jan 31, 2024
1 parent 01c22ee commit e02769e
Show file tree
Hide file tree
Showing 71 changed files with 531 additions and 531 deletions.
2 changes: 1 addition & 1 deletion ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
$values = json_decode($values);

// Make sure the template exists.
$template = $DB->get_record('customcert_templates', array('id' => $tid), '*', MUST_EXIST);
$template = $DB->get_record('customcert_templates', ['id' => $tid], '*', MUST_EXIST);

// Set the template.
$template = new \mod_customcert\template($template);
Expand Down
30 changes: 15 additions & 15 deletions backup/moodle2/backup_customcert_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,30 +39,30 @@ class backup_customcert_activity_structure_step extends backup_activity_structur
protected function define_structure() {

// The instance.
$customcert = new backup_nested_element('customcert', array('id'), array(
$customcert = new backup_nested_element('customcert', ['id'], [
'templateid', 'name', 'intro', 'introformat', 'requiredtime', 'verifyany', 'emailstudents',
'emailteachers', 'emailothers', 'protection', 'timecreated', 'timemodified'));
'emailteachers', 'emailothers', 'protection', 'timecreated', 'timemodified']);

// The template.
$template = new backup_nested_element('template', array('id'), array(
'name', 'contextid', 'timecreated', 'timemodified'));
$template = new backup_nested_element('template', ['id'], [
'name', 'contextid', 'timecreated', 'timemodified']);

// The pages.
$pages = new backup_nested_element('pages');
$page = new backup_nested_element('page', array('id'), array(
$page = new backup_nested_element('page', ['id'], [
'templateid', 'width', 'height', 'leftmargin', 'rightmargin',
'sequence', 'timecreated', 'timemodified'));
'sequence', 'timecreated', 'timemodified']);

// The elements.
$element = new backup_nested_element('element', array('id'), array(
$element = new backup_nested_element('element', ['id'], [
'pageid', 'name', 'element', 'data', 'font', 'fontsize',
'colour', 'posx', 'posy', 'width', 'refpoint', 'sequence',
'alignment', 'timecreated', 'timemodified'));
'alignment', 'timecreated', 'timemodified']);

// The issues.
$issues = new backup_nested_element('issues');
$issue = new backup_nested_element('issue', array('id'), array(
'customcertid', 'userid', 'timecreated', 'emailed', 'code'));
$issue = new backup_nested_element('issue', ['id'], [
'customcertid', 'userid', 'timecreated', 'emailed', 'code']);

// Build the tree.
$customcert->add_child($issues);
Expand All @@ -73,20 +73,20 @@ protected function define_structure() {
$page->add_child($element);

// Define sources.
$customcert->set_source_table('customcert', array('id' => backup::VAR_ACTIVITYID));
$customcert->set_source_table('customcert', ['id' => backup::VAR_ACTIVITYID]);

// Define template source.
$template->set_source_table('customcert_templates', array('contextid' => backup::VAR_CONTEXTID));
$template->set_source_table('customcert_templates', ['contextid' => backup::VAR_CONTEXTID]);

// Define page source.
$page->set_source_table('customcert_pages', array('templateid' => backup::VAR_PARENTID));
$page->set_source_table('customcert_pages', ['templateid' => backup::VAR_PARENTID]);

// Define element source, each element belongs to a page.
$element->set_source_table('customcert_elements', array('pageid' => backup::VAR_PARENTID));
$element->set_source_table('customcert_elements', ['pageid' => backup::VAR_PARENTID]);

// If we are including user info then save the issues.
if ($this->get_setting_value('userinfo')) {
$issue->set_source_table('customcert_issues', array('customcertid' => backup::VAR_ACTIVITYID));
$issue->set_source_table('customcert_issues', ['customcertid' => backup::VAR_ACTIVITYID]);
}

// Annotate the user id's where required.
Expand Down
10 changes: 5 additions & 5 deletions backup/moodle2/restore_customcert_activity_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ protected function define_my_steps() {
* Define the contents in the activity that must be processed by the link decoder.
*/
public static function define_decode_contents() {
$contents = array();
$contents = [];

$contents[] = new restore_decode_content('customcert', array('intro'), 'customcert');
$contents[] = new restore_decode_content('customcert', ['intro'], 'customcert');

return $contents;
}
Expand All @@ -65,7 +65,7 @@ public static function define_decode_contents() {
* Define the decoding rules for links belonging to the activity to be executed by the link decoder.
*/
public static function define_decode_rules() {
$rules = array();
$rules = [];

$rules[] = new restore_decode_rule('CUSTOMCERTVIEWBYID', '/mod/customcert/view.php?id=$1', 'course_module');
$rules[] = new restore_decode_rule('CUSTOMCERTINDEX', '/mod/customcert/index.php?id=$1', 'course');
Expand All @@ -81,7 +81,7 @@ public static function define_decode_rules() {
* @return array the restore log rules
*/
public static function define_restore_log_rules() {
$rules = array();
$rules = [];

$rules[] = new restore_log_rule('customcert', 'add', 'view.php?id={course_module}', '{customcert}');
$rules[] = new restore_log_rule('customcert', 'update', 'view.php?id={course_module}', '{customcert}');
Expand All @@ -108,7 +108,7 @@ public function after_restore() {
INNER JOIN {customcert} c
ON p.templateid = c.templateid
WHERE c.id = :customcertid";
if ($elements = $DB->get_records_sql($sql, array('customcertid' => $this->get_activityid()))) {
if ($elements = $DB->get_records_sql($sql, ['customcertid' => $this->get_activityid()])) {
// Go through the elements for the certificate.
foreach ($elements as $e) {
// Get an instance of the element class.
Expand Down
2 changes: 1 addition & 1 deletion backup/moodle2/restore_customcert_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class restore_customcert_activity_structure_step extends restore_activity_struct
*/
protected function define_structure() {
// The array used to store the path to the items we want to restore.
$paths = array();
$paths = [];

// The customcert instance.
$paths[] = new restore_path_element('customcert', '/activity/customcert');
Expand Down
32 changes: 16 additions & 16 deletions classes/certificate.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class certificate {
* @return string the value to insert into the protection field
*/
public static function set_protection($data) {
$protection = array();
$protection = [];

if (!empty($data->protection_print)) {
$protection[] = self::PROTECTION_PRINT;
Expand Down Expand Up @@ -157,7 +157,7 @@ public static function get_fonts() {
*/
public static function get_font_sizes() {
// Array to store the sizes.
$sizes = array();
$sizes = [];

for ($i = 1; $i <= 200; $i++) {
$sizes[$i] = $i;
Expand Down Expand Up @@ -214,7 +214,7 @@ public static function get_course_time(int $courseid, int $userid = 0): int {
WHERE userid = :userid
AND $coursefield = :courseid
ORDER BY $timefield ASC";
$params = array('userid' => $userid, 'courseid' => $courseid);
$params = ['userid' => $userid, 'courseid' => $courseid];
$totaltime = 0;
if ($logs = $DB->get_recordset_sql($sql, $params)) {
foreach ($logs as $log) {
Expand Down Expand Up @@ -261,15 +261,15 @@ public static function get_issues($customcertid, $groupmode, $cm, $limitfrom, $l

// If it is empty then return an empty array.
if (empty($conditionsparams)) {
return array();
return [];
}

// Return the issues.
$context = \context_module::instance($cm->id);
$query = \core_user\fields::for_identity($context)->with_userpic()->get_sql('u', true, '', '', false);

// Add the conditional SQL and the customcertid to form all used parameters.
$allparams = $query->params + $conditionsparams + array('customcertid' => $customcertid);
$allparams = $query->params + $conditionsparams + ['customcertid' => $customcertid];

$orderby = $sort ?: $DB->sql_fullname();

Expand Down Expand Up @@ -304,7 +304,7 @@ public static function get_number_of_issues($customcertid, $cm, $groupmode) {
}

// Add the conditional SQL and the customcertid to form all used parameters.
$allparams = $conditionsparams + array('customcertid' => $customcertid);
$allparams = $conditionsparams + ['customcertid' => $customcertid];

// Return the number of issues.
$sql = "SELECT COUNT(u.id) as count
Expand All @@ -330,7 +330,7 @@ public static function get_conditional_issues_sql($cm, $groupmode) {
// Get all users that can manage this customcert to exclude them from the report.
$context = \context_module::instance($cm->id);
$conditionssql = '';
$conditionsparams = array();
$conditionsparams = [];

// Get all users that can manage this certificate to exclude them from the report.
$certmanagers = array_keys(get_users_by_capability($context, 'mod/customcert:manage', 'u.id'));
Expand All @@ -345,30 +345,30 @@ public static function get_conditional_issues_sql($cm, $groupmode) {

// If we are viewing all participants and the user does not have access to all groups then return nothing.
if (!$currentgroup && !$canaccessallgroups) {
return array('', array());
return ['', []];
}

if ($currentgroup) {
if (!$canaccessallgroups) {
// Guest users do not belong to any groups.
if (isguestuser()) {
return array('', array());
return ['', []];
}

// Check that the user belongs to the group we are viewing.
$usersgroups = groups_get_all_groups($cm->course, $USER->id, $cm->groupingid);
if ($usersgroups) {
if (!isset($usersgroups[$currentgroup])) {
return array('', array());
return ['', []];
}
} else { // They belong to no group, so return an empty array.
return array('', array());
return ['', []];
}
}

$groupusers = array_keys(groups_get_members($currentgroup, 'u.*'));
if (empty($groupusers)) {
return array('', array());
return ['', []];
}

list($sql, $params) = $DB->get_in_or_equal($groupusers, SQL_PARAMS_NAMED, 'grp');
Expand All @@ -377,7 +377,7 @@ public static function get_conditional_issues_sql($cm, $groupmode) {
}
}

return array($conditionssql, $conditionsparams);
return [$conditionssql, $conditionsparams];
}

/**
Expand All @@ -394,7 +394,7 @@ public static function get_number_of_certificates_for_user($userid) {
INNER JOIN {customcert_issues} ci
ON c.id = ci.customcertid
WHERE ci.userid = :userid";
return $DB->count_records_sql($sql, array('userid' => $userid));
return $DB->count_records_sql($sql, ['userid' => $userid]);
}

/**
Expand All @@ -421,7 +421,7 @@ public static function get_certificates_for_user($userid, $limitfrom, $limitnum,
ON c.course = co.id
WHERE ci.userid = :userid
ORDER BY $sort";
return $DB->get_records_sql($sql, array('userid' => $userid), $limitfrom, $limitnum);
return $DB->get_records_sql($sql, ['userid' => $userid], $limitfrom, $limitnum);
}

/**
Expand Down Expand Up @@ -456,7 +456,7 @@ public static function generate_code() {
$uniquecodefound = false;
$code = random_string(10);
while (!$uniquecodefound) {
if (!$DB->record_exists('customcert_issues', array('code' => $code))) {
if (!$DB->record_exists('customcert_issues', ['code' => $code])) {
$uniquecodefound = true;
} else {
$code = random_string(10);
Expand Down
4 changes: 2 additions & 2 deletions classes/edit_element_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class edit_element_form extends \moodleform {
public function definition() {
$mform =& $this->_form;

$mform->updateAttributes(array('id' => 'editelementform'));
$mform->updateAttributes(['id' => 'editelementform']);

$element = $this->_customdata['element'];

Expand Down Expand Up @@ -85,7 +85,7 @@ public function definition_after_data() {
* @return array the errors that were found
*/
public function validation($data, $files) {
$errors = array();
$errors = [];

if (\core_text::strlen($data['name']) > 255) {
$errors['name'] = get_string('nametoolong', 'customcert');
Expand Down
Loading

0 comments on commit e02769e

Please sign in to comment.