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

(Web) Polls #4406

Merged
merged 60 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
d3e3ec7
[PROD-7416] Add Poll button into activity post form
amincdev May 13, 2024
aa0f6d4
[PROD-7416] Register activityPollForm into post form
amincdev May 14, 2024
751b46b
Merge branch 'release' into PROD-7416
amincdev May 16, 2024
a46a6bc
[PROD-7416] grunt
amincdev May 16, 2024
48258a8
[PROD-7416] Initialize poll data and add condition before adding poll…
amincdev May 16, 2024
741e648
[PROD-7416] Add Poll view template in activity form
amincdev May 16, 2024
db8b046
[PROD-7416] Check if post has Poll data before disabling a post button
amincdev May 20, 2024
1ee6b74
[PROD-7416] Remove direct field values while saving draft data and po…
amincdev May 20, 2024
a80df25
[PROD-7416] Save Poll data into draft
amincdev May 21, 2024
3765c14
[PROD-7416] Allow to post only poll in activity
amincdev May 21, 2024
bc57323
Merge branch 'release' into PROD-7416
jitendrabanjara1991 Jun 6, 2024
c319256
PROD-7416 - Grunt
jitendrabanjara1991 Jun 6, 2024
2ae5b59
PROD-7416 - Add setting for poll in platform
jitendrabanjara1991 Jun 6, 2024
4aeb90d
PROD-7416 - Display notice if platform pro is inactive and also add c…
jitendrabanjara1991 Jun 6, 2024
955b4d6
PROD-7416 - Code optimise
jitendrabanjara1991 Jun 6, 2024
9ca9d4d
PROD-7416 - Check setting value
jitendrabanjara1991 Jun 6, 2024
75ff90a
PROD-7416 - Add one param as false - If function will get false then …
jitendrabanjara1991 Jun 6, 2024
7ae55d3
PROD-7416 - Introduce new action. Using this action, can add new tool…
jitendrabanjara1991 Jun 6, 2024
adbe052
PROD-7416 - If option is enable for poll activity, or user is admin t…
jitendrabanjara1991 Jun 6, 2024
11cb439
PROD-7416 - Add new attribute in group list which display in the acti…
jitendrabanjara1991 Jun 7, 2024
b23f018
PROD-7416 - Pass attribute `allow_polls` if setting is enable for group
jitendrabanjara1991 Jun 7, 2024
e45b05c
PROD-7416 - Hide/show poll button based on poll value
jitendrabanjara1991 Jun 7, 2024
ceb84f7
PROD-7416 - Add poll id as key in the draft, Also allow to post activ…
jitendrabanjara1991 Jun 10, 2024
e3cb203
PROD-7416 - Checking poll id to set poll data
jitendrabanjara1991 Jun 11, 2024
2376095
PROD-7416 - Remove some pair name from draft data
jitendrabanjara1991 Jun 11, 2024
d7e2ca8
PROD-7416 - Remove unused model attribute when post update
jitendrabanjara1991 Jun 12, 2024
4eb8964
PROD-7416 - Update condition to check poll is exists or not
jitendrabanjara1991 Jun 12, 2024
140e255
PROD-7416 - Use only one attribute for poll and inside this main attr…
jitendrabanjara1991 Jun 12, 2024
6f3849b
Merge branch 'release' into PROD-7416
jitendrabanjara1991 Jun 13, 2024
4e8ada1
PROD-7416 - add vote disabled date in poll object
jitendrabanjara1991 Jun 13, 2024
82dc8e8
PROD-7416 - Pass activity id when edit poll
jitendrabanjara1991 Jun 23, 2024
34973ad
PROD-7416 - Add user id to verify poll creator user
jitendrabanjara1991 Jun 26, 2024
8ac9157
Merge branch 'release' into PROD-7416
jitendrabanjara1991 Jun 26, 2024
627741e
PROD-7416 - Fix js error - when reset data then it was give error abo…
jitendrabanjara1991 Jun 26, 2024
4d0ae78
PROD-7416 - Grunt
jitendrabanjara1991 Jun 27, 2024
30cc124
PROD-7416 - Update platform pro dependency version
jitendrabanjara1991 Jun 27, 2024
80316b2
PROD-7416 - Pass total votes to edit poll data
jitendrabanjara1991 Jul 1, 2024
2488242
PROD-7416 - Pass item_id in the poll object
jitendrabanjara1991 Jul 2, 2024
74e0cf8
PROD-7416 - Check poll id when activity post and send email with poll…
jitendrabanjara1991 Jul 4, 2024
9699bfa
PROD-7416 - Notification when add new poll with question
jitendrabanjara1991 Jul 4, 2024
90a469b
Merge branch 'release' into PROD-7416
jitendrabanjara1991 Jul 10, 2024
3be6424
PROD-7416 - type casting
jitendrabanjara1991 Jul 11, 2024
9ab0796
Merge branch 'release' into PROD-7416
jitendrabanjara1991 Jul 11, 2024
9155ee8
PROD-7416 - Clear poll when change group privacy
jitendrabanjara1991 Jul 12, 2024
867b057
PROD-7416 - Update icon for poll
jitendrabanjara1991 Jul 13, 2024
f9036db
PROD-7416 - Update platform pro version
jitendrabanjara1991 Jul 15, 2024
a450956
PROD-7416 - Create function to check min pro version for poll
jitendrabanjara1991 Jul 19, 2024
a9ae261
PROD-7416 - Update pro version
jitendrabanjara1991 Jul 26, 2024
23fe1cf
Merge branch 'release' into PROD-7416
jitendrabanjara1991 Jul 26, 2024
ed6866f
PROD-7416 - Pass edit_poll data to validate poll can editable or not
jitendrabanjara1991 Aug 1, 2024
fd922c7
PROD-7416 - Run grunt
jitendrabanjara1991 Aug 1, 2024
52218f4
Merge branch 'release' into PROD-7416
jitendrabanjara1991 Aug 13, 2024
1c0657e
PROD-7416 - Update default duration
jitendrabanjara1991 Aug 14, 2024
b3a07fb
Merge branch 'release' into PROD-7416
jitendrabanjara1991 Aug 15, 2024
f57bbee
PROD-7416 - Fix - "Adding new Post with Poll or without poll it shows…
jitendrabanjara1991 Aug 15, 2024
e866304
PROD-7416 - Fixed - Group Organizer/Owner and Moderator uppercase/low…
jitendrabanjara1991 Aug 15, 2024
98c578b
PROD-7416 - Fix - Adding new Post with Poll it shows on the middle sc…
jitendrabanjara1991 Aug 20, 2024
7fe36d3
Merge branch 'release' into PROD-7416
jitendrabanjara1991 Aug 21, 2024
16045f9
PROD-7416 - Update platform pro dependency version for poll
jitendrabanjara1991 Aug 22, 2024
2dc18ad
PROD-7416 - Update dependency version for platform pro
jitendrabanjara1991 Sep 3, 2024
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
5 changes: 4 additions & 1 deletion src/bp-activity/bp-activity-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -5854,6 +5854,7 @@ function bb_activity_following_post_notification( $args ) {
$media_ids = $activity_metas['bp_media_ids'][0] ?? '';
$document_ids = $activity_metas['bp_document_ids'][0] ?? '';
$video_ids = $activity_metas['bp_video_ids'][0] ?? '';
$poll_id = $activity_metas['bb_poll_id'][0] ?? 0;

if ( $media_ids ) {
$media_ids = array_filter( ! is_array( $media_ids ) ? explode( ',', $media_ids ) : $media_ids );
Expand All @@ -5876,6 +5877,8 @@ function bb_activity_following_post_notification( $args ) {
} else {
$text = __( 'a video', 'buddyboss' );
}
} elseif ( ! empty( $poll_id ) ) {
$text = __( 'a new poll', 'buddyboss' );
} else {
$text = __( 'an update', 'buddyboss' );
}
Expand Down Expand Up @@ -5925,7 +5928,7 @@ function bb_activity_following_post_notification( $args ) {
'user_id' => $user_id,
'notification_type' => 'new-activity-following',
);
$poster_name = bp_core_get_user_displayname( $activity_user_id, $user_id );
$poster_name = bp_core_get_user_displayname( $activity_user_id, $user_id );

$args['tokens']['poster.name'] = $poster_name;
$args['tokens']['unsubscribe'] = esc_url( bp_email_get_unsubscribe_link( $unsubscribe_args ) );
Expand Down
16 changes: 16 additions & 0 deletions src/bp-activity/classes/class-bp-activity-notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,9 @@ public function bb_render_activity_following_post_notification( $content, $item_
$document_ids = bp_activity_get_meta( $activity->id, 'bp_document_ids', true );
$video_ids = bp_activity_get_meta( $activity->id, 'bp_video_ids', true );
$gif_data = bp_activity_get_meta( $activity->id, '_gif_data', true );
$poll_id = bp_activity_get_meta( $activity->id, 'bb_poll_id' );
$poll = ! empty( $poll_id ) && function_exists( 'bb_load_polls' ) ? bb_load_polls()->bb_get_poll( $poll_id ) : '';
$question = ! empty( $poll->question ) ? $poll->question : '';
$amount = 'single';

if ( 'web_push' === $screen ) {
Expand Down Expand Up @@ -692,6 +695,12 @@ public function bb_render_activity_following_post_notification( $content, $item_
}
} elseif ( ! empty( $gif_data ) ) {
$text = __( 'Posted an update', 'buddyboss' );
} elseif ( ! empty( $question ) ) {
$text = sprintf(
/* translators: %s: question. */
__( 'Posted a poll "%1$s"', 'buddyboss' ),
$question
);
} else {
$text = __( 'Posted an update', 'buddyboss' );
}
Expand Down Expand Up @@ -764,6 +773,13 @@ public function bb_render_activity_following_post_notification( $content, $item_
__( '%1$s posted an update', 'buddyboss' ),
$user_fullname
);
} elseif ( ! empty( $question ) ) {
$text = sprintf(
/* translators: %1$s: User full name, %2$s: question. */
__( '%1$s posted a poll "%2$s"', 'buddyboss' ),
$user_fullname,
$question
);
} else {
$text = sprintf(
/* translators: %s: User full name. */
Expand Down
55 changes: 29 additions & 26 deletions src/bp-core/admin/bp-core-admin-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -3409,29 +3409,29 @@ function bb_get_pro_label_notice( $type = 'default' ) {
);
} elseif (
function_exists( 'bb_platform_pro' ) &&
version_compare( bb_platform_pro()->version, '2.4.50', '<' ) &&
! empty( $type ) &&
'reaction' === $type
) {
$bb_pro_notice = sprintf(
'<br/><span class="bb-head-notice"> %1$s <strong>%2$s</strong> %3$s</span>',
esc_html__( 'Update', 'buddyboss' ),
esc_html__( 'BuddyBoss Platform Pro', 'buddyboss' ),
esc_html__( 'to unlock', 'buddyboss' )
);
} elseif (
function_exists( 'bb_platform_pro' ) &&
version_compare( bb_platform_pro()->version, bb_pro_schedule_posts_version(), '<' ) &&
! empty( $type ) &&
'schedule_posts' === $type
(
(
'reaction' === $type &&
version_compare( bb_platform_pro()->version, '2.4.50', '<' )
) ||
(
'schedule_posts' === $type &&
version_compare( bb_platform_pro()->version, bb_pro_schedule_posts_version(), '<' )
) ||
(
'polls' === $type &&
version_compare( bb_platform_pro()->version, bb_pro_poll_version(), '<' )
)
)
) {
$bb_pro_notice = sprintf(
'<br/><span class="bb-head-notice"> %1$s <strong>%2$s</strong> %3$s</span>',
esc_html__( 'Update', 'buddyboss' ),
esc_html__( 'BuddyBoss Platform Pro', 'buddyboss' ),
esc_html__( 'to unlock', 'buddyboss' )
);
} elseif( ! function_exists( 'bb_platform_pro' ) || ! bbp_pro_is_license_valid() ) {
} elseif ( ! function_exists( 'bb_platform_pro' ) || ! bbp_pro_is_license_valid() ) {
$bb_pro_notice = sprintf(
'<br/><span class="bb-head-notice"> %1$s <a target="_blank" href="https://www.buddyboss.com/platform/">%2$s</a> %3$s</span>',
esc_html__( 'Install', 'buddyboss' ),
Expand Down Expand Up @@ -3472,19 +3472,22 @@ function bb_get_pro_fields_class( $type = 'default' ) {
}

if (
! empty( $type ) &&
'reaction' === $type &&
function_exists( 'bb_platform_pro' ) &&
version_compare( bb_platform_pro()->version, '2.4.50', '<' )
) {
$pro_class = 'bb-pro-inactive';
}

if (
! empty( $type ) &&
'schedule_posts' === $type &&
function_exists( 'bb_platform_pro' ) &&
version_compare( bb_platform_pro()->version, bb_pro_schedule_posts_version(), '<' )
(
(
'reaction' === $type &&
version_compare( bb_platform_pro()->version, '2.4.50', '<' )
) ||
(
'schedule_posts' === $type &&
version_compare( bb_platform_pro()->version, bb_pro_schedule_posts_version(), '<' )
) ||
(
'polls' === $type &&
version_compare( bb_platform_pro()->version, bb_pro_poll_version(), '<' )
)
)
) {
$pro_class = 'bb-pro-inactive';
}
Expand Down
27 changes: 24 additions & 3 deletions src/bp-core/admin/settings/bp-admin-setting-activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ function ( $post_type ) {

public function register_fields() {

$pro_class = bb_get_pro_fields_class( 'schedule_posts' );

$this->add_section( 'bp_activity', __( 'Activity Settings', 'buddyboss' ), '', 'bp_activity_settings_tutorial' );

// Allow Activity edit setting.
Expand All @@ -87,6 +85,15 @@ public function register_fields() {
// Allow scopes/tabs.
$this->add_field( '_bb_enable_activity_pinned_posts', __( 'Pinned Post', 'buddyboss' ), 'bb_admin_setting_callback_enable_activity_pinned_posts', 'intval' );

// Allow Poll.
$polls_pro_class = bb_get_pro_fields_class( 'polls' );
$polls_notice = bb_get_pro_label_notice( 'polls' );
$poll_args = array();
$poll_args['class'] = esc_attr( $polls_pro_class );
$poll_args['notice'] = $polls_notice;
$this->add_field( '_bb_enable_activity_post_polls', __( 'Polls', 'buddyboss' ) . $polls_notice, array( $this, 'bb_admin_setting_callback_enable_activity_post_polls' ), 'intval', $poll_args );

$pro_class = bb_get_pro_fields_class( 'schedule_posts' );
$args = array();
$args['class'] = esc_attr( $pro_class );

Expand Down Expand Up @@ -385,7 +392,21 @@ public function bb_admin_setting_callback_enable_activity_schedule_posts() {
$notice = bb_get_pro_label_notice( 'schedule_posts' );
?>
<input id="bb_enable_activity_schedule_posts" name="<?php echo empty( $notice ) ? '_bb_enable_activity_schedule_posts' : ''; ?>" type="checkbox" value="1" <?php echo empty( $notice ) ? checked( $val, true, false ) : ''; ?> />
<label for="bb_enable_activity_schedule_posts"><?php esc_html_e( 'Allow Group Organizers and Moderators to schedule their posts', 'buddyboss' ); ?></label>
<label for="bb_enable_activity_schedule_posts"><?php esc_html_e( 'Allow group owners and moderators to schedule their posts', 'buddyboss' ); ?></label>
<?php
}

/**
* Allow activity poll.
*
* @since BuddyBoss [BBVERSION]
*/
public function bb_admin_setting_callback_enable_activity_post_polls( $args ) {
$val = function_exists( 'bb_is_enabled_activity_post_polls' ) ? bb_is_enabled_activity_post_polls( false ) : false;
$notice = ! empty( $args['notice'] ) ? $args['notice'] : '';
?>
<input id="bb_enable_activity_post_polls" name="<?php echo empty( $notice ) ? '_bb_enable_activity_post_polls' : ''; ?>" type="checkbox" value="1" <?php echo empty( $notice ) ? checked( $val, true, false ) : ''; ?> />
<label for="bb_enable_activity_post_polls"><?php esc_html_e( 'Allow group owners and moderators to post polls', 'buddyboss' ); ?></label>
<?php
}
}
Expand Down
11 changes: 11 additions & 0 deletions src/bp-core/bp-core-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -9878,3 +9878,14 @@ function bb_remove_deleted_user_last_activities() {
$wpdb->query( $delete_query ); // phpcs:ignore
}
}

/**
* Function to return the minimum pro version to show notice for poll.
*
* @since BuddyBoss 2.6.10
*
* @return string
*/
function bb_pro_poll_version() {
return '2.5.91'; // @todo: update when release.
}
8 changes: 7 additions & 1 deletion src/bp-core/classes/class-bp-email-tokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -2125,7 +2125,13 @@ function_exists( 'bp_use_embed_in_activity' ) &&
}
?>
</div>
<?php echo $this->get_email_media( $activity->id, $tokens ); ?>
<?php
$poll_id = bp_activity_get_meta( $activity->id, 'bb_poll_id' );
if ( ! empty( $poll_id ) && function_exists( 'get_email_poll' ) ) {
echo get_email_poll( $activity->id, $poll_id, $tokens );
}
echo $this->get_email_media( $activity->id, $tokens );
?>
</td>
</tr>
<tr>
Expand Down
3 changes: 3 additions & 0 deletions src/bp-notifications/bp-notifications-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1393,6 +1393,7 @@ function bb_get_notification_conditional_icon( $notification ) {
$video_ids = $activity_metas['bp_video_ids'][0] ?? '';
$gif_data = ! empty( $activity_metas['_gif_data'][0] ) ? maybe_unserialize( $activity_metas['_gif_data'][0] ) : array();
$excerpt = wp_strip_all_tags( $activity->content );
$bb_poll_id = $activity_metas['bb_poll_id'][0] ?? '';

if ( '&nbsp;' === $excerpt ) {
$excerpt = '';
Expand All @@ -1419,6 +1420,8 @@ function bb_get_notification_conditional_icon( $notification ) {
$icon_class = 'bb-icon-f bb-icon-video';
} elseif ( ! empty( $gif_data ) ) {
$icon_class = 'bb-icon-f bb-icon-activity';
} elseif ( ! empty( $bb_poll_id ) ) {
$icon_class = 'bb-icon-f bb-icon-poll';
} else {
$icon_class = 'bb-icon-f bb-icon-activity';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<span class="bp-item-name">{{data.name}}</span>

<span class="bb-radio-style privacy-radio <# if ( data.selected ) { #>selected<# } #>">
<input type="radio" id="bp-item-opt-{{data.id}}" class="bp-activity-object__radio" name="group-privacy" data-title="{{data.name}}" data-id="{{data.id}}" <# if ( data.allow_schedule ) { #> data-allow-schedule-post="{{data.allow_schedule}}" <# } #> value="opt-value-{{data.id}}" <# if ( data.selected ) { #> checked <# } #>><span></span>
<input type="radio" id="bp-item-opt-{{data.id}}" class="bp-activity-object__radio" name="group-privacy" data-title="{{data.name}}" data-id="{{data.id}}" <# if ( data.allow_schedule ) { #> data-allow-schedule-post="{{data.allow_schedule}}" <# } #> <# if ( data.allow_polls ) { #> data-allow-polls="{{data.allow_polls}}" <# } #> value="opt-value-{{data.id}}" <# if ( data.selected ) { #> checked <# } #>><span></span>
</span>
</label>
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@
?>
<script type="text/html" id="tmpl-whats-new-toolbar">

<?php if ( bp_is_active( 'media' ) && ( ( bp_is_activity_directory() && ( bp_is_profile_media_support_enabled() || bp_is_group_media_support_enabled() ) ) || ( bp_is_user_activity() && bp_is_profile_media_support_enabled() ) || ( bp_is_group_activity() && bp_is_group_media_support_enabled() ) ) ) : ?>
<?php

/**
* Fires at the beginning of the whats new toolbar.
*
* @since BuddyBoss [BBVERSION]
*/
do_action( 'bb_whats_new_toolbar_before' );

if ( bp_is_active( 'media' ) && ( ( bp_is_activity_directory() && ( bp_is_profile_media_support_enabled() || bp_is_group_media_support_enabled() ) ) || ( bp_is_user_activity() && bp_is_profile_media_support_enabled() ) || ( bp_is_group_activity() && bp_is_group_media_support_enabled() ) ) ) : ?>
<div class="post-elements-buttons-item post-media media-support">
<a href="#" id="activity-media-button" class="toolbar-button bp-tooltip" data-bp-tooltip-pos="up-left" data-bp-tooltip="<?php esc_attr_e( 'Attach photo', 'buddyboss' ); ?>">
<i class="bb-icon-l bb-icon-camera"></i>
Expand Down Expand Up @@ -46,5 +55,13 @@
<div class="gif-media-search-dropdown"></div>
</div>
</div>
<?php endif; ?>
<?php endif;

/**
* Fires at the end of the whats new toolbar.
*
* @since BuddyBoss [BBVERSION]
*/
do_action( 'bb_whats_new_toolbar_after' );
?>
</script>
2 changes: 2 additions & 0 deletions src/bp-templates/bp-nouveau/includes/activity/ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,8 @@ function bp_nouveau_ajax_post_update() {
$toolbar_option = true;
} elseif ( bp_is_active( 'video' ) && ! empty( $_POST['video'] ) ) {
$toolbar_option = true;
} elseif ( ! empty( sanitize_text_field( wp_unslash( (int) $_POST['poll_id'] ) ) ) ) {
$toolbar_option = true;
}

if ( ! $toolbar_option ) {
Expand Down
12 changes: 9 additions & 3 deletions src/bp-templates/bp-nouveau/includes/groups/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -482,12 +482,18 @@ function bp_nouveau_prepare_group_for_js( $item ) {
'group_video' => ( bp_is_active( 'video' ) && bp_is_group_video_support_enabled() && bb_video_user_can_upload( bp_loggedin_user_id(), $item->id ) ),
);

$val = function_exists( 'bb_is_enabled_activity_schedule_posts_filter' ) ? bb_is_enabled_activity_schedule_posts_filter() : false;
if ( $val ) {
$allow_schedule = function_exists( 'bb_is_enabled_activity_schedule_posts_filter' ) ? bb_is_enabled_activity_schedule_posts_filter() : false;
$allow_polls = function_exists( 'bb_is_enabled_activity_post_polls' ) ? bb_is_enabled_activity_post_polls( false ) : false;
if ( $allow_schedule || $allow_polls ) {
$is_admin = groups_is_user_admin( bp_loggedin_user_id(), $item->id );
$is_mod = groups_is_user_mod( bp_loggedin_user_id(), $item->id );
if ( $is_admin || $is_mod ) {
$args['allow_schedule'] = 'enabled';
if ( $allow_schedule ) {
$args['allow_schedule'] = 'enabled';
}
if ( $allow_polls ) {
$args['allow_polls'] = 'enabled';
}
if ( bp_is_active( 'activity' ) && bp_is_activity_directory() ) {
$args['group_url'] = trailingslashit( bp_get_group_permalink( $item ) . bp_get_activity_slug() );
}
Expand Down
Loading