Skip to content

Commit

Permalink
Merge pull request #3055 from ec-europa/release-2.6.19
Browse files Browse the repository at this point in the history
Release 2.6.19
  • Loading branch information
jonhy81 authored Mar 31, 2022
2 parents 7664381 + fb6f4e2 commit 5a3b181
Show file tree
Hide file tree
Showing 6 changed files with 175 additions and 117 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Ignore metadata from common editors and IDEs.
*.sublime-project
*.sublime-workspace
*.code-workspace
.idea/
nbproject/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ function tmgmt_dgt_connector_form_cart_bundle_items($form, &$form_state) {

$form['cart_items_fields'] = array(
'#type' => 'value',
'#value' => $cart_items,
);

$form['submit_changes'] = array(
Expand Down Expand Up @@ -221,7 +222,7 @@ function _tmgmt_dgt_connector_cart_update_cart_items(array &$form_state) {
// Iterating through the CartItem entities and setting their properties.
foreach ($cart_items as $id => $cart_item) {
foreach ($fields[$id] as $field => $value) {
$cart_item->{$field} = check_plain($value);
$cart_item->{$field} = !is_array($value) ? check_plain($value) : $value;
}
$cart_item->save();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,38 +412,45 @@ function _nexteuropa_communities_node_alias_check($node, $mode) {
* Implements hook_url_outbound_alter().
*/
function nexteuropa_communities_url_outbound_alter(&$path, &$options, $original_path) {
$context = og_context();
if ($context && strpos($original_path, 'node/') !== FALSE) {
$keyword = variable_get('nexteuropa_communities_url_keyword', 'community');
// Load pathauto in order to use the cleanstring method.
module_load_include('inc', 'pathauto', 'pathauto');

// Manage the group.
$group = node_load($context['gid']);
$group_name = pathauto_cleanstring($group->title);

// Get the node aliases.
$select = db_select('url_alias');
$select->condition('source', $original_path);
$select->condition('language', LANGUAGE_NONE);
$select->fields('url_alias', ['alias']);
$paths = $select->execute()->fetchAll();

// Loop through the found paths in order to find the correct alias.
foreach ($paths as $p) {
// Check that the URL begins with the desired community pattern.
$search = strpos($p->alias, $keyword . '/' . $group_name);
if ($search !== FALSE && $search === 0) {
$new_path = $p->alias;
break;
try {
$context = og_context();
if (isset($context['gid'])) {
if (strpos($original_path, 'node/') !== FALSE) {
$keyword = variable_get('nexteuropa_communities_url_keyword', 'community');
// Load pathauto in order to use the cleanstring method.
module_load_include('inc', 'pathauto', 'pathauto');

// Manage the group.
$group = node_load($context['gid']);
$group_name = pathauto_cleanstring($group->title);

// Get the node aliases.
$select = db_select('url_alias');
$select->condition('source', $original_path);
$select->condition('language', LANGUAGE_NONE);
$select->fields('url_alias', ['alias']);
$paths = $select->execute()->fetchAll();

// Loop through the found paths in order to find the correct alias.
foreach ($paths as $p) {
// Check that the URL begins with the desired community pattern.
$search = strpos($p->alias, $keyword . '/' . $group_name);
if ($search !== FALSE && $search === 0) {
$new_path = $p->alias;
break;
}
}
}
}
}

// Set the new path if existing.
if (isset($new_path)) {
$path = $new_path;
$options['alias'] = $path;
// Set the new path if existing.
if (isset($new_path)) {
$path = $new_path;
$options['alias'] = $path;
}
}
catch (Throwable $e) {
drupal_set_message(t('Nexteuropa Communities - OG Context not found.'), 'warning');
}
}

Expand Down
Loading

0 comments on commit 5a3b181

Please sign in to comment.