From 30087b87e8f64f0572cc2a4c27b7c6c3d28a918b Mon Sep 17 00:00:00 2001 From: Daniel Berthereau Date: Mon, 14 Dec 2015 00:00:00 +0100 Subject: [PATCH 01/10] Removed assignements from conditions. --- ContributionPlugin.php | 11 ++++++----- controllers/ContributionController.php | 11 +++++++---- libraries/ContributionImportUsers.php | 3 ++- models/Api/ContributionType.php | 6 +++--- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/ContributionPlugin.php b/ContributionPlugin.php index 4afff01e..61511478 100644 --- a/ContributionPlugin.php +++ b/ContributionPlugin.php @@ -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, '/')); @@ -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'); diff --git a/controllers/ContributionController.php b/controllers/ContributionController.php index 96e931c1..1f99f671 100644 --- a/controllers/ContributionController.php +++ b/controllers/ContributionController.php @@ -61,12 +61,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); @@ -79,7 +80,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) { @@ -146,7 +147,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)) { @@ -248,7 +250,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'); } diff --git a/libraries/ContributionImportUsers.php b/libraries/ContributionImportUsers.php index 1f147e69..40ec9241 100644 --- a/libraries/ContributionImportUsers.php +++ b/libraries/ContributionImportUsers.php @@ -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)) { diff --git a/models/Api/ContributionType.php b/models/Api/ContributionType.php index 37ec9cea..7690f8fd 100644 --- a/models/Api/ContributionType.php +++ b/models/Api/ContributionType.php @@ -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; } From 61d6af15120d566a29f772b79964cec6ddd2d7d3 Mon Sep 17 00:00:00 2001 From: Daniel Berthereau Date: Mon, 14 Dec 2015 00:00:00 +0100 Subject: [PATCH 02/10] Fixed various typos. --- controllers/ContributionController.php | 4 ++-- .../ResponseAdapter/OmekaNet/ContributorFieldsAdapter.php | 2 +- models/Mixin/ContributionOrder.php | 2 +- views/admin/items/browse.php | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/controllers/ContributionController.php b/controllers/ContributionController.php index 1f99f671..43e18c37 100644 --- a/controllers/ContributionController.php +++ b/controllers/ContributionController.php @@ -261,7 +261,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); return false; } catch (Omeka_File_Ingest_InvalidException $e) { @@ -282,7 +282,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; } diff --git a/libraries/ApiImport/ResponseAdapter/OmekaNet/ContributorFieldsAdapter.php b/libraries/ApiImport/ResponseAdapter/OmekaNet/ContributorFieldsAdapter.php index 2303f4b4..6873bf6f 100644 --- a/libraries/ApiImport/ResponseAdapter/OmekaNet/ContributorFieldsAdapter.php +++ b/libraries/ApiImport/ResponseAdapter/OmekaNet/ContributorFieldsAdapter.php @@ -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; } } \ No newline at end of file diff --git a/models/Mixin/ContributionOrder.php b/models/Mixin/ContributionOrder.php index 807b29e0..ed8a1b0a 100644 --- a/models/Mixin/ContributionOrder.php +++ b/models/Mixin/ContributionOrder.php @@ -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!')); diff --git a/views/admin/items/browse.php b/views/admin/items/browse.php index 02eddb2f..09fc4cf0 100644 --- a/views/admin/items/browse.php +++ b/views/admin/items/browse.php @@ -45,7 +45,7 @@ - +
From 1d69836a23f7d5b0c59d2b03d367d89feb52bbb6 Mon Sep 17 00:00:00 2001 From: Daniel Berthereau Date: Mon, 5 Dec 2016 00:00:00 +0100 Subject: [PATCH 03/10] Fixed mysql install. --- ContributionPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ContributionPlugin.php b/ContributionPlugin.php index 61511478..81a73e09 100644 --- a/ContributionPlugin.php +++ b/ContributionPlugin.php @@ -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;"; From 3c1bf72b04c73791846ff89467a855dd918d4735 Mon Sep 17 00:00:00 2001 From: Daniel Berthereau Date: Mon, 19 Dec 2016 00:00:00 +0100 Subject: [PATCH 04/10] Added a

title to my contributions. --- views/public/contribution/my-contributions.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/views/public/contribution/my-contributions.php b/views/public/contribution/my-contributions.php index fab13a28..a48d1a51 100644 --- a/views/public/contribution/my-contributions.php +++ b/views/public/contribution/my-contributions.php @@ -1,6 +1,14 @@ - + $title, + 'bodyclass' => $bodyClass, +)); ?>
+

