Commit 5ca1e313 authored by andrei.dincu's avatar andrei.dincu
Browse files

Issue #2249723 by andrei.dincu: Add row in xmlsitemap table when new user is created

parent 1e549c4a
......@@ -616,7 +616,6 @@ function xmlsitemap_link_save(array $link) {
// Save the link and allow other modules to respond to the link being saved.
if ($existing) {
print "ana are mere" . PHP_EOL;
drupal_write_record('xmlsitemap', $link, array('type', 'id'));
\Drupal::moduleHandler()->invokeAll('xmlsitemap_link_update', $link);
}
......@@ -1617,9 +1616,8 @@ function xmlsitemap_user_xmlsitemap_process_user_links(array $uids) {
}
$accounts = User::loadMultiple($uids);
foreach ($accounts as $account) {
print var_dump($account->id);
//$link = xmlsitemap_user_create_link($account);
//xmlsitemap_link_save($link);
$link = xmlsitemap_user_create_link($account);
xmlsitemap_link_save($link);
}
}
......@@ -1630,8 +1628,8 @@ function xmlsitemap_user_presave(UserInterface $account) {
if (!\Drupal::state()->get('xmlsitemap_entity_user')) {
return ;
}
if (!empty($account->uid)) {
drupal_set_message('bogdan are mere');
$uid = $account->id();
if (!empty($uid)) {
$link = xmlsitemap_user_create_link($account);
if (isset($edit['xmlsitemap'])) {
$link = $edit['xmlsitemap'] + $link;
......@@ -1693,16 +1691,16 @@ function xmlsitemap_field_extra_fields() {
function xmlsitemap_user_create_link(UserInterface &$account) {
if (!isset($account->xmlsitemap)) {
$account->xmlsitemap = array();
if ($account->uid && $link = xmlsitemap_link_load('user', $account->uid)) {
if ($account->id() && $link = xmlsitemap_link_load('user', $account->id())) {
$account->xmlsitemap = $link;
}
}
$settings = xmlsitemap_link_bundle_load('user', 'user');
$uri = $account->uri;
$uri = $account->url();
$account->xmlsitemap += array(
'type' => 'user',
'id' => $account->uid,
'id' => $account->id(),
'subtype' => 'user',
'status' => $settings['status'],
'status_default' => $settings['status'],
......@@ -1714,8 +1712,15 @@ function xmlsitemap_user_create_link(UserInterface &$account) {
// The following values must always be checked because they are volatile.
$account->xmlsitemap['loc'] = $uri['path'];
$account->xmlsitemap['access'] = $account->uid && $account->status;
$account->xmlsitemap['language'] = !empty($account->language) ? $account->language : LANGUAGE_NONE;
if ($account->isActive()) {
$status = 1;
}
else {
$status = 0;
}
$account->xmlsitemap['access'] = $account->url() && $status;
$language = $account->language();
$account->xmlsitemap['language'] = !empty($language) ? $language->getId() : LanguageInterface::LANGCODE_NOT_SPECIFIED;
return $account->xmlsitemap;
}
......
......@@ -15,7 +15,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
function xmlsitemap_get_current_chunk(XmlSitemapInterface $sitemap) {
// Check if we should be displaing the index.
$query = \Drupal::request()->query;
if (!isset($query->get('page')) || !is_numeric($query->get('page'))) {
$query_page = $query->get('page');
if (!isset($query_page) || !is_numeric($query_page)) {
if ($sitemap->getChunks() > 1) {
return 'index';
}
......@@ -24,7 +25,7 @@ function xmlsitemap_get_current_chunk(XmlSitemapInterface $sitemap) {
}
}
else {
return (int) $query->get('page');
return (int) $query_page;
}
}
......@@ -46,8 +47,8 @@ function xmlsitemap_output_chunk() {
$file = xmlsitemap_sitemap_get_file($sitemap, $chunk);
// Provide debugging information if enabled.
$query = \Drupal::request()->query;
if (\Drupal::state()->get('developer_mode', 0) && isset($query->get('debug'))) {
$query_debug = \Drupal::request()->query->get('debug');
if (\Drupal::state()->get('developer_mode', 0) && isset($query_debug)) {
$output = array();
$context = xmlsitemap_get_current_context();
$output[] = "Current context: " . print_r($context, TRUE);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment