Skip to content

Commit

Permalink
New publisher email search filter added
Browse files Browse the repository at this point in the history
Added new search filter that makes it possible to filter pubisher search
results according to the information if publisher has email address or
not. #39
  • Loading branch information
petkivim committed Nov 5, 2016
1 parent f97f66e commit a2b2f3d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,9 @@ COM_ISBNREGISTRY_PUBLISHER_FILTER_CONTACT_PERSON="Yhteyshenkilö"
COM_ISBNREGISTRY_PUBLISHER_FILTER_TARGET_FIELD_LABEL="Hakukenttä"
COM_ISBNREGISTRY_PUBLISHER_FILTER_TARGET_FIELD_DESC="Mihin kenttään haku kohdistuu"
COM_ISBNREGISTRY_PUBLISHER_FILTER_TARGET_FIELD_SELECT="-Valitse hakukenttä-"
COM_ISBNREGISTRY_PUBLISHER_FILTER_HAS_EMAIL_LABEL="Sähköposti"
COM_ISBNREGISTRY_PUBLISHER_FILTER_HAS_EMAIL_DESC="Onko kustantajalla sähköpostiosoitetta"
COM_ISBNREGISTRY_PUBLISHER_FILTER_HAS_EMAIL_SELECT="-Onko sähköpostia-"

; Publication search
COM_ISBNREGISTRY_PUBLICATION_FILTER_SEARCH_LABEL="Haku"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,17 @@
<!--<option value="6">COM_ISBNREGISTRY_PUBLISHER_FILTER_IDENTIFIER_ISBN</option>
<option value="7">COM_ISBNREGISTRY_PUBLISHER_FILTER_IDENTIFIER_ISMN</option>-->
</field>
<field
name="has_email"
type="list"
label="COM_ISBNREGISTRY_PUBLISHER_FILTER_HAS_EMAIL_LABEL"
description="COM_ISBNREGISTRY_PUBLISHER_FILTER_HAS_EMAIL_DESC"
onchange="this.form.submit();"
>
<option value="">COM_ISBNREGISTRY_PUBLISHER_FILTER_HAS_EMAIL_SELECT</option>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
</fields>
<fields name="list">
<field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public function __construct($config = array()) {
'type', 'a.type',
'lang_code', 'a.lang_code',
'no_identifier', 'a.no_identifier',
'target_field', 'a.target_field'
'target_field', 'a.target_field',
'has_email', 'a.has_email'
);
}

Expand Down Expand Up @@ -71,6 +72,9 @@ protected function populateState($ordering = null, $direction = null) {
$targetField = $this->getUserStateFromRequest($this->context . '.filter.target_field', 'filter_target_field', '');
$this->setState('filter.target_field', $targetField);

$hasEmail = $this->getUserStateFromRequest($this->context . '.filter.has_email', 'filter_has_email', '');
$this->setState('filter.has_email', $hasEmail);

// List state information.
parent::populateState('a.official_name', 'asc');
}
Expand All @@ -97,6 +101,8 @@ protected function getListQuery() {
$noIdentifier = $this->getState('filter.no_identifier');
// Get target field
$targetField = $this->getState('filter.target_field');
// Get has email value
$hasEmail = $this->getState('filter.has_email');

// Create the base select statement.
$query->select('DISTINCT a.id, a.official_name, a.other_names, a.active_identifier_isbn, a.active_identifier_ismn, a.created')
Expand Down Expand Up @@ -124,6 +130,15 @@ protected function getListQuery() {
$query->join('LEFT', '#__isbn_registry_publisher_ismn_range AS ismn ON a.id = ismn.publisher_id');
}

// Set has email
if (is_numeric($hasEmail)) {
if($hasEmail == 0) {
$query->where('a.email = ""');
} else {
$query->where('a.email != ""');
}
}

// Set identifier filter
if (is_numeric($noIdentifier) && empty($type)) {
switch ($noIdentifier) {
Expand Down

0 comments on commit a2b2f3d

Please sign in to comment.