Skip to content

Commit

Permalink
Merge pull request #64 from luku/xtype
Browse files Browse the repository at this point in the history
Allow same item type for multiple contribution types
  • Loading branch information
patrickmj authored Feb 8, 2018
2 parents a6baf4a + 484bb3e commit 0369bfd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
7 changes: 6 additions & 1 deletion ContributionPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function hookInstall()
`display_name` VARCHAR(255) NOT NULL,
`file_permissions` ENUM('Disallowed', 'Allowed', 'Required') NOT NULL DEFAULT 'Disallowed',
PRIMARY KEY (`id`),
UNIQUE KEY `item_type_id` (`item_type_id`)
KEY `item_type_id` (`item_type_id`)
) ENGINE=MyISAM;";
$this->_db->query($sql);

Expand Down Expand Up @@ -259,6 +259,11 @@ public function hookUpgrade($args)
set_option('contribution_open', get_option('contribution_simple'));
delete_option('contribution_simple');
}
if (version_compare($oldVersion, '3.1.0.1', '<')) {
$this->_db->query("ALTER TABLE `{$this->_db->ContributionType}`
DROP INDEX `item_type_id`,
ADD INDEX `item_type_id` (`item_type_id`)");
}
}

public function hookUninstallMessage()
Expand Down
16 changes: 1 addition & 15 deletions models/Table/ContributionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,11 @@ public function getBrowseData()

/**
* Get an array of possible item types for a new contribution type.
* "Possible types" here means any item type not currently used as the
* basis for a contribution type.
*
* @return array
*/
public function getPossibleItemTypes()
{
$db = $this->getDb();
$sql = <<<SQL
SELECT `it`.`id` AS `item_type_id`, `it`.`name` AS `item_type_name`
FROM `{$db->ItemType}` AS `it`
WHERE NOT `it`.`id` IN (SELECT `item_type_id` FROM `{$this->getTableName()}`)
ORDER BY `item_type_name` ASC;
SQL;
$itemTypes = $db->fetchAll($sql);
$options = array();
foreach ($itemTypes as $itemType) {
$options[$itemType['item_type_id']] = $itemType['item_type_name'];
}
return $options;
return $this->getDb()->getTable('ItemType')->findPairsForSelectForm();
}
}
2 changes: 1 addition & 1 deletion plugin.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description="Allows collecting items from visitors"
link="http://omeka.org/codex/Plugins/Contribution_2.0"
support_link="http://omeka.org/forums/forum/plugins"
omeka_minimum_version="2.3"
omeka_target_version="2.3"
omeka_target_version="2.5"
version="3.1.1"
tags="social, items"
license="GPLv3"
Expand Down

0 comments on commit 0369bfd

Please sign in to comment.