/** * Creates user informations based on default values. * * @param int|int[] $user_ids * @param array $override_values values used to override default user values */ function create_user_infos($user_ids, $override_values = null) { global $conf; if (!is_array($user_ids)) { $user_ids = array($user_ids); } if (!empty($user_ids)) { $inserts = array(); list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();')); $default_user = get_default_user_info(false); if ($default_user === false) { // Default on structure are used $default_user = array(); } if (!is_null($override_values)) { $default_user = array_merge($default_user, $override_values); } foreach ($user_ids as $user_id) { $level = isset($default_user['level']) ? $default_user['level'] : 0; if ($user_id == $conf['webmaster_id']) { $status = 'webmaster'; $level = max($conf['available_permission_levels']); } elseif ($user_id == $conf['guest_id'] or $user_id == $conf['default_user_id']) { $status = 'guest'; } else { $status = 'normal'; } $insert = array_merge($default_user, array('user_id' => $user_id, 'status' => $status, 'registration_date' => $dbnow, 'level' => $level)); $inserts[] = $insert; } mass_inserts(USER_INFOS_TABLE, array_keys($inserts[0]), $inserts); } }
u.' . $conf['user_fields']['username'] . ' AS username, u.' . $conf['user_fields']['email'] . ' AS email, ui.status, ui.enabled_high, ui.level FROM ' . USERS_TABLE . ' AS u INNER JOIN ' . USER_INFOS_TABLE . ' AS ui ON u.' . $conf['user_fields']['id'] . ' = ui.user_id WHERE u.' . $conf['user_fields']['id'] . ' > 0 ;'; $result = pwg_query($query); while ($row = pwg_db_fetch_assoc($result)) { $users[] = $row; $user_ids[] = $row['id']; } $template->assign(array('users' => $users, 'all_users' => join(',', $user_ids), 'ACTIVATE_COMMENTS' => $conf['activate_comments'], 'Double_Password' => $conf['double_password_type_in_admin'])); $default_user = get_default_user_info(true); $protected_users = array($user['id'], $conf['guest_id'], $conf['default_user_id'], $conf['webmaster_id']); // an admin can't delete other admin/webmaster if ('admin' == $user['status']) { $query = ' SELECT user_id FROM ' . USER_INFOS_TABLE . ' WHERE status IN (\'webmaster\', \'admin\') ;'; $protected_users = array_merge($protected_users, query2array($query, null, 'user_id')); } $template->assign(array('PWG_TOKEN' => get_pwg_token(), 'NB_IMAGE_PAGE' => $default_user['nb_image_page'], 'RECENT_PERIOD' => $default_user['recent_period'], 'theme_options' => get_pwg_themes(), 'theme_selected' => get_default_theme(), 'language_options' => get_languages(), 'language_selected' => get_default_language(), 'association_options' => $groups, 'protected_users' => implode(',', array_unique($protected_users)), 'guest_user' => $conf['guest_id'])); // Status options foreach (get_enums(USER_INFOS_TABLE, 'status') as $status) { $label_of_status[$status] = l10n('user_status_' . $status);