From af9a91d24059ac443f8a80d48dc046ce9fa5fa5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Guimara=CC=83es?= Date: Thu, 8 Feb 2018 16:23:02 -0200 Subject: [PATCH 01/45] Removes unused code and some else refactors --- .../rhs/assets/js/valida-form-registro.js | 18 +++--------------- public/wp-content/themes/rhs/functions.php | 1 - .../wp-content/themes/rhs/inc/email/email.php | 4 +--- .../themes/rhs/inc/search/search.php | 1 - .../themes/rhs/inc/ticket/ticket.php | 2 -- public/wp-content/themes/rhs/inc/vote/vote.php | 2 -- .../wp-content/themes/rhs/inc/vote/widget.php | 2 -- 7 files changed, 4 insertions(+), 26 deletions(-) diff --git a/public/wp-content/themes/rhs/assets/js/valida-form-registro.js b/public/wp-content/themes/rhs/assets/js/valida-form-registro.js index b9db7dc9..3625f9bb 100644 --- a/public/wp-content/themes/rhs/assets/js/valida-form-registro.js +++ b/public/wp-content/themes/rhs/assets/js/valida-form-registro.js @@ -44,11 +44,7 @@ jQuery( function( $ ) { hiddenRecaptcha: { required: function () { - if (grecaptcha.getResponse() == '') { - return true; - } else { - return false; - } + return grecaptcha.getResponse() == ''; } } }, @@ -211,11 +207,7 @@ jQuery( function( $ ) { }, hiddenRecaptcha: { required: function () { - if (grecaptcha.getResponse() == '') { - return true; - } else { - return false; - } + return grecaptcha.getResponse() == ''; } } }, @@ -522,11 +514,7 @@ jQuery( function( $ ) { }, hiddenRecaptcha: { required: function () { - if (grecaptcha.getResponse() == '') { - return true; - } else { - return false; - } + return grecaptcha.getResponse() == ''; } } }, diff --git a/public/wp-content/themes/rhs/functions.php b/public/wp-content/themes/rhs/functions.php index e87c1976..9e4f4608 100644 --- a/public/wp-content/themes/rhs/functions.php +++ b/public/wp-content/themes/rhs/functions.php @@ -470,7 +470,6 @@ function walk( $elements, $max_depth, $args = array() ) { Ex: limitatexto(CONTENT, '[...]', TAMANHO); */ function limitatexto($texto, $final, $limite){ - $result = $texto; $len_texto = strlen($texto); $len_final = strlen($final); diff --git a/public/wp-content/themes/rhs/inc/email/email.php b/public/wp-content/themes/rhs/inc/email/email.php index babefe54..f7c39252 100644 --- a/public/wp-content/themes/rhs/inc/email/email.php +++ b/public/wp-content/themes/rhs/inc/email/email.php @@ -217,8 +217,6 @@ function filter_retrieve_password_request_email_body($message, $key, $user_login 'link' => network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user_login )) ); - $message = $this->get_message('retrieve_password_message', $args); - return $this->get_message('retrieve_password_message', $args); } @@ -331,7 +329,7 @@ function comment_post($comment){ } /* - * Envia um email ao seguidor do post por ter recebido um novo comentario. + * Envia um email ao seguidor do post por ter recebido um novo comentário. */ function comment_post_follow($comment){ $follow = new RHSFollowPost(); diff --git a/public/wp-content/themes/rhs/inc/search/search.php b/public/wp-content/themes/rhs/inc/search/search.php index d93abd91..c47fbc59 100644 --- a/public/wp-content/themes/rhs/inc/search/search.php +++ b/public/wp-content/themes/rhs/inc/search/search.php @@ -393,7 +393,6 @@ public function search_users($params = array()) { break; default: - $q_order = 'ASC';; $q_order_by = 'display_name'; $q_order = 'ASC'; break; diff --git a/public/wp-content/themes/rhs/inc/ticket/ticket.php b/public/wp-content/themes/rhs/inc/ticket/ticket.php index 837364e1..cc142950 100644 --- a/public/wp-content/themes/rhs/inc/ticket/ticket.php +++ b/public/wp-content/themes/rhs/inc/ticket/ticket.php @@ -69,8 +69,6 @@ function register_post_status() { function add_status_dropdown() { global $post; - $complete = ''; - $label = ''; if ( $post->post_type == self::POST_TYPE ) { $js = ''; diff --git a/public/wp-content/themes/rhs/inc/vote/vote.php b/public/wp-content/themes/rhs/inc/vote/vote.php index 47ff353b..c5e23fae 100644 --- a/public/wp-content/themes/rhs/inc/vote/vote.php +++ b/public/wp-content/themes/rhs/inc/vote/vote.php @@ -299,8 +299,6 @@ function fila_query( $wp_query ) { function add_status_dropdown() { global $post; - $complete = ''; - $label = ''; if ( $post->post_type == 'post' ) { $js = ''; diff --git a/public/wp-content/themes/rhs/inc/vote/widget.php b/public/wp-content/themes/rhs/inc/vote/widget.php index e6b85884..db90f27f 100644 --- a/public/wp-content/themes/rhs/inc/vote/widget.php +++ b/public/wp-content/themes/rhs/inc/vote/widget.php @@ -16,8 +16,6 @@ public function widget( $args, $instance ) { return; } $title = apply_filters( 'widget_title', __('Fila de votação') ); - $blog_title = get_bloginfo( 'name' ); - $tagline = get_bloginfo( 'description' ); echo $args['before_widget'] . $args['before_title'] .''. $title .''. $args['after_title']; From e9e128498036300889ec4310d8ad3dd71ed7fe0b Mon Sep 17 00:00:00 2001 From: Pedro Naves Date: Fri, 16 Feb 2018 10:31:27 -0200 Subject: [PATCH 02/45] =?UTF-8?q?criando=20=C3=A1rea=20para=20pr=C3=B3prio?= =?UTF-8?q?=20usu=C3=A1rio=20excluir=20e=20realizar=20backup=20de=20conta?= =?UTF-8?q?=20(ref.=20#102)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../themes/rhs/inc/perfil/perfil.php | 141 ++++++++++++++++++ .../wp-content/themes/rhs/inc/user/user.php | 7 + public/wp-content/themes/rhs/perfil.php | 10 ++ 3 files changed, 158 insertions(+) diff --git a/public/wp-content/themes/rhs/inc/perfil/perfil.php b/public/wp-content/themes/rhs/inc/perfil/perfil.php index 8b6e98db..2161f8e4 100644 --- a/public/wp-content/themes/rhs/inc/perfil/perfil.php +++ b/public/wp-content/themes/rhs/inc/perfil/perfil.php @@ -7,6 +7,17 @@ class RHSPerfil extends RHSMessage { function __construct($userID) { $this->userID = $userID; + add_action('wp_enqueue_scripts', array(&$this, 'addJS'), 2); + add_action('wp_ajax_generate_backup_file', array($this, 'generate_backup_file')); + add_action('wp_ajax_nopriv_generate_backup_file', array($this,'generate_backup_file')); + add_action('wp_ajax_delete_my_account', array($this, 'delete_my_account')); + add_action('wp_ajax_nopriv_delete_my_account', array($this,'delete_my_account')); + } + + + function addJS() { + wp_enqueue_script('rhs_profile', get_template_directory_uri() . '/inc/perfil/perfil.js', array('jquery')); + wp_localize_script('rhs_profile', 'user_vars', array('ajaxurl' => admin_url('admin-ajax.php'))); } function getUserId(){ @@ -232,6 +243,136 @@ private function validate_by_post() { return true; } + + function show_box_to_delete_profile($user_id){ + echo ""; + } + + public static function generate_backup_file() { + global $wp_query; + global $wpdb; + global $RHSVote; + global $RHSNetwork; + global $RHSSearch; + + header('Content-Type: application/vnd.ms-excel'); + header('Pragma: no-cache'); + header('Expires: 0'); + + $args = array( + 'author' => get_current_user_id(), + 'orderby' => 'post_date', + 'order' => 'ASC', + 'posts_per_page' => -1 + ); + + $content_file = get_posts($args); + + foreach($content_file as $post) { + $get_title = html_entity_decode(get_the_title($post->ID), ENT_QUOTES, "UTF-8"); + + $raw_content = get_post_field('post_content', $post->ID); + $post_content = iconv( "utf-8", "utf-8", $raw_content ); + $post_content = strip_html_tags( $post_content ); + $post_content = html_entity_decode($post_content, ENT_QUOTES, "UTF-8"); + + $get_date = get_the_date('d/m/Y H:i:s', $post->ID); + $get_author = get_the_author_meta('user_firstname', $post->post_author) . " " . get_the_author_meta('user_lastname', $post->post_author); + $get_link = $post->guid; + $get_views = $RHSNetwork->get_post_total_views($post->ID); + $get_shares = $RHSNetwork->get_post_total_shares($post->ID); + $get_comments = wp_count_comments($post->ID); + $get_votes = $RHSVote->get_total_votes($post->ID); + + $views = return_value_or_zero($get_views); + $shares = return_value_or_zero($get_shares); + $votes = return_value_or_zero($get_votes); + $comments = return_value_or_zero($get_comments); + + $post_ufmun = get_post_ufmun($post->ID); + $uf = $post_ufmun['uf']['sigla']; + $mun = $post_ufmun['mun']['nome']; + + $row_data[] = [ + 'titulo'=> $get_title, + 'conteudo' => $post_content, + 'data'=> $get_date, + 'autor' => $get_author, + 'link' => $get_link, + 'visualizacoes' => $views, + 'compartilhamentos' => $shares, + 'votos' => $votes, + 'comentarios' => $comments, + 'estado' => return_value_or_dash($uf), + 'cidade' => return_value_or_dash($mun) + ]; + } + + $head_table .= " + + + + + + + + + + + + + + + + "; + + foreach ($row_data as $row) { + $row_table .= " + + + + + + + + + + + + "; + } + + $footer_table = "
TítuloConteúdoDataAutorLinkVisualizaçõesCompartilhamentosVotosComentáriosEstadoCidade
" . $row['titulo'] . "" . $row['conteudo'] . "" . $row['data'] . "" . $row['autor'] . "" . $row['link'] . "" . $row['visualizacoes'] . "" . $row['compartilhamentos'] . "" . $row['votos'] . "" . $row['comentarios'] . "" . $row['estado'] . "" . $row['cidade'] . "
"; + + $file = $head_table . $row_table . $footer_table; + + mb_convert_encoding($file, 'UTF-16LE', 'UTF-8'); + echo $file; + } + + public static function delete_my_account() { + $user_id = get_current_user_id(); + $meta = get_user_meta($user_id); + $send_to_legacy_user = $_POST['send_to_legacy_user']; + $legacy_user_id = 1; + + // Remove meta de usuários + foreach ($meta as $key => $val) { + delete_user_meta($user_id, $key); + } + + // Desloga usuário + wp_logout(); + + // Remove usuário + if($send_to_legacy_user == 'true') { + $deleted = wp_delete_user($user_id); + } else { + $deleted = wp_delete_user($user_id, $legacy_user_id); + } + + } + } global $RHSPerfil; diff --git a/public/wp-content/themes/rhs/inc/user/user.php b/public/wp-content/themes/rhs/inc/user/user.php index 072a8af8..b0245081 100644 --- a/public/wp-content/themes/rhs/inc/user/user.php +++ b/public/wp-content/themes/rhs/inc/user/user.php @@ -391,4 +391,11 @@ class="btn btn-info js-add-link"> '; } + + + + + + + } \ No newline at end of file diff --git a/public/wp-content/themes/rhs/perfil.php b/public/wp-content/themes/rhs/perfil.php index 6005d6d9..c6159dce 100644 --- a/public/wp-content/themes/rhs/perfil.php +++ b/public/wp-content/themes/rhs/perfil.php @@ -191,6 +191,16 @@ class="form-control" type="text" id="first_name" show_user_links_to_edit($RHSUser->get_id());?> + +
+
+

Excluir Conta

+
+
+ show_box_to_delete_profile($RHSUser->get_id());?> +
+
+
From a64fff51c8d9d42144a444dc40a330a532cc7fea Mon Sep 17 00:00:00 2001 From: Pedro Naves Date: Fri, 16 Feb 2018 13:59:09 -0200 Subject: [PATCH 03/45] =?UTF-8?q?adicionando=20match=20para=20usu=C3=A1rio?= =?UTF-8?q?=20de=20legado,=20atrav=C3=A9s=20do=20e-mail=20(ref.=20#102)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/wp-content/themes/rhs/assets/scss/style.scss | 4 ++++ public/wp-content/themes/rhs/inc/perfil/perfil.php | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/public/wp-content/themes/rhs/assets/scss/style.scss b/public/wp-content/themes/rhs/assets/scss/style.scss index f44b1131..6b54e8cd 100644 --- a/public/wp-content/themes/rhs/assets/scss/style.scss +++ b/public/wp-content/themes/rhs/assets/scss/style.scss @@ -242,4 +242,8 @@ body { object-fit: cover; object-position: top; } +} + +.extra-small-type { + font-size: 60%; } \ No newline at end of file diff --git a/public/wp-content/themes/rhs/inc/perfil/perfil.php b/public/wp-content/themes/rhs/inc/perfil/perfil.php index 2161f8e4..0a0db695 100644 --- a/public/wp-content/themes/rhs/inc/perfil/perfil.php +++ b/public/wp-content/themes/rhs/inc/perfil/perfil.php @@ -354,7 +354,10 @@ public static function delete_my_account() { $user_id = get_current_user_id(); $meta = get_user_meta($user_id); $send_to_legacy_user = $_POST['send_to_legacy_user']; - $legacy_user_id = 1; + $legacy_user = get_user_by('email', 'legado@redehumanizasus.net'); + if($legacy_user == null) { + $legacy_user = get_user_by('id', 1); + } // Remove meta de usuários foreach ($meta as $key => $val) { From 426d04520588da51b3c43899cec6224033818c38 Mon Sep 17 00:00:00 2001 From: Pedro Naves Date: Fri, 16 Feb 2018 14:10:19 -0200 Subject: [PATCH 04/45] =?UTF-8?q?corrigindo=20atribui=C3=A7=C3=A3o=20de=20?= =?UTF-8?q?posts=20para=20a=20conta=20(ref.=20#102)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/wp-content/themes/rhs/inc/perfil/perfil.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/wp-content/themes/rhs/inc/perfil/perfil.php b/public/wp-content/themes/rhs/inc/perfil/perfil.php index 0a0db695..384b9b6d 100644 --- a/public/wp-content/themes/rhs/inc/perfil/perfil.php +++ b/public/wp-content/themes/rhs/inc/perfil/perfil.php @@ -369,9 +369,9 @@ public static function delete_my_account() { // Remove usuário if($send_to_legacy_user == 'true') { - $deleted = wp_delete_user($user_id); - } else { $deleted = wp_delete_user($user_id, $legacy_user_id); + } else { + $deleted = wp_delete_user($user_id); } } From 11bcc3972fa9a2ef08746d6184b7a841a771824c Mon Sep 17 00:00:00 2001 From: Pedro Naves Date: Fri, 16 Feb 2018 14:14:20 -0200 Subject: [PATCH 05/45] =?UTF-8?q?corrigindo=20t=C3=ADtulo=20de=20modal=20g?= =?UTF-8?q?erado=20pelo=20sweet=20alert=20(ref.=20#102)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/wp-content/themes/rhs/assets/scss/style.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/public/wp-content/themes/rhs/assets/scss/style.scss b/public/wp-content/themes/rhs/assets/scss/style.scss index 6b54e8cd..fc0b6d27 100644 --- a/public/wp-content/themes/rhs/assets/scss/style.scss +++ b/public/wp-content/themes/rhs/assets/scss/style.scss @@ -165,6 +165,7 @@ body { .sweet-alert{ border-radius: 0px; h2{ + padding-top: 15px; font-size: 17px; } .sa-confirm-button-container{ From 4ca5779f8365d1c32a26c75cb46ea558a4508cad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Guimara=CC=83es?= Date: Thu, 8 Feb 2018 16:23:02 -0200 Subject: [PATCH 06/45] Removes unused code and some else refactors --- .../rhs/assets/js/valida-form-registro.js | 18 +++--------------- public/wp-content/themes/rhs/functions.php | 1 - .../wp-content/themes/rhs/inc/email/email.php | 8 +++----- .../themes/rhs/inc/search/search.php | 1 - .../themes/rhs/inc/ticket/ticket.php | 2 -- public/wp-content/themes/rhs/inc/vote/vote.php | 2 -- .../wp-content/themes/rhs/inc/vote/widget.php | 2 -- 7 files changed, 6 insertions(+), 28 deletions(-) diff --git a/public/wp-content/themes/rhs/assets/js/valida-form-registro.js b/public/wp-content/themes/rhs/assets/js/valida-form-registro.js index b9db7dc9..3625f9bb 100644 --- a/public/wp-content/themes/rhs/assets/js/valida-form-registro.js +++ b/public/wp-content/themes/rhs/assets/js/valida-form-registro.js @@ -44,11 +44,7 @@ jQuery( function( $ ) { hiddenRecaptcha: { required: function () { - if (grecaptcha.getResponse() == '') { - return true; - } else { - return false; - } + return grecaptcha.getResponse() == ''; } } }, @@ -211,11 +207,7 @@ jQuery( function( $ ) { }, hiddenRecaptcha: { required: function () { - if (grecaptcha.getResponse() == '') { - return true; - } else { - return false; - } + return grecaptcha.getResponse() == ''; } } }, @@ -522,11 +514,7 @@ jQuery( function( $ ) { }, hiddenRecaptcha: { required: function () { - if (grecaptcha.getResponse() == '') { - return true; - } else { - return false; - } + return grecaptcha.getResponse() == ''; } } }, diff --git a/public/wp-content/themes/rhs/functions.php b/public/wp-content/themes/rhs/functions.php index e87c1976..9e4f4608 100644 --- a/public/wp-content/themes/rhs/functions.php +++ b/public/wp-content/themes/rhs/functions.php @@ -470,7 +470,6 @@ function walk( $elements, $max_depth, $args = array() ) { Ex: limitatexto(CONTENT, '[...]', TAMANHO); */ function limitatexto($texto, $final, $limite){ - $result = $texto; $len_texto = strlen($texto); $len_final = strlen($final); diff --git a/public/wp-content/themes/rhs/inc/email/email.php b/public/wp-content/themes/rhs/inc/email/email.php index babefe54..4fa528ec 100644 --- a/public/wp-content/themes/rhs/inc/email/email.php +++ b/public/wp-content/themes/rhs/inc/email/email.php @@ -76,7 +76,7 @@ function __construct() { 'default-subject' => '[%site_nome%] Novo Contato #%ticket_id%', 'default-email' => '

Um novo ticket foi criado #%ticket_id%

-

para acompanhar acesse o link: [%link%]

+

para acompanhar acesse o link: %link%

' . $this->mail_footer["topo"] . '

' ), 'new_ticket_replied' => array( @@ -93,7 +93,7 @@ function __construct() { 'default-subject' => '[%site_nome%] Nova resposta #%ticket_id%', 'default-email' => '

Uma nova resposta foi feita no contato de número #%ticket_id%

-

para acompanhar acesse o link: [%link%]

+

para acompanhar acesse o link: %link%

' . $this->mail_footer["topo"] . '

' ), 'new_ticket_replied_not_logged' => array( @@ -217,8 +217,6 @@ function filter_retrieve_password_request_email_body($message, $key, $user_login 'link' => network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user_login )) ); - $message = $this->get_message('retrieve_password_message', $args); - return $this->get_message('retrieve_password_message', $args); } @@ -331,7 +329,7 @@ function comment_post($comment){ } /* - * Envia um email ao seguidor do post por ter recebido um novo comentario. + * Envia um email ao seguidor do post por ter recebido um novo comentário. */ function comment_post_follow($comment){ $follow = new RHSFollowPost(); diff --git a/public/wp-content/themes/rhs/inc/search/search.php b/public/wp-content/themes/rhs/inc/search/search.php index d93abd91..c47fbc59 100644 --- a/public/wp-content/themes/rhs/inc/search/search.php +++ b/public/wp-content/themes/rhs/inc/search/search.php @@ -393,7 +393,6 @@ public function search_users($params = array()) { break; default: - $q_order = 'ASC';; $q_order_by = 'display_name'; $q_order = 'ASC'; break; diff --git a/public/wp-content/themes/rhs/inc/ticket/ticket.php b/public/wp-content/themes/rhs/inc/ticket/ticket.php index 837364e1..cc142950 100644 --- a/public/wp-content/themes/rhs/inc/ticket/ticket.php +++ b/public/wp-content/themes/rhs/inc/ticket/ticket.php @@ -69,8 +69,6 @@ function register_post_status() { function add_status_dropdown() { global $post; - $complete = ''; - $label = ''; if ( $post->post_type == self::POST_TYPE ) { $js = ''; diff --git a/public/wp-content/themes/rhs/inc/vote/vote.php b/public/wp-content/themes/rhs/inc/vote/vote.php index 47ff353b..c5e23fae 100644 --- a/public/wp-content/themes/rhs/inc/vote/vote.php +++ b/public/wp-content/themes/rhs/inc/vote/vote.php @@ -299,8 +299,6 @@ function fila_query( $wp_query ) { function add_status_dropdown() { global $post; - $complete = ''; - $label = ''; if ( $post->post_type == 'post' ) { $js = ''; diff --git a/public/wp-content/themes/rhs/inc/vote/widget.php b/public/wp-content/themes/rhs/inc/vote/widget.php index e6b85884..db90f27f 100644 --- a/public/wp-content/themes/rhs/inc/vote/widget.php +++ b/public/wp-content/themes/rhs/inc/vote/widget.php @@ -16,8 +16,6 @@ public function widget( $args, $instance ) { return; } $title = apply_filters( 'widget_title', __('Fila de votação') ); - $blog_title = get_bloginfo( 'name' ); - $tagline = get_bloginfo( 'description' ); echo $args['before_widget'] . $args['before_title'] .''. $title .''. $args['after_title']; From 744f678f872dca225f02d41ea3f2c8c79831103d Mon Sep 17 00:00:00 2001 From: Pedro Naves Date: Fri, 9 Feb 2018 09:57:33 -0200 Subject: [PATCH 07/45] =?UTF-8?q?criando=20indica=C3=A7=C3=A3o=20de=20post?= =?UTF-8?q?=20(ref.=20#192)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/wp-content/themes/rhs/functions.php | 1 + .../wp-content/themes/rhs/partes-templates/painel-single.php | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/public/wp-content/themes/rhs/functions.php b/public/wp-content/themes/rhs/functions.php index 9e4f4608..59f55270 100644 --- a/public/wp-content/themes/rhs/functions.php +++ b/public/wp-content/themes/rhs/functions.php @@ -48,6 +48,7 @@ function rhs_setup() { require_once('inc/vote/vote.php'); require_once('inc/follow/follow.php'); require_once('inc/follow-post/follow-post.php'); + require_once('inc/recommend-post/recommend-post.php'); require_once('inc/widgets/imgWithLink/image-with-link.php'); require_once('inc/widgets/Facebook_Twitter/facebook_twiter.php'); require_once('inc/widgets/usersWidget/users-widget.php'); diff --git a/public/wp-content/themes/rhs/partes-templates/painel-single.php b/public/wp-content/themes/rhs/partes-templates/painel-single.php index f9aa03b2..554f5211 100644 --- a/public/wp-content/themes/rhs/partes-templates/painel-single.php +++ b/public/wp-content/themes/rhs/partes-templates/painel-single.php @@ -127,6 +127,11 @@
+ + + + +
From bef3a0ba29fa81ff4623b6030985cbfb36bb4a3c Mon Sep 17 00:00:00 2001 From: Pedro Naves Date: Fri, 9 Feb 2018 10:00:12 -0200 Subject: [PATCH 08/45] mend --- .gitignore | 1 - .../rhs/inc/recommend-post/recommend-post.js | 40 +++++++++++ .../rhs/inc/recommend-post/recommend-post.php | 67 +++++++++++++++++++ .../rhs/partes-templates/recommend-post.php | 20 ++++++ 4 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 public/wp-content/themes/rhs/inc/recommend-post/recommend-post.js create mode 100644 public/wp-content/themes/rhs/inc/recommend-post/recommend-post.php create mode 100644 public/wp-content/themes/rhs/partes-templates/recommend-post.php diff --git a/.gitignore b/.gitignore index 57ed2350..3982641b 100644 --- a/.gitignore +++ b/.gitignore @@ -24,7 +24,6 @@ public/wp-content/themes/rhs/assets/scss/style.html public/wp-content/themes/rhs/page-fila-de-votacao.html public/wp-content/themes/rhs/vendor tests/wordpress-tests-lib/wp-tests-config.php -public/wp-content/themes/ !public/wp-content/themes/rhs .travis.yml deploy_rsa.enc diff --git a/public/wp-content/themes/rhs/inc/recommend-post/recommend-post.js b/public/wp-content/themes/rhs/inc/recommend-post/recommend-post.js new file mode 100644 index 00000000..1b147ba7 --- /dev/null +++ b/public/wp-content/themes/rhs/inc/recommend-post/recommend-post.js @@ -0,0 +1,40 @@ +jQuery( function( $ ) { + var input_recommend_post = '#input-recommend-post'; + + $(input_recommend_post).autocomplete({ + serviceUrl: vars.ajaxurl, + type: 'POST', + dataType: 'json', + paramName: 'string', + params : { + action: 'show_people_to_recommend', + }, + minChars: 3, + onSelect: function (suggestion) { + + $.ajax({ + async: false, + type: "POST", + dataType: "json", + url: vars.ajaxurl, + data: { + action: 'recommend_the_post', + user_id: suggestion.data, + post_id: $(input_recommend_post).attr('data-post-id') + }, + success: function (data) { + if (data['messages']) { + var html = ''; + Object.keys(data['messages']).forEach(function(key) { + html += data['messages'][key]; + }); + swal({title: html, html: true}); + } + }, + error: function (data) { + swal({title: data, html: true}); + } + }); + } + }); +}); \ No newline at end of file diff --git a/public/wp-content/themes/rhs/inc/recommend-post/recommend-post.php b/public/wp-content/themes/rhs/inc/recommend-post/recommend-post.php new file mode 100644 index 00000000..fcd22851 --- /dev/null +++ b/public/wp-content/themes/rhs/inc/recommend-post/recommend-post.php @@ -0,0 +1,67 @@ + admin_url('admin-ajax.php'))); + } + + /** + * Busca de usuários para indicar post + */ + function show_people_to_recommend() { + + $data = array('suggestions' => array()); + + $users = new WP_User_Query( array( + 'search' => '*' . esc_attr( $_POST['string'] ) . '*', + 'search_columns' => array( 'user_nicename', 'user_email' ), + 'number' => -1, + 'orderby' => 'display_name', + ) ); + + foreach ( $users->results as $user ) { + + $data['suggestions'][] = array( + 'data' => $user->ID, + 'value' => $user->display_name + ); + } + + echo json_encode( $data ); + exit; + + } + + /** + * Envia indicação de post para usuário + */ + function recommend_the_post() { + + $this->clear_messages(); + + $user = new RHSUser(get_userdata($_POST['user_id'])); + + $data['user'] = array( + 'user_id' => $_POST['user_id'], + 'post_id' => $_POST['post_id'], + ); + + $this->set_messages($user->get_name() . ' recebeu a indicação de leitura', false, 'success'); + + $data['messages'] = $this->messages(); + + echo json_encode($data); + exit; + } +} + +global $RHSRecommendPost; +$RHSRecommendPost = new RHSRecommendPost(); diff --git a/public/wp-content/themes/rhs/partes-templates/recommend-post.php b/public/wp-content/themes/rhs/partes-templates/recommend-post.php new file mode 100644 index 00000000..a823cc54 --- /dev/null +++ b/public/wp-content/themes/rhs/partes-templates/recommend-post.php @@ -0,0 +1,20 @@ +
+
+
+
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+
+
\ No newline at end of file From b62946eff323554068ce325ee46f18ba7c3ba77d Mon Sep 17 00:00:00 2001 From: Pedro Naves Date: Fri, 9 Feb 2018 10:03:16 -0200 Subject: [PATCH 09/45] mend --- .../wp-content/themes/rhs/inc/recommend-post/recommend-post.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/public/wp-content/themes/rhs/inc/recommend-post/recommend-post.js b/public/wp-content/themes/rhs/inc/recommend-post/recommend-post.js index 1b147ba7..b6fe534b 100644 --- a/public/wp-content/themes/rhs/inc/recommend-post/recommend-post.js +++ b/public/wp-content/themes/rhs/inc/recommend-post/recommend-post.js @@ -11,7 +11,6 @@ jQuery( function( $ ) { }, minChars: 3, onSelect: function (suggestion) { - $.ajax({ async: false, type: "POST", @@ -20,7 +19,7 @@ jQuery( function( $ ) { data: { action: 'recommend_the_post', user_id: suggestion.data, - post_id: $(input_recommend_post).attr('data-post-id') + post_id: $(input_recommend_post).data('post-id') }, success: function (data) { if (data['messages']) { From b80ec2650c6200edde09c236241390cbea6a6f2d Mon Sep 17 00:00:00 2001 From: Pedro Naves Date: Fri, 9 Feb 2018 10:26:31 -0200 Subject: [PATCH 10/45] mend --- .../rhs/inc/recommend-post/recommend-post.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/public/wp-content/themes/rhs/inc/recommend-post/recommend-post.php b/public/wp-content/themes/rhs/inc/recommend-post/recommend-post.php index fcd22851..03e661b2 100644 --- a/public/wp-content/themes/rhs/inc/recommend-post/recommend-post.php +++ b/public/wp-content/themes/rhs/inc/recommend-post/recommend-post.php @@ -1,6 +1,8 @@ clear_messages(); + $current_user = wp_get_current_user(); $user = new RHSUser(get_userdata($_POST['user_id'])); - + $user_id = $_POST['user_id']; + $post_id = $_POST['post_id']; + $data['user'] = array( - 'user_id' => $_POST['user_id'], - 'post_id' => $_POST['post_id'], + 'user_id' => $user_id, + 'post_id' => $post_id, + 'recommend_from' => $current_user->ID ); + add_user_meta($user_id, self::RECOMMEND_POST_TO_KEY, $data['user']); + add_user_meta($current_user->ID, self::RECOMMEND_POST_FROM_KEY, $data['user']); + $this->set_messages($user->get_name() . ' recebeu a indicação de leitura', false, 'success'); $data['messages'] = $this->messages(); From 356416c30a367af8992f769c12b831527a2d4583 Mon Sep 17 00:00:00 2001 From: Pedro Naves Date: Fri, 9 Feb 2018 11:14:06 -0200 Subject: [PATCH 11/45] mend --- .../rhs/inc/recommend-post/recommend-post.js | 56 ++++++++++++------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/public/wp-content/themes/rhs/inc/recommend-post/recommend-post.js b/public/wp-content/themes/rhs/inc/recommend-post/recommend-post.js index b6fe534b..42da347e 100644 --- a/public/wp-content/themes/rhs/inc/recommend-post/recommend-post.js +++ b/public/wp-content/themes/rhs/inc/recommend-post/recommend-post.js @@ -11,29 +11,43 @@ jQuery( function( $ ) { }, minChars: 3, onSelect: function (suggestion) { - $.ajax({ - async: false, - type: "POST", - dataType: "json", - url: vars.ajaxurl, - data: { - action: 'recommend_the_post', - user_id: suggestion.data, - post_id: $(input_recommend_post).data('post-id') - }, - success: function (data) { - if (data['messages']) { - var html = ''; - Object.keys(data['messages']).forEach(function(key) { - html += data['messages'][key]; - }); - swal({title: html, html: true}); - } - }, - error: function (data) { - swal({title: data, html: true}); + swal({ + title: "Deseja indicar esse post?", + text: "A indicação será enviada para" + 'Fulano', + type: "info", + showCancelButton: true, + confirmButtonClass: "btn-success", + confirmButtonText: "Sim, enviar!", + cancelButtonText: "Cancelar!", + closeOnConfirm: false, + closeOnCancel: false + }, + function (isConfirm) { + if (isConfirm) { + $.ajax({ + async: false, + type: "POST", + dataType: "json", + url: vars.ajaxurl, + data: { + action: 'recommend_the_post', + user_id: suggestion.data, + post_id: $(input_recommend_post).data('post-id') + }, + success: function (data) { + swal("Enviado!", "Indicação enviada com sucesso.", "success"); + }, + error: function (data) { + swal("Não enviado", "Sua indicação não foi enviada.", "error"); + } + }); + } else { + console.log('não confirmou'); + swal("Cancelado", "Não enviado", "error"); } }); + + return false; } }); }); \ No newline at end of file From 80e5af1619c694db85fd66705354fcd952cfbb3a Mon Sep 17 00:00:00 2001 From: Pedro Naves Date: Fri, 9 Feb 2018 15:50:35 -0200 Subject: [PATCH 12/45] mend --- docs/notifications.md | 2 +- public/wp-content/themes/rhs/functions.php | 3 +- .../rhs/inc/notification/channels-hooks.php | 10 +++ .../notification/registered-notifications.php | 1 + .../inc/notification/types/post_recommend.php | 76 +++++++++++++++++++ .../{recommend-post.js => recommend_post.js} | 7 +- ...{recommend-post.php => recommend_post.php} | 40 ++++++---- .../wp-content/themes/rhs/inc/stats/stats.php | 12 ++- .../rhs/partes-templates/recommend-post.php | 12 +-- 9 files changed, 131 insertions(+), 32 deletions(-) create mode 100644 public/wp-content/themes/rhs/inc/notification/types/post_recommend.php rename public/wp-content/themes/rhs/inc/recommend-post/{recommend-post.js => recommend_post.js} (91%) rename public/wp-content/themes/rhs/inc/recommend-post/{recommend-post.php => recommend_post.php} (57%) diff --git a/docs/notifications.md b/docs/notifications.md index 108379a6..e338508e 100644 --- a/docs/notifications.md +++ b/docs/notifications.md @@ -266,7 +266,7 @@ por exemplo: ``` 'comment_post' => ['comments_in_post'], -'rhs_contact_replied' => ['contact_replied', 10, 3], +'rhs_replied_ticket' => ['replied_ticket', 10, 3], ``` Essa linha indica que o hook `comment_post`, que faz parte do core do WP e é disparado quando um novo comentário é publicado, irá disparar uma notificação do tipo `comments_in_post`. Nesse caso, iria disparar o método `notify` da classe `comments_in_post` que está declarada dentro da pasta `inc/notifications/types`. diff --git a/public/wp-content/themes/rhs/functions.php b/public/wp-content/themes/rhs/functions.php index 59f55270..800d3847 100644 --- a/public/wp-content/themes/rhs/functions.php +++ b/public/wp-content/themes/rhs/functions.php @@ -44,11 +44,12 @@ function rhs_setup() { require_once('inc/notification/types/post_followed.php'); require_once('inc/notification/types/user_follow_author.php'); require_once('inc/notification/types/replied_ticket.php'); + require_once('inc/notification/types/post_recommend.php'); require_once('inc/vote/vote.php'); require_once('inc/follow/follow.php'); require_once('inc/follow-post/follow-post.php'); - require_once('inc/recommend-post/recommend-post.php'); + require_once('inc/recommend-post/recommend_post.php'); require_once('inc/widgets/imgWithLink/image-with-link.php'); require_once('inc/widgets/Facebook_Twitter/facebook_twiter.php'); require_once('inc/widgets/usersWidget/users-widget.php'); diff --git a/public/wp-content/themes/rhs/inc/notification/channels-hooks.php b/public/wp-content/themes/rhs/inc/notification/channels-hooks.php index 9f40c598..645700b1 100644 --- a/public/wp-content/themes/rhs/inc/notification/channels-hooks.php +++ b/public/wp-content/themes/rhs/inc/notification/channels-hooks.php @@ -22,6 +22,8 @@ function __construct() { add_action('rhs_add_user_follow_post', array(&$this, 'rhs_add_user_follow_post')); add_action('rhs_delete_user_follow_post', array(&$this, 'rhs_delete_user_follow_post')); + + add_action('rhs_add_recommend_post', array(&$this, 'rhs_add_recommend_post')); } @@ -90,6 +92,14 @@ function rhs_delete_user_follow_post($args) { global $RHSNotifications; $RHSNotifications->delete_user_from_channel(RHSNotifications::CHANNEL_COMMENTS, $args['post_id'], $args['user_id']); } + + /** + * Quando um post é indicado + */ + function rhs_add_recommend_post($args) { + global $RHSNotifications; + $RHSNotifications->add_user_to_channel(RHSNotifications::CHANNEL_COMMENTS, $args['post_id'], $args['user_id']); + } } diff --git a/public/wp-content/themes/rhs/inc/notification/registered-notifications.php b/public/wp-content/themes/rhs/inc/notification/registered-notifications.php index fb7bcb60..9125a0ea 100644 --- a/public/wp-content/themes/rhs/inc/notification/registered-notifications.php +++ b/public/wp-content/themes/rhs/inc/notification/registered-notifications.php @@ -25,4 +25,5 @@ 'comment_spam_to_approved' => ['comments_in_post'], 'rhs_add_user_follow_author' => ['user_follow_author'], 'rhs_ticket_replied' => ['replied_ticket', 10, 3], + 'rhs_add_recommend_post' => ['post_recommend'] ]; \ No newline at end of file diff --git a/public/wp-content/themes/rhs/inc/notification/types/post_recommend.php b/public/wp-content/themes/rhs/inc/notification/types/post_recommend.php new file mode 100644 index 00000000..22b163ce --- /dev/null +++ b/public/wp-content/themes/rhs/inc/notification/types/post_recommend.php @@ -0,0 +1,76 @@ +add_notification(RHSNotifications::CHANNEL_PRIVATE, $args['user_id'], self::get_name(), $args['post_id'], $current_user->ID); + } + + } + + function text() { + $post = $this->getObjectAsPost(); + if (!$post) + return; + + if($user = $this->getUser()) { + return sprintf( + 'O usuário %s indicou: %s', + $user->get_id(), + $user->get_link(), + $user->get_name(), + $post->ID, + get_permalink($post->ID), + $post->post_title + ); + } + } + + function textPush() { + $post = $this->getObjectAsPost(); + + if (!$post) + return; + + if($user = $this->getUser()) { + return sprintf( + 'O usuário %s indicou o post %s', + $user->get_name(), + $post->post_title + ); + } + + } + + function image(){ + if($user = $this->getUser()) { + return get_avatar_url($user->get_id()); + } + } + + public function buttons() { + $type = $this->getType(); + $buttons[] = (object) array('id' => 'open_' . $type, 'text' => 'Ver Post'); + $buttons[] = (object) array('id' => 'open_user_' . $type, 'text' => 'Ver Usuário'); + + return $buttons; + } + +} diff --git a/public/wp-content/themes/rhs/inc/recommend-post/recommend-post.js b/public/wp-content/themes/rhs/inc/recommend-post/recommend_post.js similarity index 91% rename from public/wp-content/themes/rhs/inc/recommend-post/recommend-post.js rename to public/wp-content/themes/rhs/inc/recommend-post/recommend_post.js index 42da347e..345c9cef 100644 --- a/public/wp-content/themes/rhs/inc/recommend-post/recommend-post.js +++ b/public/wp-content/themes/rhs/inc/recommend-post/recommend_post.js @@ -1,6 +1,6 @@ jQuery( function( $ ) { var input_recommend_post = '#input-recommend-post'; - + $(input_recommend_post).autocomplete({ serviceUrl: vars.ajaxurl, type: 'POST', @@ -13,12 +13,12 @@ jQuery( function( $ ) { onSelect: function (suggestion) { swal({ title: "Deseja indicar esse post?", - text: "A indicação será enviada para" + 'Fulano', + text: "A indicação será enviada para " + suggestion.value, type: "info", showCancelButton: true, confirmButtonClass: "btn-success", confirmButtonText: "Sim, enviar!", - cancelButtonText: "Cancelar!", + cancelButtonText: "Cancelar", closeOnConfirm: false, closeOnCancel: false }, @@ -42,7 +42,6 @@ jQuery( function( $ ) { } }); } else { - console.log('não confirmou'); swal("Cancelado", "Não enviado", "error"); } }); diff --git a/public/wp-content/themes/rhs/inc/recommend-post/recommend-post.php b/public/wp-content/themes/rhs/inc/recommend-post/recommend_post.php similarity index 57% rename from public/wp-content/themes/rhs/inc/recommend-post/recommend-post.php rename to public/wp-content/themes/rhs/inc/recommend-post/recommend_post.php index 03e661b2..7d636c66 100644 --- a/public/wp-content/themes/rhs/inc/recommend-post/recommend-post.php +++ b/public/wp-content/themes/rhs/inc/recommend-post/recommend_post.php @@ -6,13 +6,13 @@ class RHSRecommendPost extends RHSMessage { function __construct() { add_action('wp_enqueue_scripts', array(&$this, 'addJS')); - add_action('wp_ajax_show_people_to_recommend', array( $this, 'show_people_to_recommend' ) ); - add_action('wp_ajax_recommend_the_post', array( $this, 'recommend_the_post' ) ); + add_action('wp_ajax_show_people_to_recommend', array($this, 'show_people_to_recommend')); + add_action('wp_ajax_recommend_the_post', array($this, 'recommend_the_post')); } function addJS() { - wp_enqueue_script('rhs_recommend_post', get_template_directory_uri() . '/inc/recommend-post/recommend-post.js', array('jquery')); - wp_localize_script('rhs_recommend_post', 'recommend_post', array('ajaxurl' => admin_url('admin-ajax.php'))); + wp_enqueue_script('recommend_post', get_template_directory_uri() . '/inc/recommend-post/recommend_post.js', array('jquery')); + wp_localize_script('recommend_post', 'recommend_post', array('ajaxurl' => admin_url('admin-ajax.php'))); } /** @@ -22,14 +22,14 @@ function show_people_to_recommend() { $data = array('suggestions' => array()); - $users = new WP_User_Query( array( + $users = new WP_User_Query(array( 'search' => '*' . esc_attr( $_POST['string'] ) . '*', 'search_columns' => array( 'user_nicename', 'user_email' ), 'number' => -1, 'orderby' => 'display_name', ) ); - foreach ( $users->results as $user ) { + foreach ($users->results as $user) { $data['suggestions'][] = array( 'data' => $user->ID, @@ -37,7 +37,7 @@ function show_people_to_recommend() { ); } - echo json_encode( $data ); + echo json_encode($data); exit; } @@ -57,20 +57,34 @@ function recommend_the_post() { $data['user'] = array( 'user_id' => $user_id, 'post_id' => $post_id, - 'recommend_from' => $current_user->ID + 'recommend_from' => $current_user->ID, + 'value' => $user->display_name ); - add_user_meta($user_id, self::RECOMMEND_POST_TO_KEY, $data['user']); - add_user_meta($current_user->ID, self::RECOMMEND_POST_FROM_KEY, $data['user']); - $this->set_messages($user->get_name() . ' recebeu a indicação de leitura', false, 'success'); $data['messages'] = $this->messages(); + + $this->add_recomment_post($post_id, $user_id, $current_user, $data); echo json_encode($data); exit; } + + function add_recomment_post($post_id, $user_id, $current_user, $data) { + add_user_meta($user_id, self::RECOMMEND_POST_TO_KEY, $data['user']); + $return = add_user_meta($current_user->ID, self::RECOMMEND_POST_FROM_KEY, $data['user']); + + if ($return) + do_action('rhs_add_recommend_post', ['post_id' => $post_id, 'user_id' => $user_id]); + + return $return; + } } -global $RHSRecommendPost; -$RHSRecommendPost = new RHSRecommendPost(); +add_action('init', function() { + global $RHSRecommendPost; + $RHSRecommendPost = new RHSRecommendPost(); +}); + + diff --git a/public/wp-content/themes/rhs/inc/stats/stats.php b/public/wp-content/themes/rhs/inc/stats/stats.php index 6910c30b..ebf9daa7 100644 --- a/public/wp-content/themes/rhs/inc/stats/stats.php +++ b/public/wp-content/themes/rhs/inc/stats/stats.php @@ -14,6 +14,8 @@ class RHSStats { const ACTION_POST_PROMOTED = 'post_promoted'; const ACTION_USER_PROMOTED = 'user_promoted'; const ACTION_SHARE = 'share'; + const ACTION_POST_RECOMMEND = 'post_recommend'; + private $table; @@ -38,9 +40,7 @@ function __construct() { add_action( 'rhs_add_network_data', array( &$this, 'network_data'), 10, 2); add_action( 'rhs_add_user_follow_post', array( &$this, 'post_follow')); add_action( 'rhs_delete_user_follow_post', array( &$this, 'post_unfollow')); - - - + add_action( 'rhs_add_recommend_post', array( &$this, 'recommend_post')); } @@ -75,7 +75,11 @@ function user_promoted($user_id) { function post_promoted($post_id) { $this->add_event(self::ACTION_POST_PROMOTED, $post_id); } - + + function recommend_post($args) { + $this->add_event(self::ACTION_POST_RECOMMEND, $args['post_id'], $args['user_id']); + } + function network_data($post_id, $type) { if ($type == RHSNetwork::META_KEY_VIEW) // não queremos gerar eventos para views return; diff --git a/public/wp-content/themes/rhs/partes-templates/recommend-post.php b/public/wp-content/themes/rhs/partes-templates/recommend-post.php index a823cc54..70484231 100644 --- a/public/wp-content/themes/rhs/partes-templates/recommend-post.php +++ b/public/wp-content/themes/rhs/partes-templates/recommend-post.php @@ -1,15 +1,9 @@
-
-
-
- -
-
-
-
+
-
+

Indicar Post

+
From 2f4283e35c2c73d994cc7999db7f946b832f6931 Mon Sep 17 00:00:00 2001 From: Pedro Naves Date: Fri, 9 Feb 2018 16:10:35 -0200 Subject: [PATCH 13/45] restringindo indicar post para usuarios logados (ref. #192) --- .../wp-content/themes/rhs/partes-templates/painel-single.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/public/wp-content/themes/rhs/partes-templates/painel-single.php b/public/wp-content/themes/rhs/partes-templates/painel-single.php index 554f5211..4a1dc84f 100644 --- a/public/wp-content/themes/rhs/partes-templates/painel-single.php +++ b/public/wp-content/themes/rhs/partes-templates/painel-single.php @@ -127,9 +127,8 @@
- - + Date: Thu, 15 Feb 2018 10:00:42 -0200 Subject: [PATCH 14/45] =?UTF-8?q?adicionando=20teste=20para=20fun=C3=A7?= =?UTF-8?q?=C3=A3o=20de=20recomendar=20post=20(ref.=20#192)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- tests/test-recommend-post.php | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 tests/test-recommend-post.php diff --git a/README.md b/README.md index b46140f7..8c11dd01 100644 --- a/README.md +++ b/README.md @@ -149,7 +149,7 @@ bash compile-sass.sh -> Arquivo que se encontra no diretório do projeto (wp-rhs ### Testes -Abra o arquivo `tests/wordpress-tests-lib/wp-tests-config-sample.php`, edite as informações de conexão com banco de dados e salve o arquivo com o nome `wp-tests-config-sample.php`. +Abra o arquivo `tests/wordpress-tests-lib/wp-tests-config-sample.php`, edite as informações de conexão com banco de dados e salve o arquivo com o nome `wp-tests-config.php`. **Atenção**: Crie uma base de dados separada exclusivamente para os testes. Ela será apagada e recriada cada vez que você rodar os testes. diff --git a/tests/test-recommend-post.php b/tests/test-recommend-post.php new file mode 100644 index 00000000..34a73a79 --- /dev/null +++ b/tests/test-recommend-post.php @@ -0,0 +1,34 @@ +factory->post->create(['post_title' => 'Hit the road Jack!']); + $recommend_to_user = self::$users['contributor'][0]; + $current_user = wp_get_current_user(); + + $data['user'] = array( + 'user_id' => $recommend_to_user, + 'post_id' => $post_id, + 'recommend_from' => $current_user, + 'value' => $current_user->display_name + ); + + $this->assertEquals(0, $RHSRecommendPost->add_recomment_post($post_id, $recommend_to_user, $current_user, $data)); + } + +} From 28c412589d0286c24724a059f90e36ac44f97aaf Mon Sep 17 00:00:00 2001 From: Pedro Naves Date: Thu, 15 Feb 2018 14:30:09 -0200 Subject: [PATCH 15/45] =?UTF-8?q?adicionando=20testes=20para=20notifica?= =?UTF-8?q?=C3=A7=C3=A3o=20de=20recomenda=C3=A7=C3=A3o=20de=20post=20(ref.?= =?UTF-8?q?=20#192)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/notifications.md | 7 +++++-- tests/test-notifications.php | 28 ++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/docs/notifications.md b/docs/notifications.md index e338508e..7051e219 100644 --- a/docs/notifications.md +++ b/docs/notifications.md @@ -78,7 +78,7 @@ Exemplo: | 1 | 51 | false | | 2 | 51 | true | -Esta tabela é alimentada no momento em que vamos checar se h notificações para um determinado usuário. Isso garante que temos uma relação direta entre as notificações e os usuários, que podemos ter um controle das notificações vistas, e que o histórico de notificações é mantido. Por exemplo, se um usuário deixar de acompanhar um canal, ele ainda terá em seu histórico as notificações recebidas naquele canal. +Esta tabela é alimentada no momento em que vamos checar se há notificações para um determinado usuário. Isso garante que temos uma relação direta entre as notificações e os usuários, que podemos ter um controle das notificações vistas, e que o histórico de notificações é mantido. Por exemplo, se um usuário deixar de acompanhar um canal, ele ainda terá em seu histórico as notificações recebidas naquele canal. # Principais métodos @@ -260,7 +260,7 @@ Short description: Novos usuários seguindo seu post No arquivo `inc/notifications/registered-notifications.php` temos a relação dos hooks que geram as notificações. Esses hooks vão disparar o método `notify` do tipo de notificação correspondentes. Este arquivo descreve um `array` onde as chaves são o hook que vão disparar as notificações e os valores são os tipos de notificação que serão gerados. -Eles são informados por um array, onde o primeiro índice é o nome da classe, o segundo é a prioridade do hook e o terceiro é o número de argumentos q o hook vai receber (mesmo formato da função add_action() +Eles são informados por um array, onde o primeiro índice é o nome da classe, o segundo é a prioridade do hook e o terceiro é o número de argumentos que o hook vai receber (mesmo formato da função add_action() por exemplo: @@ -301,6 +301,7 @@ Novo Post de Usuário | open_post_new_post_from_user Novo Post sendo Seguido | rhs_post_followed Contato respondido | rhs_replied_ticket Usuário sendo Seguido| rhs_user_follow_author +Post Indicado | rhs_post_recommend ## Colapso de notificações @@ -349,6 +350,8 @@ Novo Post sendo Seguido | open_user_post_followed | Ver Usuário Contato respondido | open_replied_ticket | Ver Resposta Usuário sendo Seguido | open_user_follow_author | Ver Usuário Post Promovido | open_post_promoted | Ver Post +Post Indicado | open_post_recommend | Ver Post +Post Indicado | open_user_post_recommend | Ver Usuário ## Prioridades diff --git a/tests/test-notifications.php b/tests/test-notifications.php index 50879498..63fb1032 100644 --- a/tests/test-notifications.php +++ b/tests/test-notifications.php @@ -249,5 +249,33 @@ function test_delete_from_channel_and_add_again_should_not_receive_notifications } + function test_recommend_post() { + global $RHSNotifications; + global $RHSRecommendPost; + global $RHSPosts; + + // parametros necessários + $post = self::create_post_to_queue(); + $post_id = $post->getId(); + $recommend_to_user = self::$users['contributor'][0]; + $current_user = wp_set_current_user(self::$users['contributor'][1]); + + $data['user'] = array( + 'user_id' => $recommend_to_user, + 'post_id' => $post_id, + 'recommend_from' => $current_user, + 'value' => $current_user->display_name + ); + + // post é recomendado + $RHSRecommendPost->add_recomment_post($post_id, $recommend_to_user, $current_user, $data); + + // registrando notificação em canal + $this->assertEquals(1, $RHSNotifications->get_news_number($recommend_to_user)); + $this->assertEquals($post_id, $RHSNotifications->get_news($recommend_to_user)[0]->getObjectId()); + $this->assertEquals($current_user->ID, $RHSNotifications->get_news($recommend_to_user)[0]->getUserId()); + + } + } From 9f9650236910a689e341ee239f20c0401c45d5de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Guimara=CC=83es?= Date: Mon, 19 Feb 2018 23:55:07 -0300 Subject: [PATCH 16/45] Just improves final user's response checks --- .../themes/rhs/assets/js/functions.js | 1 - .../themes/rhs/inc/comments/comments.js | 2 +- .../rhs/inc/recommend-post/recommend_post.js | 15 ++++++--- .../rhs/inc/recommend-post/recommend_post.php | 33 ++++++++++--------- 4 files changed, 30 insertions(+), 21 deletions(-) diff --git a/public/wp-content/themes/rhs/assets/js/functions.js b/public/wp-content/themes/rhs/assets/js/functions.js index ed7b560e..b71bb454 100644 --- a/public/wp-content/themes/rhs/assets/js/functions.js +++ b/public/wp-content/themes/rhs/assets/js/functions.js @@ -23,7 +23,6 @@ jQuery( function( $ ) { } $('#carousel-example-generic').on('slid.bs.carousel', function(event) { - //console.log(event); var item = $('#' + event.currentTarget.id).find('div.item.active'); if (item) { var itemNumber = item.data('carousel-item'); diff --git a/public/wp-content/themes/rhs/inc/comments/comments.js b/public/wp-content/themes/rhs/inc/comments/comments.js index 7104de83..74f2807b 100644 --- a/public/wp-content/themes/rhs/inc/comments/comments.js +++ b/public/wp-content/themes/rhs/inc/comments/comments.js @@ -88,7 +88,7 @@ function validateEditableComments(url,comment_ID,comment_content){ }); function changeButton(response){ - console.log('entrou change button'); + // console.log('entrou change button'); }; var error_handler = function(xhr, textStatus, error){ diff --git a/public/wp-content/themes/rhs/inc/recommend-post/recommend_post.js b/public/wp-content/themes/rhs/inc/recommend-post/recommend_post.js index 345c9cef..19f13047 100644 --- a/public/wp-content/themes/rhs/inc/recommend-post/recommend_post.js +++ b/public/wp-content/themes/rhs/inc/recommend-post/recommend_post.js @@ -23,6 +23,7 @@ jQuery( function( $ ) { closeOnCancel: false }, function (isConfirm) { + var not_sent_title = "Não enviado!"; if (isConfirm) { $.ajax({ async: false, @@ -34,15 +35,21 @@ jQuery( function( $ ) { user_id: suggestion.data, post_id: $(input_recommend_post).data('post-id') }, - success: function (data) { - swal("Enviado!", "Indicação enviada com sucesso.", "success"); + success: function (data) { + if(data.msgErr) { + swal(not_sent_title, data.msgErr, "error"); + } else if(data.messages.success && data.user.sent_name) { + swal("Enviado!", "Indicação enviada com sucesso para " + data.user.sent_name, "success"); + } else { + swal(not_sent_title, "Tente novamente mais tarde!", "error"); + } }, error: function (data) { - swal("Não enviado", "Sua indicação não foi enviada.", "error"); + swal(not_sent_title, "Sua indicação não foi enviada.", "error"); } }); } else { - swal("Cancelado", "Não enviado", "error"); + swal("Cancelado", not_sent_title, "error"); } }); diff --git a/public/wp-content/themes/rhs/inc/recommend-post/recommend_post.php b/public/wp-content/themes/rhs/inc/recommend-post/recommend_post.php index 7d636c66..f21bfab1 100644 --- a/public/wp-content/themes/rhs/inc/recommend-post/recommend_post.php +++ b/public/wp-content/themes/rhs/inc/recommend-post/recommend_post.php @@ -50,22 +50,25 @@ function recommend_the_post() { $this->clear_messages(); $current_user = wp_get_current_user(); - $user = new RHSUser(get_userdata($_POST['user_id'])); + $user_id = $_POST['user_id']; - $post_id = $_POST['post_id']; - - $data['user'] = array( - 'user_id' => $user_id, - 'post_id' => $post_id, - 'recommend_from' => $current_user->ID, - 'value' => $user->display_name - ); - - $this->set_messages($user->get_name() . ' recebeu a indicação de leitura', false, 'success'); - - $data['messages'] = $this->messages(); - - $this->add_recomment_post($post_id, $user_id, $current_user, $data); + $user = new RHSUser(get_userdata($user_id)); + if($user instanceof RHSUser) { + $post_id = $_POST['post_id']; + $_user_name = $user->get_name(); + $data['user'] = array( + 'user_id' => $user_id, + 'post_id' => $post_id, + 'recommend_from' => $current_user->ID, + 'value' => $user->display_name, + 'sent_name' => $_user_name + ); + $this->set_messages($_user_name . ' recebeu a indicação de leitura', false, 'success'); + $data['messages'] = $this->messages(); + $this->add_recomment_post($post_id, $user_id, $current_user, $data); + } else { + $data['msgErr'] = "Usuário não encontrado. Tente novamente mais tarde!"; + } echo json_encode($data); exit; From 97d918093211b2f86e77ef216bbaf2273993b9bf Mon Sep 17 00:00:00 2001 From: Pedro Naves Date: Tue, 20 Feb 2018 15:24:24 -0300 Subject: [PATCH 17/45] =?UTF-8?q?enviando=20arquivo=20para=20exclus=C3=A3o?= =?UTF-8?q?=20de=20conta?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../themes/rhs/inc/perfil/perfil.js | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 public/wp-content/themes/rhs/inc/perfil/perfil.js diff --git a/public/wp-content/themes/rhs/inc/perfil/perfil.js b/public/wp-content/themes/rhs/inc/perfil/perfil.js new file mode 100644 index 00000000..2414b163 --- /dev/null +++ b/public/wp-content/themes/rhs/inc/perfil/perfil.js @@ -0,0 +1,89 @@ +jQuery( function( $ ) { + + var trigger_modal = ".modal-delete-account"; + $(trigger_modal).on("click", function(e) { + var html_content = "
"+ + ""+ + "Realizar o download de conteúdo do meu perfil"+ + "
"+ + "
"+ + ""+ + "

as publicações ficarão em nome da RHS e sua identidade será preservada.

"+ + "
"+ + "
"+ + ""+ + "
" + ; + + e.preventDefault(); + swal({ + title: "Excluir Conta?", + text: html_content, + html: true, + type: "warning", + showConfirmButton: false, + showCancelButton: true, + cancelButtonText: "Cancelar", + }); + + $('.dont-send-to-legacy, #spinner-content-download').hide(); + + $('#send-to-legacy-user').bind('change', function() { + if (this.checked) { + $('.dont-send-to-legacy').hide(); + $('.send-to-legacy').show(); + } else { + $('.send-to-legacy').hide(); + $('.dont-send-to-legacy').show(); + } + }); + }); + + $(document).on('click', '.download-my-content', function() { + var d = new Date(); + var filename = "RHS_meu_backup_de_posts_" + d.getDate() + "" + (d.getMonth() + 1) + ""+ d.getFullYear() + ".xls"; + $('.download-my-content').hide(); + $('#spinner-content-download').show(); + $.ajax({ + type: "POST", + url: user_vars.ajaxurl, + cache: false, + data: { + action: 'generate_backup_file', + vars_to_generate: user_vars + }, + success: function(output) { + var blob = new Blob(["\ufeff", output]); + var link = document.createElement('a'); + link.href = window.URL.createObjectURL(blob); + link.download = filename; + link.click(); + $('#spinner-content-download').hide(); + $('.download-my-content').show(); + } + }); + + }); + $(document).on('click', '.delete-my-account', function() { + var send_to_legacy_user = $(this).data('send-to-legacy-user'); + + $.ajax({ + type: "POST", + url: user_vars.ajaxurl, + cache: false, + data: { + action: 'delete_my_account', + send_to_legacy_user: send_to_legacy_user + }, + success: function(output) { + swal("Excluída!", "Conta excluída com sucesso.", "success"); + } + }); + + }); +}); \ No newline at end of file From 5b3df24336ad0c0a64d4710994120ac8c18f3271 Mon Sep 17 00:00:00 2001 From: Pedro Naves Date: Tue, 20 Feb 2018 15:33:16 -0300 Subject: [PATCH 18/45] adicionando arquivo faltante (ref. #102) --- .../themes/rhs/inc/perfil/perfil.js | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 public/wp-content/themes/rhs/inc/perfil/perfil.js diff --git a/public/wp-content/themes/rhs/inc/perfil/perfil.js b/public/wp-content/themes/rhs/inc/perfil/perfil.js new file mode 100644 index 00000000..2414b163 --- /dev/null +++ b/public/wp-content/themes/rhs/inc/perfil/perfil.js @@ -0,0 +1,89 @@ +jQuery( function( $ ) { + + var trigger_modal = ".modal-delete-account"; + $(trigger_modal).on("click", function(e) { + var html_content = "
"+ + ""+ + "Realizar o download de conteúdo do meu perfil"+ + "
"+ + "
"+ + ""+ + "

as publicações ficarão em nome da RHS e sua identidade será preservada.

"+ + "
"+ + "
"+ + ""+ + "
" + ; + + e.preventDefault(); + swal({ + title: "Excluir Conta?", + text: html_content, + html: true, + type: "warning", + showConfirmButton: false, + showCancelButton: true, + cancelButtonText: "Cancelar", + }); + + $('.dont-send-to-legacy, #spinner-content-download').hide(); + + $('#send-to-legacy-user').bind('change', function() { + if (this.checked) { + $('.dont-send-to-legacy').hide(); + $('.send-to-legacy').show(); + } else { + $('.send-to-legacy').hide(); + $('.dont-send-to-legacy').show(); + } + }); + }); + + $(document).on('click', '.download-my-content', function() { + var d = new Date(); + var filename = "RHS_meu_backup_de_posts_" + d.getDate() + "" + (d.getMonth() + 1) + ""+ d.getFullYear() + ".xls"; + $('.download-my-content').hide(); + $('#spinner-content-download').show(); + $.ajax({ + type: "POST", + url: user_vars.ajaxurl, + cache: false, + data: { + action: 'generate_backup_file', + vars_to_generate: user_vars + }, + success: function(output) { + var blob = new Blob(["\ufeff", output]); + var link = document.createElement('a'); + link.href = window.URL.createObjectURL(blob); + link.download = filename; + link.click(); + $('#spinner-content-download').hide(); + $('.download-my-content').show(); + } + }); + + }); + $(document).on('click', '.delete-my-account', function() { + var send_to_legacy_user = $(this).data('send-to-legacy-user'); + + $.ajax({ + type: "POST", + url: user_vars.ajaxurl, + cache: false, + data: { + action: 'delete_my_account', + send_to_legacy_user: send_to_legacy_user + }, + success: function(output) { + swal("Excluída!", "Conta excluída com sucesso.", "success"); + } + }); + + }); +}); \ No newline at end of file From e25eb6e3f1f86fc2208808bbd6b3cf69c8937db3 Mon Sep 17 00:00:00 2001 From: Pedro Naves Date: Tue, 20 Feb 2018 16:21:33 -0300 Subject: [PATCH 19/45] =?UTF-8?q?adicionando=20redirecionamento=20de=20usu?= =?UTF-8?q?=C3=A1rios=20ap=C3=B3s=20exclus=C3=A3o=20de=20conta=20(ref.=20#?= =?UTF-8?q?102)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/wp-content/themes/rhs/inc/perfil/perfil.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/public/wp-content/themes/rhs/inc/perfil/perfil.js b/public/wp-content/themes/rhs/inc/perfil/perfil.js index 2414b163..8eb2af93 100644 --- a/public/wp-content/themes/rhs/inc/perfil/perfil.js +++ b/public/wp-content/themes/rhs/inc/perfil/perfil.js @@ -81,7 +81,13 @@ jQuery( function( $ ) { send_to_legacy_user: send_to_legacy_user }, success: function(output) { - swal("Excluída!", "Conta excluída com sucesso.", "success"); + swal({ + title: "Excluída!", + text: "Conta excluída com sucesso.", + type: "success", + }, function() { + window.location.href = window.location.origin; + }); } }); From d219e07509523212c3134e4ca3a656dcc78367c2 Mon Sep 17 00:00:00 2001 From: Pedro Naves Date: Fri, 16 Feb 2018 10:31:27 -0200 Subject: [PATCH 20/45] =?UTF-8?q?criando=20=C3=A1rea=20para=20pr=C3=B3prio?= =?UTF-8?q?=20usu=C3=A1rio=20excluir=20e=20realizar=20backup=20de=20conta?= =?UTF-8?q?=20(ref.=20#102)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../themes/rhs/inc/perfil/perfil.php | 141 ++++++++++++++++++ .../wp-content/themes/rhs/inc/user/user.php | 7 + public/wp-content/themes/rhs/perfil.php | 10 ++ 3 files changed, 158 insertions(+) diff --git a/public/wp-content/themes/rhs/inc/perfil/perfil.php b/public/wp-content/themes/rhs/inc/perfil/perfil.php index 8b6e98db..2161f8e4 100644 --- a/public/wp-content/themes/rhs/inc/perfil/perfil.php +++ b/public/wp-content/themes/rhs/inc/perfil/perfil.php @@ -7,6 +7,17 @@ class RHSPerfil extends RHSMessage { function __construct($userID) { $this->userID = $userID; + add_action('wp_enqueue_scripts', array(&$this, 'addJS'), 2); + add_action('wp_ajax_generate_backup_file', array($this, 'generate_backup_file')); + add_action('wp_ajax_nopriv_generate_backup_file', array($this,'generate_backup_file')); + add_action('wp_ajax_delete_my_account', array($this, 'delete_my_account')); + add_action('wp_ajax_nopriv_delete_my_account', array($this,'delete_my_account')); + } + + + function addJS() { + wp_enqueue_script('rhs_profile', get_template_directory_uri() . '/inc/perfil/perfil.js', array('jquery')); + wp_localize_script('rhs_profile', 'user_vars', array('ajaxurl' => admin_url('admin-ajax.php'))); } function getUserId(){ @@ -232,6 +243,136 @@ private function validate_by_post() { return true; } + + function show_box_to_delete_profile($user_id){ + echo ""; + } + + public static function generate_backup_file() { + global $wp_query; + global $wpdb; + global $RHSVote; + global $RHSNetwork; + global $RHSSearch; + + header('Content-Type: application/vnd.ms-excel'); + header('Pragma: no-cache'); + header('Expires: 0'); + + $args = array( + 'author' => get_current_user_id(), + 'orderby' => 'post_date', + 'order' => 'ASC', + 'posts_per_page' => -1 + ); + + $content_file = get_posts($args); + + foreach($content_file as $post) { + $get_title = html_entity_decode(get_the_title($post->ID), ENT_QUOTES, "UTF-8"); + + $raw_content = get_post_field('post_content', $post->ID); + $post_content = iconv( "utf-8", "utf-8", $raw_content ); + $post_content = strip_html_tags( $post_content ); + $post_content = html_entity_decode($post_content, ENT_QUOTES, "UTF-8"); + + $get_date = get_the_date('d/m/Y H:i:s', $post->ID); + $get_author = get_the_author_meta('user_firstname', $post->post_author) . " " . get_the_author_meta('user_lastname', $post->post_author); + $get_link = $post->guid; + $get_views = $RHSNetwork->get_post_total_views($post->ID); + $get_shares = $RHSNetwork->get_post_total_shares($post->ID); + $get_comments = wp_count_comments($post->ID); + $get_votes = $RHSVote->get_total_votes($post->ID); + + $views = return_value_or_zero($get_views); + $shares = return_value_or_zero($get_shares); + $votes = return_value_or_zero($get_votes); + $comments = return_value_or_zero($get_comments); + + $post_ufmun = get_post_ufmun($post->ID); + $uf = $post_ufmun['uf']['sigla']; + $mun = $post_ufmun['mun']['nome']; + + $row_data[] = [ + 'titulo'=> $get_title, + 'conteudo' => $post_content, + 'data'=> $get_date, + 'autor' => $get_author, + 'link' => $get_link, + 'visualizacoes' => $views, + 'compartilhamentos' => $shares, + 'votos' => $votes, + 'comentarios' => $comments, + 'estado' => return_value_or_dash($uf), + 'cidade' => return_value_or_dash($mun) + ]; + } + + $head_table .= " + + + + + + + + + + + + + + + + "; + + foreach ($row_data as $row) { + $row_table .= " + + + + + + + + + + + + "; + } + + $footer_table = "
TítuloConteúdoDataAutorLinkVisualizaçõesCompartilhamentosVotosComentáriosEstadoCidade
" . $row['titulo'] . "" . $row['conteudo'] . "" . $row['data'] . "" . $row['autor'] . "" . $row['link'] . "" . $row['visualizacoes'] . "" . $row['compartilhamentos'] . "" . $row['votos'] . "" . $row['comentarios'] . "" . $row['estado'] . "" . $row['cidade'] . "
"; + + $file = $head_table . $row_table . $footer_table; + + mb_convert_encoding($file, 'UTF-16LE', 'UTF-8'); + echo $file; + } + + public static function delete_my_account() { + $user_id = get_current_user_id(); + $meta = get_user_meta($user_id); + $send_to_legacy_user = $_POST['send_to_legacy_user']; + $legacy_user_id = 1; + + // Remove meta de usuários + foreach ($meta as $key => $val) { + delete_user_meta($user_id, $key); + } + + // Desloga usuário + wp_logout(); + + // Remove usuário + if($send_to_legacy_user == 'true') { + $deleted = wp_delete_user($user_id); + } else { + $deleted = wp_delete_user($user_id, $legacy_user_id); + } + + } + } global $RHSPerfil; diff --git a/public/wp-content/themes/rhs/inc/user/user.php b/public/wp-content/themes/rhs/inc/user/user.php index 072a8af8..b0245081 100644 --- a/public/wp-content/themes/rhs/inc/user/user.php +++ b/public/wp-content/themes/rhs/inc/user/user.php @@ -391,4 +391,11 @@ class="btn btn-info js-add-link">
'; } + + + + + + + } \ No newline at end of file diff --git a/public/wp-content/themes/rhs/perfil.php b/public/wp-content/themes/rhs/perfil.php index 6005d6d9..c6159dce 100644 --- a/public/wp-content/themes/rhs/perfil.php +++ b/public/wp-content/themes/rhs/perfil.php @@ -191,6 +191,16 @@ class="form-control" type="text" id="first_name" show_user_links_to_edit($RHSUser->get_id());?>
+ +
+
+

Excluir Conta

+
+
+ show_box_to_delete_profile($RHSUser->get_id());?> +
+
+
From fd2ecca56a850da85e4b2862a6df32da04460947 Mon Sep 17 00:00:00 2001 From: Pedro Naves Date: Fri, 16 Feb 2018 13:59:09 -0200 Subject: [PATCH 21/45] =?UTF-8?q?adicionando=20match=20para=20usu=C3=A1rio?= =?UTF-8?q?=20de=20legado,=20atrav=C3=A9s=20do=20e-mail=20(ref.=20#102)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/wp-content/themes/rhs/assets/scss/style.scss | 4 ++++ public/wp-content/themes/rhs/inc/perfil/perfil.php | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/public/wp-content/themes/rhs/assets/scss/style.scss b/public/wp-content/themes/rhs/assets/scss/style.scss index f44b1131..6b54e8cd 100644 --- a/public/wp-content/themes/rhs/assets/scss/style.scss +++ b/public/wp-content/themes/rhs/assets/scss/style.scss @@ -242,4 +242,8 @@ body { object-fit: cover; object-position: top; } +} + +.extra-small-type { + font-size: 60%; } \ No newline at end of file diff --git a/public/wp-content/themes/rhs/inc/perfil/perfil.php b/public/wp-content/themes/rhs/inc/perfil/perfil.php index 2161f8e4..0a0db695 100644 --- a/public/wp-content/themes/rhs/inc/perfil/perfil.php +++ b/public/wp-content/themes/rhs/inc/perfil/perfil.php @@ -354,7 +354,10 @@ public static function delete_my_account() { $user_id = get_current_user_id(); $meta = get_user_meta($user_id); $send_to_legacy_user = $_POST['send_to_legacy_user']; - $legacy_user_id = 1; + $legacy_user = get_user_by('email', 'legado@redehumanizasus.net'); + if($legacy_user == null) { + $legacy_user = get_user_by('id', 1); + } // Remove meta de usuários foreach ($meta as $key => $val) { From 61ff8072e6c300c66521afbebc17502f9fa001e3 Mon Sep 17 00:00:00 2001 From: Pedro Naves Date: Fri, 16 Feb 2018 14:10:19 -0200 Subject: [PATCH 22/45] =?UTF-8?q?corrigindo=20atribui=C3=A7=C3=A3o=20de=20?= =?UTF-8?q?posts=20para=20a=20conta=20(ref.=20#102)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/wp-content/themes/rhs/inc/perfil/perfil.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/wp-content/themes/rhs/inc/perfil/perfil.php b/public/wp-content/themes/rhs/inc/perfil/perfil.php index 0a0db695..384b9b6d 100644 --- a/public/wp-content/themes/rhs/inc/perfil/perfil.php +++ b/public/wp-content/themes/rhs/inc/perfil/perfil.php @@ -369,9 +369,9 @@ public static function delete_my_account() { // Remove usuário if($send_to_legacy_user == 'true') { - $deleted = wp_delete_user($user_id); - } else { $deleted = wp_delete_user($user_id, $legacy_user_id); + } else { + $deleted = wp_delete_user($user_id); } } From 0518dc81d9701ffed29c117c5fc358aeacddc190 Mon Sep 17 00:00:00 2001 From: Pedro Naves Date: Fri, 16 Feb 2018 14:14:20 -0200 Subject: [PATCH 23/45] =?UTF-8?q?corrigindo=20t=C3=ADtulo=20de=20modal=20g?= =?UTF-8?q?erado=20pelo=20sweet=20alert=20(ref.=20#102)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/wp-content/themes/rhs/assets/scss/style.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/public/wp-content/themes/rhs/assets/scss/style.scss b/public/wp-content/themes/rhs/assets/scss/style.scss index 6b54e8cd..fc0b6d27 100644 --- a/public/wp-content/themes/rhs/assets/scss/style.scss +++ b/public/wp-content/themes/rhs/assets/scss/style.scss @@ -165,6 +165,7 @@ body { .sweet-alert{ border-radius: 0px; h2{ + padding-top: 15px; font-size: 17px; } .sa-confirm-button-container{ From 6085fb0045bbba61185a00c88d583473de0ed336 Mon Sep 17 00:00:00 2001 From: Pedro Naves Date: Tue, 20 Feb 2018 16:21:33 -0300 Subject: [PATCH 24/45] =?UTF-8?q?adicionando=20redirecionamento=20de=20usu?= =?UTF-8?q?=C3=A1rios=20ap=C3=B3s=20exclus=C3=A3o=20de=20conta=20(ref.=20#?= =?UTF-8?q?102)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/wp-content/themes/rhs/inc/perfil/perfil.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/public/wp-content/themes/rhs/inc/perfil/perfil.js b/public/wp-content/themes/rhs/inc/perfil/perfil.js index 2414b163..8eb2af93 100644 --- a/public/wp-content/themes/rhs/inc/perfil/perfil.js +++ b/public/wp-content/themes/rhs/inc/perfil/perfil.js @@ -81,7 +81,13 @@ jQuery( function( $ ) { send_to_legacy_user: send_to_legacy_user }, success: function(output) { - swal("Excluída!", "Conta excluída com sucesso.", "success"); + swal({ + title: "Excluída!", + text: "Conta excluída com sucesso.", + type: "success", + }, function() { + window.location.href = window.location.origin; + }); } }); From 457d30987b53c7785fc3f9c29c8c22d5695190c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Guimara=CC=83es?= Date: Wed, 21 Feb 2018 14:21:03 -0300 Subject: [PATCH 25/45] =?UTF-8?q?Evita=20que=20os=20textos=20dos=20bot?= =?UTF-8?q?=C3=B5es=20extrapolem=20seu=20elemento=20container=20na=20pagin?= =?UTF-8?q?a=20de=20publicar=20post?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../themes/rhs/assets/scss/_media-query.scss | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/public/wp-content/themes/rhs/assets/scss/_media-query.scss b/public/wp-content/themes/rhs/assets/scss/_media-query.scss index d8a6af63..1fe8829f 100644 --- a/public/wp-content/themes/rhs/assets/scss/_media-query.scss +++ b/public/wp-content/themes/rhs/assets/scss/_media-query.scss @@ -377,6 +377,18 @@ } } + @media (min-width: 991px) { + #sidebar { + .panel { + .sidebar-public { + button { + font-size: 0.9vw; + } + } + } + } + } + @media print { * { background: transparent !important; From 490aa80dee48c8c14260e09aa497fce0c2060c3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Guimara=CC=83es?= Date: Wed, 21 Feb 2018 15:01:55 -0300 Subject: [PATCH 26/45] =?UTF-8?q?Evita=20que=20as=20informa=C3=A7=C3=B5es?= =?UTF-8?q?=20dos=20dados=20de=20votos=20extrapolem=20o=20container=20do?= =?UTF-8?q?=20post?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../themes/rhs/assets/scss/_media-query.scss | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/public/wp-content/themes/rhs/assets/scss/_media-query.scss b/public/wp-content/themes/rhs/assets/scss/_media-query.scss index 1fe8829f..323b8506 100644 --- a/public/wp-content/themes/rhs/assets/scss/_media-query.scss +++ b/public/wp-content/themes/rhs/assets/scss/_media-query.scss @@ -389,6 +389,18 @@ } } + @media(min-width: 692px) and (max-width: 910px) { + .panel-default { + > .panel-heading { + > .post-titulo { + .vdivide { + padding-left: 0 !important; + } + } + } + } + } + @media print { * { background: transparent !important; From fb53b43f82a6ddbcf25e921d6a2099475cc8639c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Guimara=CC=83es?= Date: Fri, 23 Feb 2018 18:41:41 -0300 Subject: [PATCH 27/45] Altera feedback ao usuario na confirmacao da exclusao da conta --- .../themes/rhs/assets/scss/style.scss | 8 +- .../themes/rhs/inc/perfil/perfil.js | 77 ++++++++++++------- .../themes/rhs/inc/perfil/perfil.php | 12 ++- .../wp-content/themes/rhs/inc/user/user.php | 6 -- public/wp-content/themes/rhs/perfil.php | 42 ++++++++-- 5 files changed, 98 insertions(+), 47 deletions(-) diff --git a/public/wp-content/themes/rhs/assets/scss/style.scss b/public/wp-content/themes/rhs/assets/scss/style.scss index fc0b6d27..8b436552 100644 --- a/public/wp-content/themes/rhs/assets/scss/style.scss +++ b/public/wp-content/themes/rhs/assets/scss/style.scss @@ -171,8 +171,8 @@ body { .sa-confirm-button-container{ button{ display: inline-block; - background-color: #00b4b4; - border: none; + //background-color: #00b4b4; + //border: none; box-shadow: none; color: #ffffff; font: { @@ -188,8 +188,8 @@ body { &:hover, &:focus, &:hover:focus { outline: none; color: #ffffff; - background-color: #009b9b; - border: none; + //background-color: #009b9b; + //border: none; box-shadow: none; } &:active, &:active:hover, &:active:focus { diff --git a/public/wp-content/themes/rhs/inc/perfil/perfil.js b/public/wp-content/themes/rhs/inc/perfil/perfil.js index 8eb2af93..996a8c87 100644 --- a/public/wp-content/themes/rhs/inc/perfil/perfil.js +++ b/public/wp-content/themes/rhs/inc/perfil/perfil.js @@ -2,47 +2,64 @@ jQuery( function( $ ) { var trigger_modal = ".modal-delete-account"; $(trigger_modal).on("click", function(e) { - var html_content = "
"+ - ""+ - "Realizar o download de conteúdo do meu perfil"+ - "
"+ - "
"+ - ""+ - "

as publicações ficarão em nome da RHS e sua identidade será preservada.

"+ - "
"+ - "
"+ - ""+ - "
" - ; - - e.preventDefault(); + var greeting = $(this).data('displayname') + ", "; + var user_total_posts = $(this).data('total-posts'); + console.log(user_total_posts); swal({ - title: "Excluir Conta?", + type: 'warning', + title: "Deseja realmente excluir sua conta?", + showConfirmButton: true, + showCancelButton: true, + cancelButtonText: "Cancelar", + confirmButtonText: "Sim", + confirmButtonClass: "btn-danger", + closeOnConfirm: false, + closeOnCancel: false + }, function(isConfirm) { + if(isConfirm) { + renderConfirmExclusion(user_total_posts, e); + } else { + swal(greeting, "Obrigado por continuar contribuindo conosco!", "success"); + } + }); + }); + + function renderConfirmExclusion(posts_count, el) { + var $other = ""; + var $reason_delete = $(".reason-delete").html(); + var html_content = "
"; + if(posts_count > 0) { + var $other = $(".manage-content").html(); + html_content += $other; + } + + html_content += $reason_delete; + html_content += ""; + + el.preventDefault(); + swal({ + title: "Sentimos muito que você tenha que sair", text: html_content, html: true, - type: "warning", + type: "info", showConfirmButton: false, showCancelButton: true, - cancelButtonText: "Cancelar", + cancelButtonText: "Cancelar" }); - + $('.dont-send-to-legacy, #spinner-content-download').hide(); $('#send-to-legacy-user').bind('change', function() { if (this.checked) { $('.dont-send-to-legacy').hide(); $('.send-to-legacy').show(); - } else { + } else {; $('.send-to-legacy').hide(); $('.dont-send-to-legacy').show(); } }); - }); + } $(document).on('click', '.download-my-content', function() { var d = new Date(); @@ -71,6 +88,11 @@ jQuery( function( $ ) { }); $(document).on('click', '.delete-my-account', function() { var send_to_legacy_user = $(this).data('send-to-legacy-user'); + var del_reason = $("input.delreason").text(); + + console.log(this); + + console.log(del_reason); return; $.ajax({ type: "POST", @@ -78,13 +100,14 @@ jQuery( function( $ ) { cache: false, data: { action: 'delete_my_account', - send_to_legacy_user: send_to_legacy_user + send_to_legacy_user: send_to_legacy_user, + reason: del_reason }, success: function(output) { swal({ title: "Excluída!", text: "Conta excluída com sucesso.", - type: "success", + type: "success" }, function() { window.location.href = window.location.origin; }); diff --git a/public/wp-content/themes/rhs/inc/perfil/perfil.php b/public/wp-content/themes/rhs/inc/perfil/perfil.php index 384b9b6d..3b784a4f 100644 --- a/public/wp-content/themes/rhs/inc/perfil/perfil.php +++ b/public/wp-content/themes/rhs/inc/perfil/perfil.php @@ -244,8 +244,11 @@ private function validate_by_post() { } - function show_box_to_delete_profile($user_id){ - echo ""; + function show_box_to_delete_profile($user_id, $name = "") { + $_user_posts = count_user_posts($user_id); + + echo ""; + } public static function generate_backup_file() { @@ -351,6 +354,11 @@ public static function generate_backup_file() { } public static function delete_my_account() { + + + var_dump( $_POST ); + die; + $user_id = get_current_user_id(); $meta = get_user_meta($user_id); $send_to_legacy_user = $_POST['send_to_legacy_user']; diff --git a/public/wp-content/themes/rhs/inc/user/user.php b/public/wp-content/themes/rhs/inc/user/user.php index b0245081..ed995f39 100644 --- a/public/wp-content/themes/rhs/inc/user/user.php +++ b/public/wp-content/themes/rhs/inc/user/user.php @@ -392,10 +392,4 @@ class="btn btn-info js-add-link"> '; } - - - - - - } \ No newline at end of file diff --git a/public/wp-content/themes/rhs/perfil.php b/public/wp-content/themes/rhs/perfil.php index c6159dce..579a4cfa 100644 --- a/public/wp-content/themes/rhs/perfil.php +++ b/public/wp-content/themes/rhs/perfil.php @@ -1,7 +1,7 @@ - - is_admin() && get_query_var( 'rhs_user' ) ) { @@ -11,6 +11,7 @@ $RHSUser = $current_user; $RHSPerfil = new RHSPerfil( $current_user->get_id() ); } +$primeiro_nome = $RHSUser->get_first_name(); ?>
@@ -128,7 +129,7 @@ class="form-control" type="text" id="mail" name="mail" size="60"
-
@@ -193,16 +194,41 @@ class="form-control" type="text" id="first_name"
-
-

Excluir Conta

-
-
- show_box_to_delete_profile($RHSUser->get_id());?> + + + + +
+ + + +
+ + show_box_to_delete_profile($RHSUser->get_id(), $primeiro_nome);?> +
From 656f0214e23ff397ac43e787a3be2d63d302c6ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Guimara=CC=83es?= Date: Sun, 25 Feb 2018 01:03:14 -0300 Subject: [PATCH 28/45] Working way much better --- .../themes/rhs/inc/perfil/perfil.js | 28 +++++++++---------- .../themes/rhs/inc/perfil/perfil.php | 19 +++++++------ public/wp-content/themes/rhs/perfil.php | 16 +++++++---- 3 files changed, 34 insertions(+), 29 deletions(-) diff --git a/public/wp-content/themes/rhs/inc/perfil/perfil.js b/public/wp-content/themes/rhs/inc/perfil/perfil.js index 996a8c87..0642a7ca 100644 --- a/public/wp-content/themes/rhs/inc/perfil/perfil.js +++ b/public/wp-content/themes/rhs/inc/perfil/perfil.js @@ -2,7 +2,7 @@ jQuery( function( $ ) { var trigger_modal = ".modal-delete-account"; $(trigger_modal).on("click", function(e) { - var greeting = $(this).data('displayname') + ", "; + var name = $(this).data('displayname'); var user_total_posts = $(this).data('total-posts'); console.log(user_total_posts); swal({ @@ -17,29 +17,29 @@ jQuery( function( $ ) { closeOnCancel: false }, function(isConfirm) { if(isConfirm) { - renderConfirmExclusion(user_total_posts, e); + renderConfirmExclusion(user_total_posts, name, e); } else { - swal(greeting, "Obrigado por continuar contribuindo conosco!", "success"); + swal(name, "Obrigado por continuar contribuindo conosco!", "success"); } }); }); - function renderConfirmExclusion(posts_count, el) { + function renderConfirmExclusion(posts_count, name, el) { var $other = ""; var $reason_delete = $(".reason-delete").html(); - var html_content = "
"; + var html_content = ""; if(posts_count > 0) { - var $other = $(".manage-content").html(); + var $other = "
" + $(".manage-content").html(); html_content += $other; } html_content += $reason_delete; - html_content += ""; + html_content += ""; el.preventDefault(); swal({ - title: "Sentimos muito que você tenha que sair", + title: name + ", sentimos muito que você tenha que sair!", text: html_content, html: true, type: "info", @@ -88,11 +88,8 @@ jQuery( function( $ ) { }); $(document).on('click', '.delete-my-account', function() { var send_to_legacy_user = $(this).data('send-to-legacy-user'); - var del_reason = $("input.delreason").text(); - - console.log(this); - - console.log(del_reason); return; + var del_reason = $("input.delreason").last().val(); + var user = $(this).data('user'); $.ajax({ type: "POST", @@ -101,7 +98,8 @@ jQuery( function( $ ) { data: { action: 'delete_my_account', send_to_legacy_user: send_to_legacy_user, - reason: del_reason + reason: del_reason, + user: user }, success: function(output) { swal({ diff --git a/public/wp-content/themes/rhs/inc/perfil/perfil.php b/public/wp-content/themes/rhs/inc/perfil/perfil.php index 3b784a4f..6ed2efb5 100644 --- a/public/wp-content/themes/rhs/inc/perfil/perfil.php +++ b/public/wp-content/themes/rhs/inc/perfil/perfil.php @@ -354,19 +354,22 @@ public static function generate_backup_file() { } public static function delete_my_account() { - - - var_dump( $_POST ); - die; - $user_id = get_current_user_id(); $meta = get_user_meta($user_id); $send_to_legacy_user = $_POST['send_to_legacy_user']; + $user_name = $_POST['user']; + $reason_delete = empty(trim($_POST['reason'])) ? null : htmlspecialchars($_POST['reason']); $legacy_user = get_user_by('email', 'legado@redehumanizasus.net'); - if($legacy_user == null) { + + if( false === $legacy_user ) { $legacy_user = get_user_by('id', 1); } - + + if( !is_null( $reason_delete ) ) { + $subject = "Usuário $user_name deletou sua conta"; + wp_mail($legacy_user->user_email, $subject, $reason_delete, RHSEmail::EMAIL_HEADERS); + } + // Remove meta de usuários foreach ($meta as $key => $val) { delete_user_meta($user_id, $key); @@ -377,7 +380,7 @@ public static function delete_my_account() { // Remove usuário if($send_to_legacy_user == 'true') { - $deleted = wp_delete_user($user_id, $legacy_user_id); + $deleted = wp_delete_user($user_id, $legacy_user->ID); } else { $deleted = wp_delete_user($user_id); } diff --git a/public/wp-content/themes/rhs/perfil.php b/public/wp-content/themes/rhs/perfil.php index 579a4cfa..5cc1caeb 100644 --- a/public/wp-content/themes/rhs/perfil.php +++ b/public/wp-content/themes/rhs/perfil.php @@ -202,24 +202,28 @@ class="form-control" type="text" id="first_name" From b05824b8e222abc9877ea687a9294540feab430a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Guimara=CC=83es?= Date: Sun, 25 Feb 2018 01:12:26 -0300 Subject: [PATCH 29/45] removes useless extra hr/spaces --- public/wp-content/themes/rhs/perfil.php | 1 - 1 file changed, 1 deletion(-) diff --git a/public/wp-content/themes/rhs/perfil.php b/public/wp-content/themes/rhs/perfil.php index 5cc1caeb..d0109e0e 100644 --- a/public/wp-content/themes/rhs/perfil.php +++ b/public/wp-content/themes/rhs/perfil.php @@ -223,7 +223,6 @@ class="form-control" type="text" id="first_name"

As publicações ficarão em nome da RHS e sua identidade será preservada.

-


From 33adea6fcf9684c609b0adb9e2deda4bbc078a49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Guimara=CC=83es?= Date: Sun, 25 Feb 2018 01:35:01 -0300 Subject: [PATCH 30/45] =?UTF-8?q?Melhorias=20no=20UI=20do=20modal=20de=20e?= =?UTF-8?q?xclus=C3=A3o=20da=20conta?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../themes/rhs/assets/scss/_panel.scss | 2 - .../themes/rhs/inc/perfil/perfil.js | 4 +- public/wp-content/themes/rhs/perfil.php | 47 ++++++++----------- 3 files changed, 21 insertions(+), 32 deletions(-) diff --git a/public/wp-content/themes/rhs/assets/scss/_panel.scss b/public/wp-content/themes/rhs/assets/scss/_panel.scss index e9238efe..213e3cb7 100644 --- a/public/wp-content/themes/rhs/assets/scss/_panel.scss +++ b/public/wp-content/themes/rhs/assets/scss/_panel.scss @@ -146,14 +146,12 @@ float: right; padding: { bottom: 7px; - top: 7px; } a, button { background-color: $primeira_cor_texto; border-color: $primeira_cor_texto; &.btn { font-size: 17px; - margin-top: 10px; padding: 6px 37px; } } diff --git a/public/wp-content/themes/rhs/inc/perfil/perfil.js b/public/wp-content/themes/rhs/inc/perfil/perfil.js index 0642a7ca..e05e2838 100644 --- a/public/wp-content/themes/rhs/inc/perfil/perfil.js +++ b/public/wp-content/themes/rhs/inc/perfil/perfil.js @@ -34,8 +34,8 @@ jQuery( function( $ ) { } html_content += $reason_delete; - html_content += ""; + html_content += "
"; el.preventDefault(); swal({ diff --git a/public/wp-content/themes/rhs/perfil.php b/public/wp-content/themes/rhs/perfil.php index d0109e0e..043e8393 100644 --- a/public/wp-content/themes/rhs/perfil.php +++ b/public/wp-content/themes/rhs/perfil.php @@ -193,35 +193,26 @@ class="form-control" type="text" id="first_name"
-
- - - - -
- - +
+ - -
+