Skip to content

Commit

Permalink
Fix people lookup bug in Item Relations tab of item edit
Browse files Browse the repository at this point in the history
  • Loading branch information
Thom Mc committed Jul 23, 2015
1 parent 90ca365 commit d1fd063
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
19 changes: 11 additions & 8 deletions controllers/ItemAutocompleteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function getAction()

$params = $request->getParams();

if (empty($params['term']) || empty($params['elementid']))
if (empty($params['term']) || empty($params['irpropid']))
{
header("HTTP/1.0 400 Bad Request");
die('Argh! Need a search term and an element id');
Expand All @@ -59,11 +59,15 @@ public function getAction()

// $select = $db->getSelect();

// work out which DC element_ids to look up ppl instead of things
$sql = "
SELECT id FROM omeka_elements WHERE name IN ('contributor', 'creator', 'publisher') and element_set_id = 1;
";
$people_element_ids = $db->getTable('Element')->fetchAll($sql);
// work out which item_relations_property_ids to look up ppl instead of things
$irprop_people_ids = array();
$q_contributor_id = $db->getTable('ItemRelationsProperty')->findByLabel('Contributor');
$irprop_people_ids[] = $q_contributor_id[0]->id;
$q_creator_id = $db->getTable('ItemRelationsProperty')->findByLabel('Creator');
$irprop_people_ids[] = $q_creator_id[0]->id;
$q_publisher_id = $db->getTable('ItemRelationsProperty')->findByLabel('Publisher');
$irprop_people_ids[] = $q_publisher_id[0]->id;


// determine element_id for DC Title
$sql = "
Expand All @@ -77,9 +81,8 @@ public function getAction()
";
$alt_title_id = $db->getTable('Element')->fetchOne($sql);


// if DC field is a person, limit results to people...
if (!empty($params['elementid']) && in_array($params['elementid'], $people_element_ids[0])) // contributor, creator, publisher
if (!empty($params['irpropid']) && in_array($params['irpropid'], $irprop_people_ids)) // contributor, creator, publisher
{
$sql = "
SELECT DISTINCT et1.record_id, et1.text
Expand Down
4 changes: 2 additions & 2 deletions item_relations_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
},
source: function(request, response) {
jQuery.ajax({
url: '/item-relations/item-autocomplete/get/term/' + request.term + (jQuery('#item_relations_property_id' + rowid).val() == undefined ? '' : '/elementid/' + jQuery('#item_relations_property_id' + rowid).val()),
url: '/item-relations/item-autocomplete/get/term/' + request.term + (jQuery('#item_relations_property_id' + rowid).val() == undefined ? '' : '/irpropid/' + jQuery('#item_relations_property_id' + rowid).val()),
dataType: "json",
data: {
// q: request.term
Expand Down Expand Up @@ -116,7 +116,7 @@
},
source: function(request, response) {
jQuery.ajax({
url: '/item-relations/item-autocomplete/get/term/' + request.term + (jQuery('#item_relations_property_id').val() == undefined ? '' : '/elementid/' + jQuery('#item_relations_property_id').val()),
url: '/item-relations/item-autocomplete/get/term/' + request.term + (jQuery('#item_relations_property_id').val() == undefined ? '' : '/irpropid/' + jQuery('#item_relations_property_id').val()),
dataType: "json",
data: {
// q: request.term
Expand Down
2 changes: 1 addition & 1 deletion plugin.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ support_link="http://omeka.org/forums/forum/plugins"
license="GPLv3"
omeka_minimum_version="2.0"
omeka_target_version="2.3"
version="2.0.12"
version="2.0.13"
tags="item,relation,rdf"

0 comments on commit d1fd063

Please sign in to comment.