Skip to content

Commit 184b866

Browse files
committed
Fix handling of newly registered users
Signed-off-by: Matt Friedman <maf675@gmail.com>
1 parent 5890fb2 commit 184b866

2 files changed

Lines changed: 20 additions & 21 deletions

File tree

includes/qi_populate.php

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public function run()
170170
$this->email_domain = strtolower($this->email_domain);
171171

172172
// Populate the users array with some initial data.
173-
// I'm sure there where a reason to split this up to two functions.
173+
// I'm sure there was a reason to split this up to two functions.
174174
// Need to have a closer look at that later. The second one might need to move.
175175
$this->pop_user_arr();
176176
}
@@ -304,14 +304,25 @@ private function fill_forums()
304304
// Use the default user if no new users are being populated
305305
if (!$this->num_users && empty($this->user_arr))
306306
{
307-
$this->user_arr = $this->get_user(1);
307+
$this->user_arr = $users = $this->get_user(1);
308+
}
309+
// If there are going to be newly registered users, we need to not use them when filling forums
310+
else if ($this->num_new_group && $this->num_new_group < $this->num_users)
311+
{
312+
$users = array_slice($this->user_arr, 0, -$this->num_new_group, true);
313+
}
314+
else
315+
{
316+
$users = $this->user_arr;
308317
}
309318

310319
// Get the min and max for mt_rand.
311-
end($this->user_arr);
312-
$mt_max = (int) key($this->user_arr);
313-
reset($this->user_arr);
314-
$mt_min = (int) key($this->user_arr);
320+
end($users);
321+
$mt_max = (int) key($users);
322+
reset($users);
323+
$mt_min = (int) key($users);
324+
325+
unset($users);
315326

316327
// Flags for BBCodes.
317328
$flags = 7;
@@ -756,7 +767,7 @@ private function save_users()
756767
unset($sql_ary);
757768

758769
// Put them in groups.
759-
$chunk_cnt = $newly_registered = $skip = 0;
770+
$chunk_cnt = $skip = 0;
760771

761772
// Don't add the first users to the newly registered group if a moderator and/or an admin is needed.
762773
$skip = ($this->create_mod) ? $skip + 1 : $skip;
@@ -767,23 +778,11 @@ private function save_users()
767778
{
768779
$sql_ary[] = array(
769780
'user_id' => (int) $user['user_id'],
770-
'group_id' => (int) $registered_group,
781+
'group_id' => $this->num_new_group && $user['user_posts'] < 1 && $skip < 1 ? $newly_registered_group : $registered_group,
771782
'group_leader' => 0, // No group leaders.
772783
'user_pending' => 0, // User is not pending.
773784
);
774785

775-
if ($newly_registered < $this->num_new_group && $skip < 1)
776-
{
777-
$sql_ary[] = array(
778-
'user_id' => (int) $user['user_id'],
779-
'group_id' => (int) $newly_registered_group,
780-
'group_leader' => 0, // No group leaders.
781-
'user_pending' => 0, // User is not pending.
782-
);
783-
784-
$newly_registered++;
785-
}
786-
787786
$skip--;
788787

789788
if ($s_chunks && $chunk_cnt >= $this->user_chunks)

language/en/qi.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@
205205
'NUM_FORUMS' => 'Number of forums',
206206
'NUM_FORUMS_EXPLAIN' => 'The number of forums to create, they will be spread evenly over the created categories.',
207207
'NUM_NEW_GROUP' => 'Newly registered users',
208-
'NUM_NEW_GROUP_EXPLAIN' => 'The number of users to place in the newly registered group. If this number is larger than the number of users, all new users will be placed in the newly registered group.',
208+
'NUM_NEW_GROUP_EXPLAIN' => 'The number of users to place in the newly registered group. If this number is larger than the number of users, it will be ignored.',
209209
'NUM_REPLIES' => 'Number of replies',
210210
'NUM_REPLIES_EXPLAIN' => 'The number of replies. Each topic will receive a random number of replies between these min and max values.',
211211
'NUM_TOPICS' => 'Number of topics',

0 commit comments

Comments
 (0)