Skip to content

Commit

Permalink
Coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
sh-csg committed Jan 25, 2024
1 parent 581f966 commit a4a6ed5
Show file tree
Hide file tree
Showing 16 changed files with 68 additions and 76 deletions.
1 change: 0 additions & 1 deletion backup/moodle2/backup_kanban_activity_task.class.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 backup_kanban_activity_task extends backup_activity_task {

/**
* No specific settings for this activity
*/
Expand Down
7 changes: 4 additions & 3 deletions backup/moodle2/backup_kanban_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,14 @@ protected function define_structure(): backup_nested_element {
$historyitem->annotate_ids('kanban_card_id', 'kanban_card');
$historyitem->annotate_ids('kanban_column_id', 'kanban_column');
$historyitem->annotate_ids('kanban_board_id', 'kanban_board');

} else {
$board->set_source_sql('
$board->set_source_sql(
'
SELECT *
FROM {kanban_board}
WHERE kanban_instance = ? AND userid = 0 AND groupid = 0 AND template = 1',
[backup::VAR_PARENTID]);
[backup::VAR_PARENTID]
);
}
$column->set_source_table('kanban_column', ['kanban_board' => backup::VAR_PARENTID]);
$card->set_source_table('kanban_card', ['kanban_column' => backup::VAR_PARENTID]);
Expand Down
1 change: 0 additions & 1 deletion backup/moodle2/restore_kanban_activity_task.class.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 restore_kanban_activity_task extends restore_activity_task {

/**
* No specific settings for this activity
*
Expand Down
1 change: 0 additions & 1 deletion backup/moodle2/restore_kanban_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class restore_kanban_activity_structure_step extends restore_activity_structure_step {

/**
* List of elements that can be restored
*
Expand Down
18 changes: 10 additions & 8 deletions classes/boardmanager.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class boardmanager {
public function __construct(int $cmid = 0, int $boardid = 0) {
$this->cmid = $cmid;
if ($cmid) {
list($this->course, $this->cminfo) = get_course_and_cm_from_cmid($cmid);
[$this->course, $this->cminfo] = get_course_and_cm_from_cmid($cmid);
$this->load_instance($this->cminfo->instance);
}
$this->formatter = new updateformatter();
Expand All @@ -86,7 +86,7 @@ public function load_instance(int $instance, bool $dontloadcm = false): void {
global $DB;
$this->kanban = $DB->get_record('kanban', ['id' => $instance], '*', MUST_EXIST);
if (!$dontloadcm) {
list ($this->course, $this->cminfo) = get_course_and_cm_from_instance($this->kanban->id, 'kanban');
[$this->course, $this->cminfo] = get_course_and_cm_from_instance($this->kanban->id, 'kanban');
$this->cmid = $this->cminfo->id;
}
}
Expand Down Expand Up @@ -476,7 +476,8 @@ public function add_card(int $columnid, int $aftercard = 0, array $data = []): i
$DB->update_record('kanban_column', $update);

// Users can always edit cards they created.
$data['canedit'] = $this->can_user_manage_specific_card($data['id']);;
$data['canedit'] = $this->can_user_manage_specific_card($data['id']);
;
$data['columnname'] = clean_param($column->title, PARAM_TEXT);

$this->formatter->put('cards', $data);
Expand Down Expand Up @@ -853,7 +854,7 @@ public function update_card(int $cardid, array $data): void {
helper::add_or_update_calendar_event($this->kanban, (object) $carddata, $assignees);
if (!empty($todelete)) {
helper::remove_calendar_event($this->kanban, (object) $carddata, $todelete);
list($sql, $params) = $DB->get_in_or_equal($todelete, SQL_PARAMS_NAMED);
[$sql, $params] = $DB->get_in_or_equal($todelete, SQL_PARAMS_NAMED);
$sql = 'kanban_card = :cardid AND userid ' . $sql;
$params['cardid'] = $cardid;
$DB->delete_records_select('kanban_assignee', $sql, $params);
Expand Down Expand Up @@ -882,8 +883,7 @@ public function update_card(int $cardid, array $data): void {
'id' => $user->id,
'fullname' => fullname($user),
'userpicture' => $OUTPUT->user_picture($user, ['link' => false]),
]
);
]);
}
$DB->insert_records('kanban_assignee', $assignees);
helper::send_notification(
Expand Down Expand Up @@ -1221,8 +1221,10 @@ public function can_user_manage_specific_card(int $cardid, int $userid = 0): boo
return true;
}

if (has_capability('mod/kanban:manageassignedcards', $context, $userid) &&
in_array($userid, $this->get_card_assignees($card->id))) {
if (
has_capability('mod/kanban:manageassignedcards', $context, $userid) &&
in_array($userid, $this->get_card_assignees($card->id))
) {
return true;
}

Expand Down
6 changes: 4 additions & 2 deletions classes/completion/custom_completion.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public function get_state(string $rule): int {

if ($rule == 'completioncreate') {
if ($kanban->completioncreate > 0) {
$count = $DB->get_field_sql('
$count = $DB->get_field_sql(
'
SELECT COUNT(DISTINCT c.id)
FROM {kanban_board} b
INNER JOIN {kanban_card} c ON b.kanban_instance = :kanbanid AND c.kanban_board = b.id
Expand All @@ -52,7 +53,8 @@ public function get_state(string $rule): int {
}
if ($rule == 'completioncomplete') {
if ($kanban->completioncomplete > 0) {
$count = $DB->get_field_sql('
$count = $DB->get_field_sql(
'
SELECT COUNT(DISTINCT c.id)
FROM {kanban_board} b
INNER JOIN {kanban_card} c ON b.kanban_instance = :kanbanid AND c.kanban_board = b.id AND c.completed != 0
Expand Down
34 changes: 16 additions & 18 deletions classes/external/change_kanban_content.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class change_kanban_content extends external_api {

/**
* Returns description of method parameters for the add_column function.
*
Expand Down Expand Up @@ -108,7 +107,7 @@ public static function add_column(int $cmid, int $boardid, array $data): array {
$data['title'] = clean_param($params['data']['title'], PARAM_TEXT);
}
$aftercol = $params['data']['aftercol'];
list($course, $cminfo) = get_course_and_cm_from_cmid($cmid);
[$course, $cminfo] = get_course_and_cm_from_cmid($cmid);
$context = context_module::instance($cmid);
self::validate_context($context);
require_capability('mod/kanban:managecolumns', $context);
Expand Down Expand Up @@ -181,7 +180,7 @@ public static function add_card(int $cmid, int $boardid, array $data): array {
$data['title'] = clean_param($params['data']['title'], PARAM_TEXT);
}
$aftercard = $params['data']['aftercard'];
list($course, $cminfo) = get_course_and_cm_from_cmid($cmid);
[$course, $cminfo] = get_course_and_cm_from_cmid($cmid);
$context = context_module::instance($cmid);
self::validate_context($context);
require_capability('mod/kanban:addcard', $context);
Expand Down Expand Up @@ -244,7 +243,7 @@ public static function move_column(int $cmid, int $boardid, array $data): array
$boardid = $params['boardid'];
$aftercol = $params['data']['aftercol'];
$columnid = $params['data']['columnid'];
list($course, $cminfo) = get_course_and_cm_from_cmid($cmid);
[$course, $cminfo] = get_course_and_cm_from_cmid($cmid);
$context = context_module::instance($cmid);
self::validate_context($context);
require_capability('mod/kanban:managecolumns', $context);
Expand Down Expand Up @@ -311,7 +310,7 @@ public static function move_card(int $cmid, int $boardid, array $data): array {
$aftercard = $params['data']['aftercard'];
$columnid = $params['data']['columnid'];
$cardid = $params['data']['cardid'];
list($course, $cminfo) = get_course_and_cm_from_cmid($cmid);
[$course, $cminfo] = get_course_and_cm_from_cmid($cmid);
$context = context_module::instance($cmid);
self::validate_context($context);
$boardmanager = new boardmanager($cmid, $boardid);
Expand Down Expand Up @@ -375,7 +374,7 @@ public static function delete_card(int $cmid, int $boardid, array $data): array
$cmid = $params['cmid'];
$boardid = $params['boardid'];
$cardid = $params['data']['cardid'];
list($course, $cminfo) = get_course_and_cm_from_cmid($cmid);
[$course, $cminfo] = get_course_and_cm_from_cmid($cmid);
$context = context_module::instance($cmid);
self::validate_context($context);

Expand Down Expand Up @@ -439,7 +438,7 @@ public static function delete_column(int $cmid, int $boardid, array $data): arra
$cmid = $params['cmid'];
$boardid = $params['boardid'];
$columnid = $params['data']['columnid'];
list($course, $cminfo) = get_course_and_cm_from_cmid($cmid);
[$course, $cminfo] = get_course_and_cm_from_cmid($cmid);
$context = context_module::instance($cmid);
self::validate_context($context);
require_capability('mod/kanban:managecolumns', $context);
Expand Down Expand Up @@ -502,7 +501,7 @@ public static function assign_user(int $cmid, int $boardid, array $data): array
$boardid = $params['boardid'];
$cardid = $params['data']['cardid'];
$userid = $params['data']['userid'];
list($course, $cminfo) = get_course_and_cm_from_cmid($cmid);
[$course, $cminfo] = get_course_and_cm_from_cmid($cmid);
$context = context_module::instance($cmid);
self::validate_context($context);
if (empty($userid)) {
Expand Down Expand Up @@ -573,7 +572,7 @@ public static function unassign_user(int $cmid, int $boardid, array $data): arra
if (empty($userid)) {
$userid = $USER->id;
}
list($course, $cminfo) = get_course_and_cm_from_cmid($cmid);
[$course, $cminfo] = get_course_and_cm_from_cmid($cmid);
$context = context_module::instance($cmid);
self::validate_context($context);
if ($userid == $USER->id) {
Expand Down Expand Up @@ -640,7 +639,7 @@ public static function set_card_complete(int $cmid, int $boardid, array $data):
$boardid = $params['boardid'];
$state = $params['data']['state'];
$cardid = $params['data']['cardid'];
list($course, $cminfo) = get_course_and_cm_from_cmid($cmid);
[$course, $cminfo] = get_course_and_cm_from_cmid($cmid);
$context = context_module::instance($cmid);
self::validate_context($context);
$boardmanager = new boardmanager($cmid, $boardid);
Expand Down Expand Up @@ -706,7 +705,7 @@ public static function set_column_locked(int $cmid, int $boardid, array $data):
$boardid = $params['boardid'];
$state = $params['data']['state'];
$columnid = $params['data']['columnid'];
list($course, $cminfo) = get_course_and_cm_from_cmid($cmid);
[$course, $cminfo] = get_course_and_cm_from_cmid($cmid);
$context = context_module::instance($cmid);
self::validate_context($context);

Expand Down Expand Up @@ -770,7 +769,7 @@ public static function set_board_columns_locked(int $cmid, int $boardid, array $
$boardid = $params['boardid'];
$state = $params['data']['state'];

list($course, $cminfo) = get_course_and_cm_from_cmid($cmid);
[$course, $cminfo] = get_course_and_cm_from_cmid($cmid);
$context = context_module::instance($cmid);
self::validate_context($context);

Expand Down Expand Up @@ -835,7 +834,7 @@ public static function add_discussion_message(int $cmid, int $boardid, array $da
// Additional cleaning most likely not needed, because message is PARAM_TEXT, but let's be extra sure.
$message = clean_param($params['data']['message'], PARAM_TEXT);

list($course, $cminfo) = get_course_and_cm_from_cmid($cmid);
[$course, $cminfo] = get_course_and_cm_from_cmid($cmid);
$context = context_module::instance($cmid);
self::validate_context($context);

Expand All @@ -848,7 +847,6 @@ public static function add_discussion_message(int $cmid, int $boardid, array $da
return [
'update' => $boardmanager->get_formatted_updates(),
];

}

/**
Expand Down Expand Up @@ -899,7 +897,7 @@ public static function delete_discussion_message(int $cmid, int $boardid, array
$boardid = $params['boardid'];
$messageid = $params['data']['messageid'];

list($course, $cminfo) = get_course_and_cm_from_cmid($cmid);
[$course, $cminfo] = get_course_and_cm_from_cmid($cmid);
$context = context_module::instance($cmid);
self::validate_context($context);

Expand Down Expand Up @@ -961,7 +959,7 @@ public static function save_as_template(int $cmid, int $boardid): array {
]);
$cmid = $params['cmid'];
$boardid = $params['boardid'];
list($course, $cminfo) = get_course_and_cm_from_cmid($cmid);
[$course, $cminfo] = get_course_and_cm_from_cmid($cmid);
$context = context_module::instance($cmid);
self::validate_context($context);
require_capability('mod/kanban:manageboard', $context);
Expand Down Expand Up @@ -1016,7 +1014,7 @@ public static function delete_board(int $cmid, int $boardid): array {
]);
$cmid = $params['cmid'];
$boardid = $params['boardid'];
list($course, $cminfo) = get_course_and_cm_from_cmid($cmid);
[$course, $cminfo] = get_course_and_cm_from_cmid($cmid);
$context = context_module::instance($cmid);
self::validate_context($context);

Expand Down Expand Up @@ -1081,7 +1079,7 @@ public static function push_card_copy(int $cmid, int $boardid, array $data): arr
$cmid = $params['cmid'];
$boardid = $params['boardid'];
$cardid = $params['data']['cardid'];
list($course, $cminfo) = get_course_and_cm_from_cmid($cmid);
[$course, $cminfo] = get_course_and_cm_from_cmid($cmid);
$context = context_module::instance($cmid);
self::validate_context($context);

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

/**
* Returns description of method parameters for the execute webservice function.
*
Expand Down Expand Up @@ -342,7 +341,7 @@ public static function execute(int $cmid, int $boardid, int $timestamp = 0, bool
$cmid = $params['cmid'];
$boardid = $params['boardid'];
$timestamp = $params['timestamp'];
list($course, $cminfo) = get_course_and_cm_from_cmid($cmid);
[$course, $cminfo] = get_course_and_cm_from_cmid($cmid);
$context = context_module::instance($cmid);
self::validate_context($context);
require_capability('mod/kanban:view', $context);
Expand Down Expand Up @@ -429,7 +428,7 @@ public static function execute(int $cmid, int $boardid, int $timestamp = 0, bool
}
if (!empty($kanbanboard->groupid)) {
$members = groups_get_members($kanbanboard->groupid, 'u.id');
$members = array_map(function($v) {
$members = array_map(function ($v) {
return intval($v->id);
}, $members);
$ismember = in_array($USER->id, $members);
Expand All @@ -449,7 +448,7 @@ public static function execute(int $cmid, int $boardid, int $timestamp = 0, bool
}
}

$common = new stdClass;
$common = new stdClass();
$common->timestamp = time();
$common->id = $cmid;
$common->userid = $USER->id;
Expand Down Expand Up @@ -626,7 +625,7 @@ public static function get_discussion_update_returns(): external_single_structur
*/
public static function get_discussion_update(int $cmid, int $boardid, int $cardid, int $timestamp = 0): array {
global $DB, $USER;
list($course, $cminfo) = get_course_and_cm_from_cmid($cmid);
[$course, $cminfo] = get_course_and_cm_from_cmid($cmid);
$context = context_module::instance($cmid);
self::validate_context($context);
require_capability('mod/kanban:view', $context);
Expand Down Expand Up @@ -696,7 +695,7 @@ public static function get_history_update_returns(): external_single_structure {
*/
public static function get_history_update(int $cmid, int $boardid, int $cardid, int $timestamp = 0): array {
global $DB;
list($course, $cminfo) = get_course_and_cm_from_cmid($cmid);
[$course, $cminfo] = get_course_and_cm_from_cmid($cmid);
$context = context_module::instance($cmid);
self::validate_context($context);
require_capability('mod/kanban:viewhistory', $context);
Expand Down
1 change: 0 additions & 1 deletion classes/form/edit_card_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ public function process_dynamic_submission(): array {
return [
'update' => $boardmanager->get_formatted_updates(),
];

}

/**
Expand Down
4 changes: 2 additions & 2 deletions classes/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public static function check_permissions_for_user_or_group(
}
if (!empty($board->groupid)) {
$members = groups_get_members($board->groupid, 'u.id');
$members = array_map(function($v) {
$members = array_map(function ($v) {
return intval($v->id);
}, $members);
$ismember = in_array($USER->id, $members);
Expand Down Expand Up @@ -302,7 +302,7 @@ public static function add_or_update_calendar_event(stdClass $kanban, stdClass $
public static function remove_calendar_event(stdClass $kanban, stdClass $card, array $users = []) {
global $DB;
if (!empty($users)) {
list($sql, $params) = $DB->get_in_or_equal($users, SQL_PARAMS_NAMED);
[$sql, $params] = $DB->get_in_or_equal($users, SQL_PARAMS_NAMED);
$sql = 'instance = :id AND uuid = :cardid AND userid ' . $sql;
$params['cardid'] = $card->id;
$params['id'] = $kanban->id;
Expand Down
Loading

0 comments on commit a4a6ed5

Please sign in to comment.