Skip to content

Commit 7f0722a

Browse files
committed
codecleaning with new codechecker version
1 parent 0545f4a commit 7f0722a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1518
-827
lines changed

backup/moodle2/backup_moodleoverflow_activity_task.class.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3737
*/
3838
class backup_moodleoverflow_activity_task extends backup_activity_task {
39-
4039
/**
4140
* No specific settings for this activity
4241
*/

backup/moodle2/backup_moodleoverflow_stepslib.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3333
*/
3434
class backup_moodleoverflow_activity_structure_step extends backup_activity_structure_step {
35-
3635
/**
3736
* Defines the backup structure of the module
3837
*
@@ -108,11 +107,13 @@ protected function define_structure() {
108107

109108
// All these source definitions only happen if we are including user info.
110109
if ($userinfo) {
111-
$discussion->set_source_sql('
110+
$discussion->set_source_sql(
111+
'
112112
SELECT *
113113
FROM {moodleoverflow_discussions}
114114
WHERE moodleoverflow = ?',
115-
[backup::VAR_PARENTID]);
115+
[backup::VAR_PARENTID]
116+
);
116117

117118
// Need posts ordered by id so parents are always before childs on restore.
118119
$post->set_source_table('moodleoverflow_posts', ['discussion' => backup::VAR_PARENTID], 'id ASC');

backup/moodle2/restore_moodleoverflow_activity_task.class.php

Lines changed: 141 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3939
*/
4040
class restore_moodleoverflow_activity_task extends restore_activity_task {
41-
4241
/**
4342
* Define (add) particular settings this activity can have
4443
*/
@@ -79,18 +78,24 @@ public static function define_decode_rules() {
7978

8079
$rules[] = new restore_decode_rule('MOODLEOVERFLOWVIEWBYF', '/mod/moodleoverflow/view.php?f=$1', 'moodleoverflow');
8180
// Link to forum discussion.
82-
$rules[] = new restore_decode_rule('MOODLEOVERFLOWDISCUSSIONVIEW',
81+
$rules[] = new restore_decode_rule(
82+
'MOODLEOVERFLOWDISCUSSIONVIEW',
8383
'/mod/moodleoverflow/discussion.php?d=$1',
84-
'moodleoverflow_discussion');
84+
'moodleoverflow_discussion'
85+
);
8586
// Link to discussion with parent and with anchor posts.
86-
$rules[] = new restore_decode_rule('MOODLEOVERFLOWDISCUSSIONVIEWPARENT',
87+
$rules[] = new restore_decode_rule(
88+
'MOODLEOVERFLOWDISCUSSIONVIEWPARENT',
8789
'/mod/moodleoverflow/discussion.php?d=$1&parent=$2',
88-
['moodleoverflow_discussion', 'moodleoverflow_post']);
89-
$rules[] = new restore_decode_rule('MOODLEOVERFLOWDISCUSSIONVIEWINSIDE', '/mod/moodleoverflow/discussion.php?d=$1#$2',
90-
['moodleoverflow_discussion', 'moodleoverflow_post']);
90+
['moodleoverflow_discussion', 'moodleoverflow_post']
91+
);
92+
$rules[] = new restore_decode_rule(
93+
'MOODLEOVERFLOWDISCUSSIONVIEWINSIDE',
94+
'/mod/moodleoverflow/discussion.php?d=$1#$2',
95+
['moodleoverflow_discussion', 'moodleoverflow_post']
96+
);
9197

9298
return $rules;
93-
9499
}
95100

96101
/**
@@ -102,49 +107,134 @@ public static function define_decode_rules() {
102107
public static function define_restore_log_rules() {
103108
$rules = [];
104109

105-
$rules[] = new restore_log_rule('moodleoverflow', 'add',
106-
'view.php?id={course_module}', '{moodleoverflow}');
107-
$rules[] = new restore_log_rule('moodleoverflow', 'update',
108-
'view.php?id={course_module}', '{moodleoverflow}');
109-
$rules[] = new restore_log_rule('moodleoverflow', 'view',
110-
'view.php?id={course_module}', '{moodleoverflow}');
111-
$rules[] = new restore_log_rule('moodleoverflow', 'view moodleoverflow',
112-
'view.php?id={course_module}', '{moodleoverflow}');
113-
$rules[] = new restore_log_rule('moodleoverflow', 'mark read',
114-
'view.php?f={moodleoverflow}', '{moodleoverflow}');
115-
$rules[] = new restore_log_rule('moodleoverflow', 'start tracking',
116-
'view.php?f={moodleoverflow}', '{moodleoverflow}');
117-
$rules[] = new restore_log_rule('moodleoverflow', 'stop tracking',
118-
'view.php?f={moodloeoverflow}', '{moodleoverflow}');
119-
$rules[] = new restore_log_rule('moodleoverflow', 'subscribe',
120-
'view.php?f={moodleoverflow}', '{moodleoverflow}');
121-
$rules[] = new restore_log_rule('moodleoverflow', 'unsubscribe',
122-
'view.php?f={moodleoverflow}', '{moodleoverflow}');
123-
$rules[] = new restore_log_rule('moodleoverflow', 'subscriber',
124-
'subscribers.php?id={moodleoverflow}', '{moodleoverflow}');
125-
$rules[] = new restore_log_rule('moodleoverflow', 'subscribers',
126-
'subscribers.php?id={moodleoverflow}', '{moodleoverflow}');
127-
$rules[] = new restore_log_rule('moodleoverflow', 'view subscribers',
128-
'subscribers.php?id={moodleoverflow}', '{moodleoverflow}');
129-
$rules[] = new restore_log_rule('moodleoverflow', 'add discussion',
130-
'discussion.php?d={moodleoverflow_discussion}', '{moodleoverflow_discussion}');
131-
$rules[] = new restore_log_rule('moodleoverflow', 'view discussion',
132-
'discussion.php?d={moodleoverflow_discussion}', '{moodleoverflow_discussion}');
133-
$rules[] = new restore_log_rule('moodleoverflow', 'move discussion',
134-
'discussion.php?d={moodleoverflow_discussion}', '{moodleoverflow_discussion}');
135-
$rules[] = new restore_log_rule('moodleoverflow', 'delete discussi',
136-
'view.php?id={course_module}', '{moodleoverflow}',
137-
null, 'delete discussion');
138-
$rules[] = new restore_log_rule('moodleoverflow', 'delete discussion',
139-
'view.php?id={course_module}', '{moodleoverflow}');
140-
$rules[] = new restore_log_rule('moodleoverflow', 'add post',
141-
'discussion.php?d={moodleoverflow_discussion}&parent={moodleoverflow_post}', '{moodleoverflow_post}');
142-
$rules[] = new restore_log_rule('moodleoverflow', 'update post',
143-
'discussion.php?d={moodleoverflow_discussion}&parent={moodleoverflow_post}', '{moodleoverflow_post}');
144-
$rules[] = new restore_log_rule('moodleoverflow', 'prune post',
145-
'discussion.php?d={moodleoverflow_discussion}', '{moodleoverflow_post}');
146-
$rules[] = new restore_log_rule('moodleoverflow', 'delete post',
147-
'discussion.php?d={moodleoverflow_discussion}', '[post]');
110+
$rules[] = new restore_log_rule(
111+
'moodleoverflow',
112+
'add',
113+
'view.php?id={course_module}',
114+
'{moodleoverflow}'
115+
);
116+
$rules[] = new restore_log_rule(
117+
'moodleoverflow',
118+
'update',
119+
'view.php?id={course_module}',
120+
'{moodleoverflow}'
121+
);
122+
$rules[] = new restore_log_rule(
123+
'moodleoverflow',
124+
'view',
125+
'view.php?id={course_module}',
126+
'{moodleoverflow}'
127+
);
128+
$rules[] = new restore_log_rule(
129+
'moodleoverflow',
130+
'view moodleoverflow',
131+
'view.php?id={course_module}',
132+
'{moodleoverflow}'
133+
);
134+
$rules[] = new restore_log_rule(
135+
'moodleoverflow',
136+
'mark read',
137+
'view.php?f={moodleoverflow}',
138+
'{moodleoverflow}'
139+
);
140+
$rules[] = new restore_log_rule(
141+
'moodleoverflow',
142+
'start tracking',
143+
'view.php?f={moodleoverflow}',
144+
'{moodleoverflow}'
145+
);
146+
$rules[] = new restore_log_rule(
147+
'moodleoverflow',
148+
'stop tracking',
149+
'view.php?f={moodloeoverflow}',
150+
'{moodleoverflow}'
151+
);
152+
$rules[] = new restore_log_rule(
153+
'moodleoverflow',
154+
'subscribe',
155+
'view.php?f={moodleoverflow}',
156+
'{moodleoverflow}'
157+
);
158+
$rules[] = new restore_log_rule(
159+
'moodleoverflow',
160+
'unsubscribe',
161+
'view.php?f={moodleoverflow}',
162+
'{moodleoverflow}'
163+
);
164+
$rules[] = new restore_log_rule(
165+
'moodleoverflow',
166+
'subscriber',
167+
'subscribers.php?id={moodleoverflow}',
168+
'{moodleoverflow}'
169+
);
170+
$rules[] = new restore_log_rule(
171+
'moodleoverflow',
172+
'subscribers',
173+
'subscribers.php?id={moodleoverflow}',
174+
'{moodleoverflow}'
175+
);
176+
$rules[] = new restore_log_rule(
177+
'moodleoverflow',
178+
'view subscribers',
179+
'subscribers.php?id={moodleoverflow}',
180+
'{moodleoverflow}'
181+
);
182+
$rules[] = new restore_log_rule(
183+
'moodleoverflow',
184+
'add discussion',
185+
'discussion.php?d={moodleoverflow_discussion}',
186+
'{moodleoverflow_discussion}'
187+
);
188+
$rules[] = new restore_log_rule(
189+
'moodleoverflow',
190+
'view discussion',
191+
'discussion.php?d={moodleoverflow_discussion}',
192+
'{moodleoverflow_discussion}'
193+
);
194+
$rules[] = new restore_log_rule(
195+
'moodleoverflow',
196+
'move discussion',
197+
'discussion.php?d={moodleoverflow_discussion}',
198+
'{moodleoverflow_discussion}'
199+
);
200+
$rules[] = new restore_log_rule(
201+
'moodleoverflow',
202+
'delete discussi',
203+
'view.php?id={course_module}',
204+
'{moodleoverflow}',
205+
null,
206+
'delete discussion'
207+
);
208+
$rules[] = new restore_log_rule(
209+
'moodleoverflow',
210+
'delete discussion',
211+
'view.php?id={course_module}',
212+
'{moodleoverflow}'
213+
);
214+
$rules[] = new restore_log_rule(
215+
'moodleoverflow',
216+
'add post',
217+
'discussion.php?d={moodleoverflow_discussion}&parent={moodleoverflow_post}',
218+
'{moodleoverflow_post}'
219+
);
220+
$rules[] = new restore_log_rule(
221+
'moodleoverflow',
222+
'update post',
223+
'discussion.php?d={moodleoverflow_discussion}&parent={moodleoverflow_post}',
224+
'{moodleoverflow_post}'
225+
);
226+
$rules[] = new restore_log_rule(
227+
'moodleoverflow',
228+
'prune post',
229+
'discussion.php?d={moodleoverflow_discussion}',
230+
'{moodleoverflow_post}'
231+
);
232+
$rules[] = new restore_log_rule(
233+
'moodleoverflow',
234+
'delete post',
235+
'discussion.php?d={moodleoverflow_discussion}',
236+
'[post]'
237+
);
148238

149239
return $rules;
150240
}

backup/moodle2/restore_moodleoverflow_stepslib.php

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3333
*/
3434
class restore_moodleoverflow_activity_structure_step extends restore_activity_structure_step {
35-
3635
/**
3736
* Defines structure of path elements to be processed during the restore.
3837
*
@@ -45,20 +44,34 @@ protected function define_structure() {
4544

4645
$paths[] = new restore_path_element('moodleoverflow', '/activity/moodleoverflow');
4746
if ($userinfo) {
48-
$paths[] = new restore_path_element('moodleoverflow_discussion',
49-
'/activity/moodleoverflow/discussions/discussion');
50-
$paths[] = new restore_path_element('moodleoverflow_post',
51-
'/activity/moodleoverflow/discussions/discussion/posts/post');
52-
$paths[] = new restore_path_element('moodleoverflow_discuss_sub',
53-
'/activity/moodleoverflow/discussions/discussion/discuss_subs/discuss_sub');
54-
$paths[] = new restore_path_element('moodleoverflow_rating',
55-
'/activity/moodleoverflow/discussions/discussion/posts/post/ratings/rating');
56-
$paths[] = new restore_path_element('moodleoverflow_subscription',
57-
'/activity/moodleoverflow/subscriptions/subscription');
58-
$paths[] = new restore_path_element('moodleoverflow_read',
59-
'/activity/moodleoverflow/readposts/read');
60-
$paths[] = new restore_path_element('moodleoverflow_track',
61-
'/activity/moodleoverflow/tracking/track');
47+
$paths[] = new restore_path_element(
48+
'moodleoverflow_discussion',
49+
'/activity/moodleoverflow/discussions/discussion'
50+
);
51+
$paths[] = new restore_path_element(
52+
'moodleoverflow_post',
53+
'/activity/moodleoverflow/discussions/discussion/posts/post'
54+
);
55+
$paths[] = new restore_path_element(
56+
'moodleoverflow_discuss_sub',
57+
'/activity/moodleoverflow/discussions/discussion/discuss_subs/discuss_sub'
58+
);
59+
$paths[] = new restore_path_element(
60+
'moodleoverflow_rating',
61+
'/activity/moodleoverflow/discussions/discussion/posts/post/ratings/rating'
62+
);
63+
$paths[] = new restore_path_element(
64+
'moodleoverflow_subscription',
65+
'/activity/moodleoverflow/subscriptions/subscription'
66+
);
67+
$paths[] = new restore_path_element(
68+
'moodleoverflow_read',
69+
'/activity/moodleoverflow/readposts/read'
70+
);
71+
$paths[] = new restore_path_element(
72+
'moodleoverflow_track',
73+
'/activity/moodleoverflow/tracking/track'
74+
);
6275
}
6376

6477
// Return the paths wrapped into standard activity structure.
@@ -178,7 +191,6 @@ protected function process_moodleoverflow_subscription($data) {
178191

179192
$newitemid = $DB->insert_record('moodleoverflow_subscriptions', $data);
180193
$this->set_mapping('moodleoverflow_subscription', $oldid, $newitemid, true);
181-
182194
}
183195

184196
/**

classes/anonymous.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3333
*/
3434
class anonymous {
35-
3635
/**
3736
* Used if nothing is anonymous.
3837
*/
@@ -86,8 +85,11 @@ public static function get_userid_mapping($moodleoverflow, $discussionid) {
8685
}
8786
if ($moodleoverflow->anonymous == self::QUESTION_ANONYMOUS) {
8887
return [
89-
$DB->get_field('moodleoverflow_posts', 'userid',
90-
['parent' => 0, 'discussion' => $discussionid]) => get_string('questioner', 'mod_moodleoverflow'),
88+
$DB->get_field(
89+
'moodleoverflow_posts',
90+
'userid',
91+
['parent' => 0, 'discussion' => $discussionid]
92+
) => get_string('questioner', 'mod_moodleoverflow'),
9193
];
9294
}
9395

@@ -96,7 +98,9 @@ public static function get_userid_mapping($moodleoverflow, $discussionid) {
9698
'FROM {moodleoverflow_posts} ' .
9799
'WHERE discussion = :discussion ' .
98100
'GROUP BY userid ' .
99-
'ORDER BY MIN(created) ASC;', ['discussion' => $discussionid]);
101+
'ORDER BY MIN(created) ASC;',
102+
['discussion' => $discussionid]
103+
);
100104

101105
$mapping = [];
102106
$questioner = array_shift($userids);
@@ -108,5 +112,4 @@ public static function get_userid_mapping($moodleoverflow, $discussionid) {
108112
}
109113
return $mapping;
110114
}
111-
112115
}

classes/capabilities.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3535
*/
3636
class capabilities {
37-
3837
/** capability add instance */
3938
const ADD_INSTANCE = 'mod/moodleoverflow:addinstance';
4039

@@ -100,5 +99,4 @@ public static function has(string $capability, context $context, $userid = null)
10099

101100
return self::$cache[$key];
102101
}
103-
104102
}

0 commit comments

Comments
 (0)