0 AND u.status <> 0"; $result = db_query_range($sql, 0, $limit); $sitemap_changed = FALSE; while ($account = db_fetch_object($result)) { $row = new stdClass(); $row->uid = $account->uid; $row->changed = !empty($account->access) ? $account->access : REQUEST_TIME; $row->previously_changed = $account->created; drupal_write_record('xmlsitemap_user', $row); $sitemap_changed = TRUE; } if ($sitemap_changed) { xmlsitemap_flag_sitemap(); } } } /** * Implementation of hook_form_FORM_ID_alter(). */ function xmlsitemap_user_form_user_admin_settings_alter(&$form, &$from_state) { if (!isset($form['xmlsitemap'])) { $form['xmlsitemap'] = array( '#type' => 'fieldset', '#title' => t('XML sitemap'), '#collapsible' => TRUE, ); } $default = variable_get('xmlsitemap_user_default_priority', 0.5); $form['xmlsitemap']['xmlsitemap_user_default_priority'] = array( '#type' => 'select', '#title' => t('Default user priority'), '#description' => t('The default priority for users who have only the authenticated user role.'), '#default_value' => $default, '#options' => xmlsitemap_priority_options('exclude'), ); $form['buttons']['#weight'] = isset($form['buttons']['#weight']) ? $form['buttons']['#weight'] + 1 : 1; $form['#submit'][] = 'xmlsitemap_user_admin_settings_submit'; } /** * Implementation of hook_form_FORM_ID_alter(). */ function xmlsitemap_user_form_user_admin_role_alter(&$form, &$from_state) { $options = xmlsitemap_priority_options('exclude'); $priority = db_result(db_query("SELECT priority FROM {xmlsitemap_user_role} WHERE rid = %d", $form['rid']['#value']) ); if ($priority === FALSE) { $priority = 0.5; } if (!isset($form['xmlsitemap'])) { $form['xmlsitemap'] = array( '#type' => 'fieldset', '#title' => t('XML sitemap'), '#collapsible' => TRUE, ); } $form['xmlsitemap']['xmlsitemap_user_role_priority'] = array( '#type' => 'select', '#title' => t('Default priority'), '#description' => t("The priority of all user roles will be added together to set the user's default priority. If all role priorities are left at default, the user's default priority will be %priority.", array('%priority' => $options[variable_get('xmlsitemap_user_default_priority', '0.5')])), '#default_value' => $priority, '#options' => $options, ); $form['submit']['#weight'] = isset($form['submit']['#weight']) ? $form['submit']['#weight'] + 1 : 1; $form['delete']['#weight'] = isset($form['delete']['#weight']) ? $form['delete']['#weight'] + 1 : 1; $form['#submit'][] = 'xmlsitemap_user_admin_role_submit'; } /** * Implementation of hook_user(). */ function xmlsitemap_user_user($op, &$edit, &$account, $category = NULL) { switch ($op) { case 'form': if ($category != 'account') { return array(); } case 'register': $priority = db_result(db_query("SELECT priority_override FROM {xmlsitemap_user} WHERE uid = %d", $account->uid) ); $options = xmlsitemap_priority_options('both'); if (isset($account->roles)) { $roles = array_keys($account->roles); $default = db_fetch_object( db_query("SELECT MIN(priority) AS min, SUM(priority) AS sum FROM {xmlsitemap_user_role} WHERE rid IN (". db_placeholders($roles, 'varchar') .")", $roles ) ); } if (isset($default->min) && isset($default->sum)) { $default_priority = $default->min < 0 ? -1.0 : round(min($default->sum, 1), 1); } else { $default_priority = variable_get('xmlsitemap_user_default_priority', 0.5); } $form = xmlsitemap_user_form_fieldset(); $form['xmlsitemap']['xmlsitemap_user_priority'] = array( '#type' => 'select', '#title' => t('User priority'), '#description' => t('The default priority is %priority.', array('%priority' => $options[(string)$default_priority])), '#default_value' => $priority !== FALSE ? $priority : -2.0, '#options' => $options, ); return $form; case 'insert': if ($account->status) { $row = new stdClass(); $row->uid = $account->uid; $row->changed = !empty($account->access) ? $account->access : REQUEST_TIME; $row->previously_changed = $account->created; $row->priority_override = isset($edit['xmlsitemap_user_priority']) ? $edit['xmlsitemap_user_priority'] : -2.0; drupal_write_record('xmlsitemap_user', $row); $edit['xmlsitemap_user_priority'] = NULL; xmlsitemap_flag_sitemap(); } break; case 'update': if ($account->status) { if (($result = db_fetch_object(db_query("SELECT uid, changed, previously_changed, priority_override FROM {xmlsitemap_user} WHERE uid = %d", $account->uid))) === FALSE) { $row = new stdClass(); $row->uid = $account->uid; $row->previously_changed = $account->created; $row->changed = !empty($account->access) ? $account->access : REQUEST_TIME; } else { $row = $result; if (!empty($account->access)) { if ($row->changed < $account->access) { $row->previously_changed = $row->changed; $row->changed = $account->access; } } else { $row->previously_changed = $row->changed; $row->changed = REQUEST_TIME; } } if (isset($edit['xmlsitemap_user_priority'])) { $row->priority_override = $edit['xmlsitemap_user_priority']; } drupal_write_record('xmlsitemap_user', $row, $result !== FALSE ? 'uid' : NULL); xmlsitemap_flag_sitemap(); } break; case 'delete': db_query("DELETE FROM {xmlsitemap_user} WHERE uid = %d", $account->uid); db_query("DELETE FROM {xmlsitemap} WHERE type = 'user' AND id = %d", $account->uid); xmlsitemap_flag_sitemap(); break; } } /** * Implementation of hook_xmlsitemap_description(). */ function xmlsitemap_user_xmlsitemap_description() { return '