Skip to content
This repository was archived by the owner on Oct 29, 2020. It is now read-only.

Commit 2cc46e8

Browse files
committed
Merge pull request #5461 from DoSomething/dev
dev into global
2 parents 813694b + c7322a2 commit 2cc46e8

File tree

8 files changed

+96
-48
lines changed

8 files changed

+96
-48
lines changed

lib/modules/dosomething/dosomething_campaign_group/dosomething_campaign_group.info

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package = DoSomething
55
version = 7.x-1.0
66
dependencies[] = ctools
77
dependencies[] = dosomething_campaign
8+
dependencies[] = dosomething_helpers
89
dependencies[] = dosomething_static_content
910
dependencies[] = dosomething_taxonomy
1011
dependencies[] = entityreference

lib/modules/dosomething/dosomething_campaign_group/dosomething_campaign_group.module

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ function dosomething_campaign_group_get_child_data($node) {
157157
'nids' => array(),
158158
);
159159
if (!empty($node->field_campaigns)) {
160-
foreach ($node->field_campaigns[LANGUAGE_NONE] as $delta => $value) {
160+
$clc = dosomething_helpers_get_current_language_code();
161+
foreach ($node->field_campaigns[$clc] as $delta => $value) {
161162
// Add the child nid to nid's array.
162163
$data['nids'][] = $value['entity']->nid;
163164
// If the node is published:

lib/modules/dosomething/dosomething_global/dosomething_global.module

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ function _dosomething_global_get_regional_roles() {
219219
}
220220

221221
/**
222-
* Returns the user's langauge based on the role.
222+
* Returns the user's language based on the role.
223223
*
224224
* @param Object $user
225225
* Optional - A specified user to check
@@ -270,6 +270,19 @@ function dosomething_global_get_user_language($user = NULL) {
270270
return $countries;
271271
}
272272

273+
/**
274+
* Returns the session's country code, or `global` if it's not
275+
* one of our whitelisted global countries.
276+
*/
277+
function dosomething_global_get_country() {
278+
$country_code = dosomething_settings_get_geo_country_code();
279+
if (in_array($country_code, dosomething_global_get_countries())) {
280+
return $country_code;
281+
}
282+
283+
return 'global';
284+
}
285+
273286
/**
274287
* Gets the country from a given language.
275288
*

lib/modules/dosomething/dosomething_helpers/dosomething_helpers.module

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -598,9 +598,18 @@ function dosomething_helpers_application_path($path = '') {
598598
*/
599599
function dosomething_helpers_form_node_admin_content_alter(&$form, &$form_state, $form_id) {
600600
// Remove destination?=admin/content from edit button
601-
foreach ($form['admin']['nodes']['#rows'] as $nid => $node) {
602-
if (!empty($form['admin']['nodes']['#rows'][$nid]['operations'])) {
603-
unset($form['admin']['nodes']['#rows'][$nid]['operations']['data']['#options']['query']['destination']);
601+
if (dosomething_user_is_staff()) {
602+
foreach ($form['admin']['nodes']['#options'] as $nid => $node) {
603+
if (!empty($form['admin']['nodes']['#options'][$nid]['operations'])) {
604+
unset($form['admin']['nodes']['#options'][$nid]['operations']['data']['#links']['edit']['query']['destination']);
605+
}
606+
}
607+
}
608+
else if (dosomething_global_is_regional_admin()) {
609+
foreach ($form['admin']['nodes']['#rows'] as $nid => $node) {
610+
if (!empty($form['admin']['nodes']['#rows'][$nid]['operations'])) {
611+
unset($form['admin']['nodes']['#rows'][$nid]['operations']['data']['#options']['query']['destination']);
612+
}
604613
}
605614
}
606615
}

lib/modules/dosomething/dosomething_user/dosomething_user.module

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ function dosomething_user_form_alter(&$form, $form_state, $form_id) {
289289
}
290290

291291
$form['#after_build'][] = 'dosomething_user_remove_extra_values_from_address_field';
292-
if ($is_validate_address_set) {
292+
if ($validate_address) {
293293
$form['#after_build'][] = 'dosomething_user_add_validation_attributes_to_address_fields';
294294
}
295295

lib/themes/dosomething/paraneue_dosomething/includes/preprocess.inc

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,15 +181,29 @@ function paraneue_dosomething_preprocess_page(&$vars) {
181181
* Global Page Footer
182182
*/
183183

184+
$country = dosomething_global_get_country();
184185
$columns = array('first', 'second', 'third');
185186
$footer_links = array();
186187

187188
foreach($columns as $column) {
188-
$prefix = "footer_links_" . $column . "_column_";
189+
$prefix = "footer_links_" . $country . '_' . $column . "_column_";
189190
$footer_links[$column] = array();
190-
$footer_links[$column]['heading'] = theme_get_setting($prefix . "heading");
191191

192-
$links = explode("\n", trim(theme_get_setting($prefix . "links")));
192+
// Get new country code setting if it exists, if not fallback to old setting.
193+
// @TODO: Remove this after we've updated theme settings everywhere.
194+
$heading_setting = theme_get_setting($prefix . 'heading');
195+
if(!$heading_setting === NULL) {
196+
$heading_setting = theme_get_setting('footer_links_' . $column . '_column_heading');
197+
}
198+
$footer_links[$column]['heading'] = $heading_setting;
199+
200+
// Get new country code setting if it exists, if not fallback to old setting.
201+
// @TODO: Remove this after we've updated theme settings everywhere.
202+
$links_setting = theme_get_setting($prefix . 'links');
203+
if(!$links_setting === NULL) {
204+
$links_setting = theme_get_setting('footer_links_' . $column . '_column_links');
205+
}
206+
$links = explode("\n", trim($links_setting));
193207
$links = array_filter($links); // Remove empty items
194208

195209
foreach($links as &$link) {

lib/themes/dosomething/paraneue_dosomething/paraneue_dosomething.info

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,10 @@ settings[footer_links_first_column_heading] = 'Help'
4747
settings[footer_links_first_column_links] = 'Contact Us|node/516
4848
Hotlines|node/518
4949
FAQs|node/1052'
50-
settings[footer_links_first_column_class] = 'help'
5150
settings[footer_links_second_column_heading] = 'Get to Know Us'
5251
settings[footer_links_second_column_links] = 'Partners|node/532
5352
Donate|node/539
5453
TMI Agency|http://www.tmiagency.org'
55-
settings[footer_links_second_column_class] = 'knowus'
5654
settings[footer_links_third_column_heading] = 'About'
5755
settings[footer_links_third_column_links] = 'What is DoSomething.org?|node/538
5856
Our Team|node/1044
@@ -61,7 +59,6 @@ Internships|node/940
6159
Old People|node/329
6260
Sexy Financials|node/540
6361
International|node/523'
64-
settings[footer_links_third_column_class] = 'about'
6562

6663
; User
6764
settings[user_validate_js_postcode] = 1

lib/themes/dosomething/paraneue_dosomething/theme-settings.php

Lines changed: 49 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -272,46 +272,59 @@ function _paraneue_dosomething_theme_settings_footer(&$form, $form_state) {
272272
);
273273

274274
$links = &$form['footer']['links'];
275-
$columns = array('first', 'second', 'third');
276-
foreach ($columns as $column) {
277-
$prefix = 'footer_links_' . $column;
278275

279-
$links[$prefix] = array(
276+
// Set up theme settings for each country's footer
277+
$countries = dosomething_global_get_countries();
278+
foreach($countries as $country) {
279+
$links[$country. '_links'] = [
280280
'#type' => 'fieldset',
281-
'#title' => t(ucwords($column) .' column'),
281+
'#title' => t('@country Links', ['@country' => $country]),
282282
'#collapsible' => TRUE,
283-
'#collapsed' => TRUE
284-
);
285-
286-
$link_column = &$links[$prefix];
287-
288-
$link_column[$prefix . '_column_heading'] = array(
289-
'#type' => 'textfield',
290-
'#title' => t(ucwords($column) . ' Column Heading'),
291-
'#default_value' => theme_get_setting('footer_links_' . $column . '_column_heading')
292-
);
293-
294-
$link_column[$prefix . '_column_links'] = array(
295-
'#type' => 'textarea',
296-
'#title' => t(ucwords($column) . ' Column Links'),
297-
'#default_value' => theme_get_setting('footer_links_' . $column . '_column_links')
298-
);
299-
300-
$link_column[$prefix. '_advanced'] = array(
301-
'#type' => 'fieldset',
302-
'#title' => t('Advanced options'),
303-
'#collapsible' => TRUE,
304-
'#collapsed' => TRUE
305-
);
306-
307-
$link_column[$prefix . '_advanced'][$prefix . '_column_class'] = array(
308-
'#type' => 'textfield',
309-
'#title' => t(ucwords($column) . ' Column Class'),
310-
'#default_value' => theme_get_setting('footer_links_' . $column . '_column_class')
311-
);
283+
'#collapsed' => TRUE,
284+
];
285+
286+
// Set up theme settings for each of the three columns
287+
$columns = ['first', 'second', 'third'];
288+
foreach ($columns as $column) {
289+
$prefix = 'footer_links_' . $country . '_' . $column;
290+
291+
$links[$country. '_links'][$prefix] = [
292+
'#type' => 'fieldset',
293+
'#title' => t(ucwords($column) .' column'),
294+
'#collapsible' => TRUE,
295+
'#collapsed' => TRUE,
296+
];
297+
298+
$link_column = &$links[$country. '_links'][$prefix];
299+
300+
// Get new country code setting if it exists, if not fallback to old setting.
301+
// @TODO: Remove this after we've updated theme settings everywhere.
302+
$heading_default = theme_get_setting('footer_links_' . $country . '_' . $column . '_column_heading');
303+
if(!$heading_default === NULL) {
304+
$heading_default = theme_get_setting('footer_links_' . $column . '_column_heading');
305+
}
306+
307+
$link_column[$prefix . '_column_heading'] = [
308+
'#type' => 'textfield',
309+
'#title' => t(ucwords($country) . ' ' . ucwords($column) . ' Column Heading'),
310+
'#default_value' => $heading_default,
311+
];
312+
313+
// Get new country code setting if it exists, if not fallback to old setting.
314+
// @TODO: Remove this after we've updated theme settings everywhere.
315+
$links_default = theme_get_setting('footer_links_' . $country . '_' . $column . '_column_links');
316+
if(!$links_default === NULL) {
317+
$links_default = theme_get_setting('footer_links_' . $column . '_column_links');
318+
}
319+
320+
$link_column[$prefix . '_column_links'] = [
321+
'#type' => 'textarea',
322+
'#title' => t(ucwords($country) . ' ' . ucwords($column) . ' Column Links'),
323+
'#default_value' => $links_default,
324+
];
325+
}
312326

313327
}
314-
315328
}
316329

317330
function _paraneue_dosomething_theme_settings_user(&$form, $form_state) {
@@ -321,7 +334,7 @@ function _paraneue_dosomething_theme_settings_user(&$form, $form_state) {
321334
);
322335
$form_user = &$form['user'];
323336

324-
// Validaions.
337+
// Validations.
325338
$form_user['validations'] = array(
326339
'#type' => 'fieldset',
327340
'#title' => t('JS Validations'),

0 commit comments

Comments
 (0)