Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow same item type for multiple contribution types #64

Merged
merged 2 commits into from
Feb 8, 2018
Merged
Changes from all 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
7 changes: 6 additions & 1 deletion ContributionPlugin.php
Original file line number Diff line number Diff line change
@@ -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);

@@ -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()
16 changes: 1 addition & 15 deletions models/Table/ContributionType.php
Original file line number Diff line number Diff line change
@@ -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
@@ -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"