allow to edit topics by anonymous users.

This commit is contained in:
CBS Information System 2020-12-21 18:39:23 +09:00
parent 8ef58cad2d
commit c324c37e7a
2 changed files with 23 additions and 1 deletions

View File

@ -515,6 +515,16 @@ function cbsonline_wpforo_edit_topic_data_filter($args)
return $args; return $args;
} }
// - allow to edit topics by anonymous user
add_action('wpforo_start_edit_topic', 'cbsonline_wpforo_start_edit_topic');
function cbsonline_wpforo_start_edit_topic($args)
{
if (!is_user_logged_in()) {
if ($topic = WPF()->topic->get_topic($args['topicid'])) {
WPF()->current_user_email = $topic['email'];
}
}
}
// - allow to delete topics by anonymous user // - allow to delete topics by anonymous user
add_action('wp_ajax_nopriv_wpforo_delete_ajax', 'cbsonline_wpforo_nopriv_delete'); add_action('wp_ajax_nopriv_wpforo_delete_ajax', 'cbsonline_wpforo_nopriv_delete');
function cbsonline_wpforo_nopriv_delete() function cbsonline_wpforo_nopriv_delete()

View File

@ -35,6 +35,7 @@
}else{ }else{
$buttons = array( 'report', 'delete', 'link' ); $buttons = array( 'report', 'delete', 'link' );
} }
wpforo_post_buttons( 'icon-text', $buttons, $forum, $topic, $post );
if (!is_user_logged_in()) { if (!is_user_logged_in()) {
$forumid = (isset($forum['forumid'])) ? $forum['forumid'] : 0; $forumid = (isset($forum['forumid'])) ? $forum['forumid'] : 0;
$topicid = (isset($topic['topicid'])) ? $topic['topicid'] : 0; $topicid = (isset($topic['topicid'])) ? $topic['topicid'] : 0;
@ -48,7 +49,6 @@
echo '<span wpf-tooltip="'.esc_attr(wpforo_phrase('Delete', false)).'" id="'.esc_attr($a.$b).'" class="wpf-action wpforo-delete"><i class="fas fa-trash-alt wpfsx"></i><span class="wpf-button-text">'.wpforo_phrase('Delete', false).'</span></span>'; echo '<span wpf-tooltip="'.esc_attr(wpforo_phrase('Delete', false)).'" id="'.esc_attr($a.$b).'" class="wpf-action wpforo-delete"><i class="fas fa-trash-alt wpfsx"></i><span class="wpf-button-text">'.wpforo_phrase('Delete', false).'</span></span>';
} }
} }
wpforo_post_buttons( 'icon-text', $buttons, $forum, $topic, $post );
?> ?>
</div> </div>
<?php wpforo_share_toggle($post_url, $post['body'], 'top'); ?> <?php wpforo_share_toggle($post_url, $post['body'], 'top'); ?>
@ -64,6 +64,18 @@
<?php <?php
$buttons = array( 'reply', 'quote', 'approved', 'edit', 'like' ); $buttons = array( 'reply', 'quote', 'approved', 'edit', 'like' );
wpforo_post_buttons( 'icon-text', $buttons, $forum, $topic, $post ); wpforo_post_buttons( 'icon-text', $buttons, $forum, $topic, $post );
if (!is_user_logged_in() && isset($post['email']) && !wpforo_is_owner($post['userid'], $post['email'])) {
$forumid = (isset($forum['forumid'])) ? $forum['forumid'] : 0;
$topicid = (isset($topic['topicid'])) ? $topic['topicid'] : 0;
$is_topic = (bool) wpfval($post, 'is_first_post');
$diff = current_time( 'timestamp', 1 ) - strtotime($post['created']);
if (WPF()->perm->forum_can(($is_topic ? 'eot' : 'eor' ), $forumid)
&& $diff < WPF()->post->options[($is_topic ? 'eot' : 'eor').'_durr']) {
$a = ( $is_topic ) ? 'wpfedittopicpid' : '';
$b = ( $is_topic ) ? $topicid : $postid;
echo '<span wpf-tooltip="'.esc_attr(wpforo_phrase('Edit', false)).'" id="'.esc_attr($a.$b).'" class="wpforo-edit wpf-action"><i class="fas fa-edit wpfsx"></i><span class="wpf-button-text">'.wpforo_phrase('Edit', false).'</span></span>';
}
}
?> ?>
<?php if($post['status']): ?> <?php if($post['status']): ?>
<span class="wpf-mod-message"><i class="fas fa-exclamation-circle" aria-hidden="true"></i> <?php wpforo_phrase('Awaiting moderation') ?></span> <span class="wpf-mod-message"><i class="fas fa-exclamation-circle" aria-hidden="true"></i> <?php wpforo_phrase('Awaiting moderation') ?></span>