From 77830a4a4f1f7fcdf2eacba2659a251b2abebe2a Mon Sep 17 00:00:00 2001 From: vnmedeiros Date: Thu, 17 Sep 2020 10:37:19 -0300 Subject: [PATCH] add mapped property `submission_anonymous_user` #388 --- .../entities/class-tainacan-collection.php | 23 ++++++++++++++++++- .../class-tainacan-collections.php | 9 +++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/classes/entities/class-tainacan-collection.php b/src/classes/entities/class-tainacan-collection.php index bfaca0900..8e86220ba 100644 --- a/src/classes/entities/class-tainacan-collection.php +++ b/src/classes/entities/class-tainacan-collection.php @@ -34,7 +34,8 @@ class Collection extends Entity { $header_image_id, $header_image, $comment_status, - $allow_comments; + $allow_comments, + $submission_anonymous_user; /** * {@inheritDoc} @@ -543,6 +544,15 @@ class Collection extends Entity { return $this->get_mapped_property('allow_comments'); } + /** + * Get enable submission with anonymous user + * + * @return string + */ + function get_submission_anonymous_user() { + return $this->get_mapped_property( 'submission_anonymous_user' ) != 'false'; + } + /** * Set the collection name * @@ -732,6 +742,17 @@ class Collection extends Entity { $this->set_mapped_property('allow_comments', $value ); } + /** + * Set enable submission with anonymous user + * + * @param [boolean] $value + * + * @return void + */ + function set_submission_anonymous_user( $value ) { + $this->set_mapped_property( 'submission_anonymous_user', $value ); + } + /** * Validate Collection * diff --git a/src/classes/repositories/class-tainacan-collections.php b/src/classes/repositories/class-tainacan-collections.php index 2d556dfa5..368d9913b 100644 --- a/src/classes/repositories/class-tainacan-collections.php +++ b/src/classes/repositories/class-tainacan-collections.php @@ -194,7 +194,14 @@ class Collections extends Repository { 'description' => __( 'Collection items comment status: "open" means comments are allowed, "closed" means comments are not allowed.', 'tainacan' ), 'default' => 'open', 'validation' => v::optional(v::stringType()->in( [ 'open', 'closed' ] )), - ] + ], + 'submission_anonymous_user' => [ + 'map' => 'meta', + 'title' => __( 'Allows submission by anonymous user', 'tainacan' ), + 'type' => 'boolean', + 'description' => __( 'If enabled, allows submission by anonymous user.', 'tainacan' ), + 'default' => 'false' + ], ] ); }