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

Commit 8a8eb9e

Browse files
author
Shae Smith
committed
commenting code
1 parent 131ad27 commit 8a8eb9e

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

lib/modules/dosomething/dosomething_campaign/dosomething_campaign.module

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,19 +1269,21 @@ function dosomething_campaign_node_update($node) {
12691269
*/
12701270
function dosomething_campaign_node_validate($node, $form, &$form_state) {
12711271
if ($node->type == 'campaign') {
1272+
// Get the language of the translation being submitted.
12721273
$language = $form_state['entity_translation']['form_langcode'];
1273-
$values = $form_state['values'];
12741274

1275+
// Get the current run set in the db and the one the user submitted.
1276+
// so we can see if it has changed.
12751277
$current_run_id = $form['#node']->field_current_run[$language][0]['target_id'];
1276-
$submitted_current_run = $values['field_current_run'][$language][0]['target_id'];
1278+
$submitted_current_run = $form_state['values']['field_current_run'][$language][0]['target_id'];
12771279

12781280
if ($current_run_id !== $submitted_current_run) {
1281+
// Get the dates of the run.
12791282
$new_run = entity_metadata_wrapper('node', $submitted_current_run);
1280-
// @TODO -- Extract into function.
12811283
$start_date = new DateTime($new_run->language($language)->field_run_date->value()['value']);
12821284
$end_date = new DateTime($new_run->language($language)->field_run_date->value()['value2']);
1285+
// Update the campaign status.
12831286
$status = dosomething_helpers_get_campaign_status($start_date, $end_date);
1284-
// -- end function.
12851287
$form_state['values']['field_campaign_status'][$language][0]['value'] = $status;
12861288
}
12871289
}

lib/modules/dosomething/dosomething_campaign_run/dosomething_campaign_run.module

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,15 +299,16 @@ function dosomething_campaign_run_form_campaign_run_node_form_alter(&$form, &$fo
299299
*/
300300
function dosomething_campaign_run_node_submit($node, $form, &$form_state) {
301301
if ($node->type == 'campaign_run') {
302+
// Get language of the translation being submittted.
302303
$language = $form_state['entity_translation']['form_langcode'];
303-
// @TODO -- Extracted into function.
304+
// Grab the run dates the user just entered;
304305
$start_date = new DateTime($form_state['values']['field_run_date'][$language][0]['value']);
305306
$end_date = (!$form_state['values']['field_run_date'][$language][0]['value2']) ? $start_date : new DateTime($form_state['values']['field_run_date'][$language][0]['value2']);
306307
$status = dosomething_helpers_get_campaign_status($start_date, $end_date);
307-
// -- end extraction.
308308

309309
// Just get the first campaign this is tied to. While we allow for multiple campaigns to be selected per campaign run, only one should be selected.
310310
$campaign = $form_state['values']['field_campaigns'][$language][0];
311+
// Update the campaign's status.
311312
$campaign = entity_metadata_wrapper('node', $campaign['target_id']);
312313
$current_run = $campaign->language($language)->field_current_run->value();
313314
if ($current_run->nid == $form_state['values']['nid']) {

0 commit comments

Comments
 (0)