@@ -30,4 +38,4 @@ - + Date: Mon, 19 Dec 2016 00:00:00 +0100 Subject: [PATCH 05/10] Protected the page "My Contributions". --- controllers/ContributionController.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/controllers/ContributionController.php b/controllers/ContributionController.php index 43e18c37..9c8deb06 100644 --- a/controllers/ContributionController.php +++ b/controllers/ContributionController.php @@ -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(); From abe1dc14e4ca1f130bd59e72fa2bc0d0c00745ee Mon Sep 17 00:00:00 2001 From: Daniel Berthereau Date: Mon, 19 Dec 2016 00:00:00 +0100 Subject: [PATCH 06/10] Internationalized some strings. --- ContributionPlugin.php | 2 +- languages/template.pot | 4 ++-- views/public/contribution/contribute.php | 7 +++++-- views/public/contribution/thankyou.php | 4 ++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ContributionPlugin.php b/ContributionPlugin.php index 81a73e09..474d80a9 100644 --- a/ContributionPlugin.php +++ b/ContributionPlugin.php @@ -674,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; diff --git a/languages/template.pot b/languages/template.pot index 099a704c..2e633f12 100644 --- a/languages/template.pot +++ b/languages/template.pot @@ -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 @@ -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 diff --git a/views/public/contribution/contribute.php b/views/public/contribution/contribute.php index 30bc025d..d12498df 100644 --- a/views/public/contribution/contribute.php +++ b/views/public/contribution/contribute.php @@ -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}"); } @@ -42,7 +42,10 @@ redirect = absolute_url(); ?> -

You must '>create an account or '>log in before contributing. You can still leave your identity to site visitors anonymous.

+

+ ', '', '', ''); ?> + +

diff --git a/views/public/contribution/thankyou.php b/views/public/contribution/thankyou.php index a2bc1d32..1a805e68 100644 --- a/views/public/contribution/thankyou.php +++ b/views/public/contribution/thankyou.php @@ -1,10 +1,10 @@

-

" . __('browse the archive') . ""); ?> +

" . __('browse the archive') . ""); ?>

-

" . __('this page') . ""); ?> +

" . __('this page') . ""); ?>

From 78a2ede1a0ae54c899c7b9adf160215f9d671984 Mon Sep 17 00:00:00 2001 From: Daniel Berthereau Date: Mon, 19 Dec 2016 00:00:00 +0100 Subject: [PATCH 07/10] Updated tests. --- tests/cases/ContributionTypeTest.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/cases/ContributionTypeTest.php b/tests/cases/ContributionTypeTest.php index d245f847..c6140026 100644 --- a/tests/cases/ContributionTypeTest.php +++ b/tests/cases/ContributionTypeTest.php @@ -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()); } @@ -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.'); } From b3702099f6cccdc5eff686f27bd0a5d0b2cf0ab0 Mon Sep 17 00:00:00 2001 From: Daniel Berthereau Date: Mon, 19 Dec 2016 00:00:00 +0100 Subject: [PATCH 08/10] Fixed color of the message when the settings are saved. --- controllers/SettingsController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/SettingsController.php b/controllers/SettingsController.php index 958aeccc..fe16846a 100644 --- a/controllers/SettingsController.php +++ b/controllers/SettingsController.php @@ -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')); } From d645d393843f2c8f0d06333872434551922d2bdf Mon Sep 17 00:00:00 2001 From: Daniel Berthereau Date: Mon, 19 Dec 2016 00:00:00 +0100 Subject: [PATCH 09/10] Fixed tag when there is no captcha. --- views/public/contribution/contribute.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/public/contribution/contribute.php b/views/public/contribution/contribute.php index d12498df..6da463ba 100644 --- a/views/public/contribution/contribute.php +++ b/views/public/contribution/contribute.php @@ -61,8 +61,8 @@
-
> - +
> +
From 11f3c2f02e02730596763e2e7488740a916322f6 Mon Sep 17 00:00:00 2001 From: Daniel Berthereau Date: Mon, 19 Dec 2016 00:00:00 +0100 Subject: [PATCH 10/10] Made the element form label themable. --- ContributionPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ContributionPlugin.php b/ContributionPlugin.php index 474d80a9..086a0645 100644 --- a/ContributionPlugin.php +++ b/ContributionPlugin.php @@ -801,7 +801,7 @@ public function elementFormFilter($components, $args) $type = $view->type; $contributionElement = $this->_db->getTable('ContributionTypeElement')->findByElementAndType($element, $type); $prompt = $contributionElement->prompt; - $components['label'] = ''; + $components['label'] = $view->formLabel(null, $prompt, array('disableFor' => true)); $components['add_input'] = null; return $components; }