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/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/docs/notifications.md b/docs/notifications.md index 108379a6..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,13 +260,13 @@ 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: ``` '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`. @@ -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/public/wp-content/themes/rhs/assets/images/logo.png b/public/wp-content/themes/rhs/assets/images/logo.png index 5cc8be44..2b2e66e1 100644 Binary files a/public/wp-content/themes/rhs/assets/images/logo.png and b/public/wp-content/themes/rhs/assets/images/logo.png differ diff --git a/public/wp-content/themes/rhs/assets/images/logo_color.png b/public/wp-content/themes/rhs/assets/images/logo_color.png new file mode 100644 index 00000000..9c506814 Binary files /dev/null and b/public/wp-content/themes/rhs/assets/images/logo_color.png differ diff --git a/public/wp-content/themes/rhs/assets/images/logo_original.png b/public/wp-content/themes/rhs/assets/images/logo_original.png new file mode 100644 index 00000000..5cc8be44 Binary files /dev/null and b/public/wp-content/themes/rhs/assets/images/logo_original.png differ 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/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/assets/scss/_archive-page.scss b/public/wp-content/themes/rhs/assets/scss/_archive-page.scss index 971fe5d6..81243490 100644 --- a/public/wp-content/themes/rhs/assets/scss/_archive-page.scss +++ b/public/wp-content/themes/rhs/assets/scss/_archive-page.scss @@ -3,7 +3,7 @@ * Archive Page * ************/ -.archive{ +div.panel.archive{ box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2); background: #fff none repeat scroll 0 0; .titulo{ diff --git a/public/wp-content/themes/rhs/assets/scss/_author-perfil.scss b/public/wp-content/themes/rhs/assets/scss/_author-perfil.scss index d70a67de..a9514fb4 100644 --- a/public/wp-content/themes/rhs/assets/scss/_author-perfil.scss +++ b/public/wp-content/themes/rhs/assets/scss/_author-perfil.scss @@ -402,4 +402,31 @@ + .panel-collapse > .panel-body { border-color: $backgroundColor; } -} \ No newline at end of file +} + + +.encerrar-conta-label { + font-size: medium; + padding-top: 5px; +} + +.encerrar-conta-p { font-size: 11px; } + +a.download-my-content { margin-top: 10px; } + +#encerrar-conta-container { + .manage-content { + .col-md-12 { + width: 100%; + display: inline-block; + .col-md-6 { + width: 50%; + display: inline-block; + font-size: 16px; + + input { font-size: 16px; } + p { font-size: 11px; } + } + } + } +} // #encerrar-conta-container \ No newline at end of file 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..323b8506 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,30 @@ } } + @media (min-width: 991px) { + #sidebar { + .panel { + .sidebar-public { + button { + font-size: 0.9vw; + } + } + } + } + } + + @media(min-width: 692px) and (max-width: 910px) { + .panel-default { + > .panel-heading { + > .post-titulo { + .vdivide { + padding-left: 0 !important; + } + } + } + } + } + @media print { * { background: transparent !important; 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/assets/scss/_single-page.scss b/public/wp-content/themes/rhs/assets/scss/_single-page.scss index af8e01f7..3e44754e 100644 --- a/public/wp-content/themes/rhs/assets/scss/_single-page.scss +++ b/public/wp-content/themes/rhs/assets/scss/_single-page.scss @@ -257,7 +257,8 @@ margin: 10px 10px; } &:hover { - box-shadow: 2px 2px 1px 1px #c1c1c1; + // box-shadow: 2px 2px 1px 1px #c1c1c1; + box-shadow: -1px 0.5px 9px 0 $mediumGray; } &.padding-bottom { .alert { diff --git a/public/wp-content/themes/rhs/assets/scss/_variavels.scss b/public/wp-content/themes/rhs/assets/scss/_variavels.scss index 6e45dba4..959a0a16 100644 --- a/public/wp-content/themes/rhs/assets/scss/_variavels.scss +++ b/public/wp-content/themes/rhs/assets/scss/_variavels.scss @@ -3,6 +3,7 @@ // _body_ $font_padrao: 'Solitas-NorReg'; $grayColor: #787878; +$mediumGray: #c1c1c1; $backgroundColor: #f2f3f5; $attention-red: #a94442; diff --git a/public/wp-content/themes/rhs/assets/scss/style.scss b/public/wp-content/themes/rhs/assets/scss/style.scss index f44b1131..02d6b05d 100644 --- a/public/wp-content/themes/rhs/assets/scss/style.scss +++ b/public/wp-content/themes/rhs/assets/scss/style.scss @@ -162,16 +162,15 @@ body { } } -.sweet-alert{ - border-radius: 0px; +.sweet-alert { + border-radius: 0; h2{ + padding-top: 15px; font-size: 17px; } .sa-confirm-button-container{ button{ display: inline-block; - background-color: #00b4b4; - border: none; box-shadow: none; color: #ffffff; font: { @@ -187,8 +186,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 { @@ -196,7 +195,7 @@ body { color: #ffffff; background-color: #009b9b; border: none; - box-shadow: 3px 4px 0px 0px #037b7b inset; + box-shadow: 3px 4px 0 0 #037b7b inset; } } } @@ -227,11 +226,17 @@ body { outline: none; color: #797979; background-color: #fff; - box-shadow: 3px 4px 0px 0px #797979 inset; + box-shadow: 3px 4px 0 0 #797979 inset; } } } -} +} // .sweet-alert + +.sweet-alert.deleteAccount { + .sa-custom { + width: 300px !important; + } +} // .sweet-alert.deleteAccount .user-last-login-widget { padding-top: 10px; @@ -242,4 +247,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/functions.php b/public/wp-content/themes/rhs/functions.php index e87c1976..800d3847 100644 --- a/public/wp-content/themes/rhs/functions.php +++ b/public/wp-content/themes/rhs/functions.php @@ -44,10 +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/widgets/imgWithLink/image-with-link.php'); require_once('inc/widgets/Facebook_Twitter/facebook_twiter.php'); require_once('inc/widgets/usersWidget/users-widget.php'); @@ -470,7 +472,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/header-full.php b/public/wp-content/themes/rhs/header-full.php index c6145352..13b2620e 100644 --- a/public/wp-content/themes/rhs/header-full.php +++ b/public/wp-content/themes/rhs/header-full.php @@ -19,7 +19,7 @@ -
+ > diff --git a/public/wp-content/themes/rhs/inc/api/rhs-api.php b/public/wp-content/themes/rhs/inc/api/rhs-api.php index f99a3dbb..5b184957 100644 --- a/public/wp-content/themes/rhs/inc/api/rhs-api.php +++ b/public/wp-content/themes/rhs/inc/api/rhs-api.php @@ -200,9 +200,11 @@ function prepare_post( $data, $post, $context ) { global $RHSVote, $RHSNetwork; $total_votes = $RHSVote->get_total_votes($post->ID); $total_shares = $RHSNetwork->get_post_total_shares($post->ID); + $user_has_voted = $RHSVote->user_has_voted($post->ID, get_current_user_id()); $data->data['total_votes'] = $total_votes ? $total_votes : 0; $data->data['comment_count'] = $post->comment_count; $data->data['total_shares'] = $total_shares ? $total_shares : 0; + $data->data['user_has_voted'] = $user_has_voted ? $user_has_voted : false; return $data; } 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/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' => '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' => '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/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/perfil/perfil.js b/public/wp-content/themes/rhs/inc/perfil/perfil.js new file mode 100644 index 00000000..1ae00d4c --- /dev/null +++ b/public/wp-content/themes/rhs/inc/perfil/perfil.js @@ -0,0 +1,117 @@ +jQuery( function( $ ) { + + var trigger_modal = ".modal-delete-account"; + $(trigger_modal).on("click", function(e) { + var name = $(this).data('displayname'); + var user_total_posts = $(this).data('total-posts'); + swal({ + 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, name, e); + } else { + swal(name, "Obrigado por continuar contribuindo conosco!", "success"); + } + }); + }); + + function renderConfirmExclusion(posts_count, name, el) { + var $other = ""; + var $reason_delete = $(".reason-delete").html(); + var $modal_header_img = $(".encerra-header-img").text(); + var html_content = ""; + if(posts_count > 0) { + var $other = "Título | +Conteúdo | +Data | +Autor | +Link | +Visualizações | +Compartilhamentos | +Votos | +Comentários | +Estado | +Cidade | +
---|---|---|---|---|---|---|---|---|---|---|
" . $row['titulo'] . " | +" . $row['conteudo'] . " | +" . $row['data'] . " | +" . $row['autor'] . " | +" . $row['link'] . " | +" . $row['visualizacoes'] . " | +" . $row['compartilhamentos'] . " | +" . $row['votos'] . " | +" . $row['comentarios'] . " | +" . $row['estado'] . " | +" . $row['cidade'] . " | +
O usuário $user_name ($_deleted_user_email) deletou sua conta em $agora.
"; + + if(!is_null($reason_delete)) { + $_mail_msg .= "Motivo: " . $reason_delete . "
"; + } + + $_mail_msg .= "Deixou seu conteúdo como legado RHS: $send_to_legacy_user
"; + // Notifica admin por email + wp_mail($legacy_user['email'], $subject, $_mail_msg, RHSEmail::EMAIL_HEADERS); + } + } + + private function get_destinatary_user() { + $legacy = get_user_by('email', 'legado@redehumanizasus.net'); + + if( false === $legacy ) { + $admin_email = get_option('admin_email'); + $_id_ = 1; + if(!$admin_email) { + $_admin_users = get_users(['role' => 'administrator']); + if( is_array($_admin_users) && is_object($_admin_users[0]) ) { + $admin_email = $_admin_users[0]->user_email; + $_id_ = $legacy->ID; + } else { + return false; + } + } + } else { + $admin_email = $legacy->user_email; + $_id_ = $legacy->ID; + } + + return [ + 'ID' => $_id_, + 'email' => $admin_email + ]; + } } global $RHSPerfil; 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..19f13047 --- /dev/null +++ b/public/wp-content/themes/rhs/inc/recommend-post/recommend_post.js @@ -0,0 +1,59 @@ +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) { + swal({ + title: "Deseja indicar esse post?", + text: "A indicação será enviada para " + suggestion.value, + type: "info", + showCancelButton: true, + confirmButtonClass: "btn-success", + confirmButtonText: "Sim, enviar!", + cancelButtonText: "Cancelar", + closeOnConfirm: false, + closeOnCancel: false + }, + function (isConfirm) { + var not_sent_title = "Não enviado!"; + 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) { + 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(not_sent_title, "Sua indicação não foi enviada.", "error"); + } + }); + } else { + swal("Cancelado", not_sent_title, "error"); + } + }); + + return false; + } + }); +}); \ 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..2ae781c9 --- /dev/null +++ b/public/wp-content/themes/rhs/inc/recommend-post/recommend_post.php @@ -0,0 +1,93 @@ + 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'), + 'number' => 50, + '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(); + + $current_user = wp_get_current_user(); + + $user_id = $_POST['user_id']; + $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; + } + + 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; + } +} + +add_action('init', function() { + global $RHSRecommendPost; + $RHSRecommendPost = new RHSRecommendPost(); +}); + + 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/stats/stats.php b/public/wp-content/themes/rhs/inc/stats/stats.php index 6910c30b..83131a22 100644 --- a/public/wp-content/themes/rhs/inc/stats/stats.php +++ b/public/wp-content/themes/rhs/inc/stats/stats.php @@ -9,12 +9,14 @@ class RHSStats { const ACTION_REGISTER = 'user_register'; const ACTION_FOLLOW_USER = 'user_follow'; const ACTION_UNFOLLOW_USER = 'user_unfollow'; + const ACTION_DELETED_USER = 'user_deleted'; const ACTION_FOLLOW_POST = 'post_follow'; const ACTION_UNFOLLOW_POST = 'post_unfollow'; 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,10 +40,9 @@ 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')); + add_action( 'rhs_user_deleted', array( &$this, 'user_deleted')); + } function login($user_login, $user) { @@ -75,7 +76,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; @@ -83,6 +88,10 @@ function network_data($post_id, $type) { $this->add_event(self::ACTION_SHARE, $post_id, $user_ID); $this->add_event(self::ACTION_SHARE . '_' . $type, $post_id, $user_ID); } + + function user_deleted($user_id) { + $this->add_event(self::ACTION_DELETED_USER, $user_id, $user_id); + } /** * Adiciona evento @@ -114,7 +123,7 @@ function get_total_events_by_action($action) { } /** - * Verifica se existe tabela, se não, á insere + * Cria a tabela caso não exista */ private function verify_database() { $option_name = 'rhs_database_' . get_class($this); 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/user/user.php b/public/wp-content/themes/rhs/inc/user/user.php index 072a8af8..ed995f39 100644 --- a/public/wp-content/themes/rhs/inc/user/user.php +++ b/public/wp-content/themes/rhs/inc/user/user.php @@ -391,4 +391,5 @@ class="btn btn-info js-add-link"> '; } + } \ No newline at end of file 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']; 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..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,6 +127,10 @@ + + + +