Skip to content
17 changes: 9 additions & 8 deletions ContributionPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function hookInstall()
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`item_type_id` INT UNSIGNED NOT NULL,
`display_name` VARCHAR(255) NOT NULL,
`file_permissions` ENUM('Disallowed', 'Allowed', 'Required') NOT NULL DEFAULT 'Disallowed',
`file_permissions` ENUM('Disallowed', 'Allowed', 'Required') NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `item_type_id` (`item_type_id`)
) ENGINE=MyISAM;";
Expand Down Expand Up @@ -181,7 +181,8 @@ public function hookUpgrade($args)
}

$pagePath = get_option('contribution_page_path');
if ($pagePath = 'contribution/') {
$pagePath = 'contribution/';
if ($pagePath) {
delete_option('contribution_page_path');
} else {
set_option('contribution_page_path', trim($pagePath, '/'));
Expand Down Expand Up @@ -524,11 +525,11 @@ public function hookAdminItemsBrowseDetailedEach($args)
*/
public function hookItemsBrowseSql($args)
{
$select = $args['select'];
$params = $args['params'];

$select = $args['select'];
$params = $args['params'];

if (($request = Zend_Controller_Front::getInstance()->getRequest())) {
$request = Zend_Controller_Front::getInstance()->getRequest();
if ($request) {
$db = get_db();

$contributed = $request->get('contributed');
Expand Down Expand Up @@ -673,7 +674,7 @@ public function filterItemCitation($cite,$args)
public function filterGuestUserLinks($nav)
{
$nav['Contribution'] = array(
'label' => 'My Contributions',
'label' => __('My Contributions'),
'uri' => contribution_contribute_url('my-contributions'),
);
return $nav;
Expand Down Expand Up @@ -800,7 +801,7 @@ public function elementFormFilter($components, $args)
$type = $view->type;
$contributionElement = $this->_db->getTable('ContributionTypeElement')->findByElementAndType($element, $type);
$prompt = $contributionElement->prompt;
$components['label'] = '<label>' . $prompt . '</label>';
$components['label'] = $view->formLabel(null, $prompt, array('disableFor' => true));
$components['add_input'] = null;
return $components;
}
Expand Down
19 changes: 13 additions & 6 deletions controllers/ContributionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ public function indexAction()
public function myContributionsAction()
{
$user = current_user();
if (empty($user)) {
$this->_helper->redirector('login', 'users', 'default');
}

$contribItemTable = $this->_helper->db->getTable('ContributionContributedItem');

$contribItems = array();
Expand Down Expand Up @@ -62,12 +66,13 @@ public function contributeAction()
$csrf = new Omeka_Form_SessionCsrf;
$this->view->csrf = $csrf;
if(!empty($_POST)) {
$defaultType = get_option('contribution_default_type');
if (!$csrf->isValid($_POST)) {
$this->_helper->_flashMessenger(__('There was an error on the form. Please try again.'), 'error');
$typeId = null;
if (isset($_POST['contribution_type']) && ($postedType = $_POST['contribution_type'])) {
$typeId = $postedType;
} else if ($defaultType = get_option('contribution_default_type')) {
} elseif ($defaultType) {
$typeId = $defaultType;
}
$this->_setupContributeSubmit($typeId);
Expand All @@ -80,7 +85,7 @@ public function contributeAction()
$typeId = null;
if (isset($_POST['contribution_type']) && ($postedType = $_POST['contribution_type'])) {
$typeId = $postedType;
} else if ($defaultType = get_option('contribution_default_type')) {
} elseif ($defaultType) {
$typeId = $defaultType;
}
if ($this->_captcha) {
Expand Down Expand Up @@ -147,7 +152,8 @@ public function _setupContributeSubmit($typeId)
$profileType = $this->_helper->db->getTable('UserProfilesType')->find($profileTypeId);
$this->view->profileType = $profileType;

if($user = current_user()) {
$user = current_user();
if($user) {
$profile = $this->_helper->db->getTable('UserProfilesProfile')->findByUserIdAndTypeId($user->id, $profileTypeId);
}
if(empty($profile)) {
Expand Down Expand Up @@ -249,7 +255,8 @@ protected function _processForm($post)

// This is a hack to allow the file upload job to succeed
// even with the synchronous job dispatcher.
if ($acl = get_acl()) {
$acl = get_acl();
if ($acl) {
$acl->allow(null, 'Items', 'showNotPublic');
$acl->allow(null, 'Collections', 'showNotPublic');
}
Expand All @@ -259,7 +266,7 @@ protected function _processForm($post)
$item->setOwner($user);
$item->save();
$item = update_item($item, $itemMetadata, array(), $fileMetadata);
} catch(Omeka_Validator_Exception $e) {
} catch(Omeka_Validate_Exception $e) {
$this->flashValidatonErrors($e);
$item->delete();
return false;
Expand All @@ -283,7 +290,7 @@ protected function _processForm($post)
$item->save();
//if not simple and the profile doesn't process, send back false for the error
$this->_processUserProfile($post, $user);
$this->_linkItemToContributedItem($item, $contributor, $post);
$this->_linkItemToContributedItem($item, null, $post);
$this->_sendEmailNotifications($user, $item);
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion controllers/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function editAction()
if (isset($_POST['submit'])) {
if ($form->isValid($_POST)) {
$this->_setOptions($form->getValues());
$this->_helper->flashMessenger(__('Settings have been saved.'));
$this->_helper->flashMessenger(__('Settings have been saved.'), 'success');
} else {
$this->_helper->flashMessenger(__('There were errors found in your form. Please edit and resubmit.', 'error'));
}
Expand Down
4 changes: 2 additions & 2 deletions languages/template.pot
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ msgstr ""
#, php-format
msgid ""
"Your contribution will show up in the archive once an administrator approves "
"it. Meanwhile, feel free to %s or %s ."
"it. Meanwhile, feel free to %s or %s."
msgstr ""

#: views/public/contribution/thankyou.php:7
Expand All @@ -619,7 +619,7 @@ msgstr ""
msgid ""
"If you would like to interact with the site further, you can use an account "
"that is ready for you. Visit %s, and request a new password for the email "
"you used"
"you used."
msgstr ""

#: views/public/contribution/type-form.php:3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected function getElementSet()
$userProfilesType->public = 0;
$userProfilesType->required = 0;
$userProfilesType->element_set_id = $this->elementSet->id;
$userProfileType->save();
$userProfilesType->save();
return $this->elementSet;
}
}
3 changes: 2 additions & 1 deletion libraries/ContributionImportUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public function perform()
//create username from email and set up for some validation checks
$username = $contributor['email'];
$email = $contributor['email'];
if($user = $db->getTable('User')->findByEmail($contributor['email'])) {
$user = $db->getTable('User')->findByEmail($contributor['email']);
if ($user) {
$userContributorMap[$user->id][] = $contributor['id'];
} else {
if(!$emailValidator->isValid($email)) {
Expand Down
6 changes: 3 additions & 3 deletions models/Api/ContributionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ public function getRepresentation(Omeka_Record_AbstractRecord $type)
{
$representation = array(
'id' => $type->id,
'url' => self::getResourceUrl("/contribution_types/{$ype->id}"),
'url' => self::getResourceUrl('/contribution_types/' . $type->id),
'display_name' => $type->display_name,
'file_permissions' => $type->file_permissions
);
$representation['item_type'] = array(
'id' => $type->item_type_id,
'url' => self::getResourceUrl("/item_types/{$type->item_type_id}")
);
'url' => self::getResourceUrl('/item_types/' . $type->item_type_id)
);
return $representation;
}

Expand Down
2 changes: 1 addition & 1 deletion models/Mixin/ContributionOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function reorderChildren()
array($parentId));
}

public function addChild(Omeka_Record $child)
public function addChild(Omeka_Record_AbstractRecord $child)
{
if (!$this->_record->exists()) {
throw new Omeka_Record_Exception(__('Cannot add a child to a record that does not exist yet!'));
Expand Down
18 changes: 9 additions & 9 deletions tests/cases/ContributionTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ public function testIsFileAllowed()
$type = new ContributionType;
$this->assertFalse($type->isFileAllowed());

$type->file_permissions = ContributionType::FILE_PERMISSION_ALLOWED;
$type->file_permissions = 'Allowed';
$this->assertTrue($type->isFileAllowed());

$type->file_permissions = ContributionType::FILE_PERMISSION_REQUIRED;
$type->file_permissions = 'Required';
$this->assertTrue($type->isFileAllowed());

$type->file_permissions = ContributionType::FILE_PERMISSION_DISALLOWED;
$type->file_permissions = 'Disallowed';
$this->assertFalse($type->isFileAllowed());
}

Expand All @@ -41,22 +41,22 @@ public function testIsFileRequired()
$type = new ContributionType;
$this->assertFalse($type->isFileRequired());

$type->file_permissions = ContributionType::FILE_PERMISSION_ALLOWED;
$type->file_permissions = 'Allowed';
$this->assertFalse($type->isFileRequired());

$type->file_permissions = ContributionType::FILE_PERMISSION_REQUIRED;
$type->file_permissions = 'Required';
$this->assertTrue($type->isFileRequired());

$type->file_permissions = ContributionType::FILE_PERMISSION_DISALLOWED;
$type->file_permissions = 'Disallowed';
$this->assertFalse($type->isFileRequired());
}

public function testFilePermissionsCoverage()
{
$permissions = ContributionType::getPossibleFilePermissions();
$this->assertAndRemoveArrayKey(ContributionType::FILE_PERMISSION_ALLOWED, $permissions);
$this->assertAndRemoveArrayKey(ContributionType::FILE_PERMISSION_REQUIRED, $permissions);
$this->assertAndRemoveArrayKey(ContributionType::FILE_PERMISSION_DISALLOWED, $permissions);
$this->assertAndRemoveArrayKey('Allowed', $permissions);
$this->assertAndRemoveArrayKey('Required', $permissions);
$this->assertAndRemoveArrayKey('Disallowed', $permissions);
$this->assertEquals(0, count($permissions), 'Not all file permission levels are covered by testing.');
}

Expand Down
2 changes: 1 addition & 1 deletion views/admin/items/browse.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

<?php echo common('contribution-quick-filters'); ?>

<table id="contributions" cellspacing="0" cellpadding="0">
<table id="contributions">
<thead id="types-table-head">
<tr>
<?php if ($allowToManage): ?>
Expand Down
11 changes: 7 additions & 4 deletions views/public/contribution/contribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
//load user profiles js and css if needed
if(get_option('contribution_user_profile_type') && plugin_is_active('UserProfiles') ) {
queue_js_file('admin-globals');
queue_js_file('tiny_mce', 'javascripts/vendor/tiny_mce');
queue_js_file('tiny_mce', 'javascripts/vendor/tiny_mce');
queue_js_file('elements');
queue_css_string("input.add-element {display: block}");
}
Expand All @@ -42,7 +42,10 @@
<?php $session = new Zend_Session_Namespace;
$session->redirect = absolute_url();
?>
<p>You must <a href='<?php echo url('guest-user/user/register'); ?>'>create an account</a> or <a href='<?php echo url('guest-user/user/login'); ?>'>log in</a> before contributing. You can still leave your identity to site visitors anonymous.</p>
<p>
<?php echo __('You must %screate an account%s or %slog in%s before contributing.', '<a href="' . url('guest-user/user/register') .'">', '</a>', '<a href="' . url('guest-user/user/login') . '">', '</a>'); ?>
<?php echo __('You can still leave your identity to site visitors anonymous.'); ?>
</p>
<?php else: ?>
<form method="post" action="" enctype="multipart/form-data">
<fieldset id="contribution-item-metadata">
Expand All @@ -58,8 +61,8 @@
</div>
</fieldset>

<fieldset id="contribution-confirm-submit" <?php if (!isset($type)) { echo 'style="display: none;"'; }?>>
<?php if(isset($captchaScript)): ?>
<fieldset id="contribution-confirm-submit" <?php if (empty($type)) { echo 'style="display: none;"'; }?>>
<?php if(!empty($captchaScript)): ?>
<div id="captcha" class="inputs"><?php echo $captchaScript; ?></div>
<?php endif; ?>
<div class="inputs">
Expand Down
4 changes: 2 additions & 2 deletions views/public/contribution/thankyou.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php echo head(); ?>
<div id="primary">
<h1><?php echo __("Thank you for contributing!"); ?></h1>
<p><?php echo __("Your contribution will show up in the archive once an administrator approves it. Meanwhile, feel free to %s or %s ." , contribution_link_to_contribute(__('make another contribution')), "<a href='" . url('items/browse') . "'>" . __('browse the archive') . "</a>"); ?>
<p><?php echo __("Your contribution will show up in the archive once an administrator approves it. Meanwhile, feel free to %s or %s." , contribution_link_to_contribute(__('make another contribution')), "<a href='" . url('items/browse') . "'>" . __('browse the archive') . "</a>"); ?>
</p>
<?php if(get_option('contribution_open') && !current_user()): ?>
<p><?php echo __("If you would like to interact with the site further, you can use an account that is ready for you. Visit %s, and request a new password for the email you used", "<a href='" . url('users/forgot-password') . "'>" . __('this page') . "</a>"); ?>
<p><?php echo __("If you would like to interact with the site further, you can use an account that is ready for you. Visit %s, and request a new password for the email you used.", "<a href='" . url('users/forgot-password') . "'>" . __('this page') . "</a>"); ?>
<?php endif; ?>
</div>
<?php echo foot(); ?>