Skip to content
This repository was archived by the owner on Oct 29, 2020. It is now read-only.
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,16 @@ function _dosomething_reportback_get_permalink_copy_vars($user) {
}


function dosomething_reportback_form_views_exposed_form_alter(&$form, &$form_state, $form_id) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forgot docblock 😉

// Make sure a default run is added to the filter
if (empty($_GET['run_nid'])) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation looks wrong.

$run = dosomething_helpers_get_current_campaign_run_for_user(arg(1));
if (isset($run)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe !empty() will be better?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I only want this to run when the filter is empty. If I did !empty( it would run even when a user specifies a filter

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is setting the value for this filter

screen shot 2016-02-19 at 3 26 59 pm

However that should only happen when the filter is empty. If a value already exists in the filter, I don't want to replace it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but I'm talking about asserting $run variable's existence.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (!empty($run)) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OHHHHHHHHHH

the if right above is empty and i thought thats what you were referring too.

The function im getting the run from returns NULL if it cant find it, so I dont think empty would work

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But !empty(NULL) is FALSE, as expected.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And to be clear, dosomething_helpers_get_current_campaign_run_for_user() may return not just null, but FALSE and stdClass, see return node_load($run['id']);.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and FYI

php > $false = FALSE;
php > var_dump(isset($false));
bool(true)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!empty($run)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my replies here: #6194 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

github why you hide all the important comments

$form_state['input']['run_nid'] = $run->nid;
}
}
}

/**
* Implements hook_form_alter().
*
Expand Down