From 19814de0b827eec97670b58546aa74dc087f017d Mon Sep 17 00:00:00 2001 From: Jacson Date: Wed, 13 Jan 2016 14:29:53 -0200 Subject: [PATCH 001/435] Update README.md --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 9a9acca..7480fec 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,16 @@ Como usar? ========== Tudo o que você precisa para rodar este plugin é ter uma instalação de WordPress funcionando e saber como instalar um plugin. Para mais informações veja a [documentação](https://github.com/redelivre/delibera/wiki/Home). + +Acessando pautas: + +Post type = pauta + +Exemplo sem links customizados: +http://www.exemplo.com/?post_type=pauta + +Exemplo com links customizados: +http://www.exemplo.com/pauta/ Como Colaborar? =============== From a190d3e6cda2d93ccb6636f8231970a39303fec3 Mon Sep 17 00:00:00 2001 From: Rosana Waszak Date: Mon, 18 Jan 2016 14:27:57 -0200 Subject: [PATCH 002/435] Corrige largura e alinhamento dos elementos nos temas Creta e Atenas, ajustes responsivos abaixo de 910px Issue #4 --- themes/atenas/delibera_style.css | 20 +++++++++++++++----- themes/creta/delibera_style.css | 13 ++++++++++++- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/themes/atenas/delibera_style.css b/themes/atenas/delibera_style.css index f1b9869..a7a2121 100644 --- a/themes/atenas/delibera_style.css +++ b/themes/atenas/delibera_style.css @@ -203,7 +203,7 @@ p.delibera-participacao a{ padding: 10px 35px; margin:0 10px 0 10px; border-radius: 10px; - width: 790px; + width: 100%; } .archive .form-filtro-ultimos-div { @@ -292,6 +292,7 @@ body.post-type-archive-pauta .entry-meta { line-height: 1.9em; padding:0 10px; margin-top: 40px; + } .post-type-archive-pauta .hentry .entry-content { @@ -433,7 +434,7 @@ span.delibera_seguir_text:hover { .single-pauta .hentry { float: left; background: #fff; - width: 940px; + width: 100%; border-radius: 15px; } @@ -444,7 +445,8 @@ span.delibera_seguir_text:hover { float: left; line-height: 1.9em; padding: 20px 30px; - width: 940px; + width: 100%; + margin: 0px } .single-pauta .entry-utility { @@ -456,7 +458,7 @@ span.delibera_seguir_text:hover { padding-bottom:5px; padding: 0 15px; padding-top:1px; - width:940px; + width:100%; float:left; border:none; } @@ -920,7 +922,7 @@ ul.tab-navigation li a:hover { .post-type-archive-pauta #content, .single-pauta #content { -moz-border-radius: 20px; -webkit-border-radius: 20px; - width: 940px; + width: 100%; margin: 0 auto; } @@ -1652,3 +1654,11 @@ h1.author { font-weight: bold; } + + +/* + Responsivo + ================================================================================*/ +@media screen and (max-width: 910px) { + .site {padding: 20px;} +} diff --git a/themes/creta/delibera_style.css b/themes/creta/delibera_style.css index 40ae6ec..aecec9b 100644 --- a/themes/creta/delibera_style.css +++ b/themes/creta/delibera_style.css @@ -28,6 +28,7 @@ div, h1, h2, h3, h4, h5, p { margin-bottom:9px; } #delibera .filters li { padding:3px 0; + list-style-type: none; } #delibera .filters ul.dates li { @@ -603,4 +604,14 @@ div.error { div.error p { margin: 0.5em 0; padding: 2px; -} \ No newline at end of file +} + +/* + Responsivo + ================================================================================*/ +@media screen and (max-width: 910px) { + .site-content {padding: 20px;} + .filters.widget-area {width: 100%;} + #delibera .site-content {width: 100%;} +} + From b85dbc5eb2ee6a67805a3cf3b7b2a0c5831a010e Mon Sep 17 00:00:00 2001 From: Lucas Pirola Date: Mon, 18 Jan 2016 21:20:47 -0200 Subject: [PATCH 003/435] =?UTF-8?q?Remove=20espa=C3=A7o=20em=20branco?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- delibera.php | 560 +++++++++++++++++++++++++-------------------------- 1 file changed, 280 insertions(+), 280 deletions(-) diff --git a/delibera.php b/delibera.php index df88342..ec1079c 100644 --- a/delibera.php +++ b/delibera.php @@ -61,14 +61,14 @@ function delibera_init() { add_action('admin_menu', 'delibera_config_menu'); - + delibera_Add_custom_Post(); - + delibera_Add_custom_taxonomy(); - + global $delibera_comments_padrao; $delibera_comments_padrao = false; - + } add_action('init','delibera_init'); @@ -76,7 +76,7 @@ function delibera_init() require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_setup.php'; /** - * + * * Revemos acentos do texto * @param string $texto * @return string @@ -100,10 +100,10 @@ function delibera_slug_under($label) function is_pauta($post = false) { return get_post_type($post) == 'pauta' ? true : false; -} +} /** - * + * * Insere term no banco e atualizar línguas do qtranslate * @param string $label * @param string $tax Taxonomy @@ -149,12 +149,12 @@ function delibera_Add_custom_Post() 'view_item' => __('Visualizar Pauta','delibera'), 'search_items' => __('Procurar Pautas','delibera'), 'not_found' => __('Nenhuma Pauta localizada','delibera'), - 'not_found_in_trash' => __('Nenhuma Pauta localizada na lixeira','delibera'), + 'not_found_in_trash' => __('Nenhuma Pauta localizada na lixeira','delibera'), 'parent_item_colon' => '', 'menu_name' => __('Pautas','delibera') - + ); - + $args = array ( 'label' => __('Pautas','delibera'), @@ -166,8 +166,8 @@ function delibera_Add_custom_Post() 'show_ui' => true, // public 'show_in_menu' => true, 'menu_position' => 5, - // 'menu_icon' => '', - 'capability_type' => array('pauta','pautas'), + // 'menu_icon' => '', + 'capability_type' => array('pauta','pautas'), 'map_meta_cap' => true, 'hierarchical' => false, 'supports' => array('title', 'editor', 'author', 'excerpt', 'trackbacks', 'revisions', 'comments'), @@ -179,9 +179,9 @@ function delibera_Add_custom_Post() 'query_var' => true, 'can_export' => true//, // veja abaixo //'show_in_nav_menus' => '', // public - //'_builtin' => '', // Core + //'_builtin' => '', // Core //'_edit_link' => '' // Core - + ); register_post_type("pauta", $args); @@ -191,7 +191,7 @@ function delibera_pauta_redirect_filter($location, $post_id = null) { if (strpos($_SERVER['HTTP_REFERER'], "post_type=pauta")) return admin_url("edit.php")."?post_type=pauta&updated=1"; - else + else return $location; } add_filter('redirect_post_location', 'delibera_pauta_redirect_filter', '99'); @@ -213,10 +213,10 @@ function delibera_Add_custom_taxonomy() 'new_item_name' => __('Novo Tema','delibera'), 'view_item' => __('Visualizar Tema','delibera'), 'not_found' => __('Nenhum Tema localizado','delibera'), - 'not_found_in_trash' => __('Nenhum Tema localizado na lixeira','delibera'), + 'not_found_in_trash' => __('Nenhum Tema localizado na lixeira','delibera'), 'menu_name' => __('Temas','delibera') ); - + $args = array ( 'label' => __('Temas','delibera'), @@ -228,15 +228,15 @@ function delibera_Add_custom_taxonomy() // 'show_ui' => '', // Public 'hierarchical' => true, //'update_count_callback' => '', //Contar objetos associados - 'rewrite' => true, + 'rewrite' => true, //'query_var' => '', - //'_builtin' => '' // Core + //'_builtin' => '' // Core ); - + register_taxonomy('tema', array('pauta'), $args); - - - + + + $labels = array ( 'name' => __('Situações','delibera'), @@ -252,10 +252,10 @@ function delibera_Add_custom_taxonomy() 'new_item_name' => __('Nova Situação','delibera'), 'view_item' => __('Visualizar Situação','delibera'), 'not_found' => __('Nenhuma Situação localizado','delibera'), - 'not_found_in_trash' => __('Nenhuma Situação localizada na lixeira','delibera'), + 'not_found_in_trash' => __('Nenhuma Situação localizada na lixeira','delibera'), 'menu_name' => __('Situações','delibera') ); - + $args = array ( 'label' => __('Situações','delibera'), @@ -265,11 +265,11 @@ function delibera_Add_custom_taxonomy() //'show_ui' => true, // Public 'hierarchical' => false//, //'update_count_callback' => '', //Contar objetos associados - //'rewrite' => '', // + //'rewrite' => '', // //'query_var' => '', - //'_builtin' => '' // Core + //'_builtin' => '' // Core ); - + register_taxonomy('situacao', array('pauta'), $args); // Se precisar trocar os nomes dos terms denovo @@ -283,9 +283,9 @@ function delibera_Add_custom_taxonomy() wp_update_term($term->term_id, 'situacao', array('name' => 'Proposta de Pauta')); $term = get_term_by('slug', 'naovalidada', 'situacao'); wp_update_term($term->term_id, 'situacao', array('name' => 'Pauta Recusada'));*/ - + $opt = delibera_get_config(); - + if(taxonomy_exists('situacao')) { if(term_exists('comresolucao', 'situacao', null) == false) @@ -332,7 +332,7 @@ function delibera_Add_custom_taxonomy() ); } } - + if(term_exists('relatoria', 'situacao', null) == false) { delibera_insert_term('Relatoria', 'situacao', array( @@ -390,12 +390,12 @@ function delibera_Add_custom_taxonomy() } } } - + if(file_exists(__DIR__.DIRECTORY_SEPARATOR.'delibera_taxs.php')) { require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_taxs.php'; } - + } require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_themes.php'; @@ -414,7 +414,7 @@ function delibera_get_comment_type($comment) /** * Retorna o nome "amigável" do tipo de um comentário. - * + * * @param object $comment * @param string $tipo * @param bool $echo @@ -435,7 +435,7 @@ function delibera_get_comment_type_label($comment, $tipo = false, $echo = true) return __('Proposta', 'delibera'); break; case 'voto': - if($echo) _e('Voto', 'delibera'); + if($echo) _e('Voto', 'delibera'); return __('Voto', 'delibera'); break; case 'resolucao': @@ -454,18 +454,18 @@ function delibera_get_comment_type_label($comment, $tipo = false, $echo = true) * Retorna uma string com a quantidade de comentários * associados a pauta do tipo correspondente a situação * atual. - * + * * @param int $postId * @return string (exemplo: "5 votos") */ function delibera_get_comments_count_by_type($postId) { $situacao = delibera_get_situacao($postId); - + switch ($situacao->slug) { case 'validacao': $count = count(delibera_get_comments_validacoes($postId)); - + if ($count == 0) { $label = __('Nenhuma validação', 'delibera'); } else if ($count == 1) { @@ -473,11 +473,11 @@ function delibera_get_comments_count_by_type($postId) } else { $label = sprintf(__('%d validações', 'delibera'), $count); } - + return $label; case 'discussao': $count = count(delibera_get_comments_discussoes($postId)); - + if ($count == 0) { $label = __('Nenhum comentário', 'delibera'); } else if ($count == 1) { @@ -485,11 +485,11 @@ function delibera_get_comments_count_by_type($postId) } else { $label = sprintf(__('%d comentários', 'delibera'), $count); } - + return $label; case 'emvotacao': $count = count(delibera_get_comments_votacoes($postId)); - + if ($count == 0) { $label = __('Nenhum voto', 'delibera'); } else if ($count == 1) { @@ -497,7 +497,7 @@ function delibera_get_comments_count_by_type($postId) } else { $label = sprintf(__('%d votos', 'delibera'), $count); } - + return $label; } } @@ -515,7 +515,7 @@ function delibera_pauta_custom_meta() function delibera_forca_fim_prazo($postID) { $situacao = delibera_get_situacao($postID); - + switch($situacao->slug) { case 'discussao': @@ -546,11 +546,11 @@ function delibera_admin_list_options($actions, $post) $url = 'admin.php?action=delibera_forca_fim_prazo_action&post='.$post->ID; $url = wp_nonce_url($url, 'delibera_forca_fim_prazo_action'.$post->ID); $actions['forcar_prazo'] = ''.__('Forçar fim de prazo','delibera').''; - + $url = 'admin.php?action=delibera_nao_validado_action&post='.$post->ID; $url = wp_nonce_url($url, 'delibera_nao_validado_action'.$post->ID); $actions['nao_validado'] = ''.__('Invalidar','delibera').''; - + } if(delibera_get_situacao($post->ID)->slug == 'naovalidada' && current_user_can('delibera_reabrir_pauta')) { @@ -558,54 +558,54 @@ function delibera_admin_list_options($actions, $post) $url = wp_nonce_url($url, 'delibera_reabrir_pauta_action'.$post->ID); $actions['reabrir'] = ''.__('Reabrir','delibera').''; } - + } - + //print_r(_get_cron_array()); return $actions; } add_filter('post_row_actions','delibera_admin_list_options', 10, 2); -function delibera_forca_fim_prazo_action() +function delibera_forca_fim_prazo_action() { - if(current_user_can('forcar_prazo') && check_admin_referer('delibera_forca_fim_prazo_action'.$_REQUEST['post'], '_wpnonce')) + if(current_user_can('forcar_prazo') && check_admin_referer('delibera_forca_fim_prazo_action'.$_REQUEST['post'], '_wpnonce')) { delibera_forca_fim_prazo($_REQUEST['post']); - + wp_redirect( admin_url( 'edit.php?post_type=pauta') ); } - else + else { wp_die(__('Você não tem permissão para forçar um prazo','delibera'), __('Sem permissão','delibera')); } } add_action('admin_action_delibera_forca_fim_prazo_action', 'delibera_forca_fim_prazo_action'); -function delibera_nao_validado_action() +function delibera_nao_validado_action() { - if(current_user_can('forcar_prazo') && check_admin_referer('delibera_nao_validado_action'.$_REQUEST['post'], '_wpnonce')) + if(current_user_can('forcar_prazo') && check_admin_referer('delibera_nao_validado_action'.$_REQUEST['post'], '_wpnonce')) { delibera_marcar_naovalidada($_REQUEST['post']); - + wp_redirect( admin_url( 'edit.php?post_type=pauta') ); } - else + else { wp_die(__('Você não tem permissão para invalidar uma pauta','delibera'), __('Sem permissão','delibera')); } } add_action('admin_action_delibera_nao_validado_action', 'delibera_nao_validado_action'); -function delibera_reabrir_pauta_action() +function delibera_reabrir_pauta_action() { - if(current_user_can('delibera_reabrir_pauta') && check_admin_referer('delibera_reabrir_pauta_action'.$_REQUEST['post'], '_wpnonce')) + if(current_user_can('delibera_reabrir_pauta') && check_admin_referer('delibera_reabrir_pauta_action'.$_REQUEST['post'], '_wpnonce')) { delibera_reabrir_pauta($_REQUEST['post']); - + wp_redirect( admin_url( 'edit.php?post_type=pauta') ); } - else + else { wp_die(__('Você não tem permissão para re-abrir discussão sobre uma pauta','delibera'), __('Sem permissão','delibera')); } @@ -615,7 +615,7 @@ function delibera_reabrir_pauta_action() require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_cron.php'; /** - * + * * Retorna a situação do post * @param int $postID * @return mixed validacao, discussao, elegerelator, relatoria, emvotacao, comresolucao, naovalidada ou false @@ -628,33 +628,33 @@ function delibera_get_situacao($postID) { $ret = array_pop($situacao); } - + if(!is_object($ret)) // if term situacao does not exists { $ret = new stdClass(); $ret->slug = ''; $ret->name = ''; } - + if(has_filter('delibera_get_situacao')) { return apply_filters('delibera_get_situacao', $ret); } - + return $ret; } /** * Retorna o label do botão com a situação da * pauta. - * + * * @param int $postId * @return string */ function delibera_get_situation_button($postId) { $situacao = get_the_terms($postId, 'situacao'); - + if (is_array($situacao) && !empty($situacao)) { $situacao = array_pop($situacao); } @@ -682,14 +682,14 @@ function delibera_pauta_meta() $custom = get_post_custom($post->ID); $options_plugin_delibera = delibera_get_config(); - + if(!is_array($custom)) $custom = array(); $validacoes = array_key_exists("numero_validacoes", $custom) ? $custom["numero_validacoes"][0] : 0; - + $min_validacoes = array_key_exists("min_validacoes", $custom) ? $custom["min_validacoes"][0] : htmlentities($options_plugin_delibera['minimo_validacao']); - + $situacao = delibera_get_situacao($post->ID); - + $dias_validacao = intval(htmlentities($options_plugin_delibera['dias_validacao'])); $dias_discussao = intval(htmlentities($options_plugin_delibera['dias_discussao'])); $dias_relatoria = intval(htmlentities($options_plugin_delibera['dias_relatoria'])); @@ -709,13 +709,13 @@ function delibera_pauta_meta() { $dias_discussao += $dias_validacao; } - + $dias_votacao = $dias_discussao + intval(htmlentities($options_plugin_delibera['dias_votacao'])); - + if($options_plugin_delibera['relatoria'] == "S") // Adiciona prazo de relatoria se for necessário { $dias_votacao += $dias_relatoria; - $dias_relatoria += $dias_discussao; + $dias_relatoria += $dias_discussao; if($options_plugin_delibera['eleicao_relator'] == "S") // Adiciona prazo de vatacao relator se for necessário { $dias_votacao += $dias_votacao_relator; @@ -723,21 +723,21 @@ function delibera_pauta_meta() $dias_votacao_relator += $dias_discussao; } } - + $now = strtotime(date('Y/m/d')." 11:59:59"); - + $prazo_validacao_sugerido = strtotime("+$dias_validacao days", $now); $prazo_discussao_sugerido = strtotime("+$dias_discussao days", $now); $prazo_eleicao_relator_sugerido = strtotime("+$dias_votacao_relator days", $now); $prazo_relatoria_sugerido = strtotime("+$dias_relatoria days", $now); $prazo_votacao_sugerido = strtotime("+$dias_votacao days", $now); - + $prazo_validacao = date('d/m/Y', $prazo_validacao_sugerido); $prazo_discussao = date('d/m/Y', $prazo_discussao_sugerido); $prazo_eleicao_relator = date('d/m/Y', $prazo_eleicao_relator_sugerido); - $prazo_relatoria = date('d/m/Y', $prazo_relatoria_sugerido); + $prazo_relatoria = date('d/m/Y', $prazo_relatoria_sugerido); $prazo_votacao = date('d/m/Y', $prazo_votacao_sugerido); - + if ( $options_plugin_delibera['representante_define_prazos'] == "N" && !($post->post_status == 'draft' || @@ -749,7 +749,7 @@ function delibera_pauta_meta() } else { $disable_edicao = ''; } - + if(!($post->post_status == 'draft' || $post->post_status == 'auto-draft' || $post->post_status == 'pending')) @@ -757,14 +757,14 @@ function delibera_pauta_meta() $prazo_validacao = array_key_exists("prazo_validacao", $custom) ? $custom["prazo_validacao"][0] : $prazo_validacao; $prazo_discussao = array_key_exists("prazo_discussao", $custom) ? $custom["prazo_discussao"][0] : $prazo_discussao; $prazo_eleicao_relator = array_key_exists("prazo_eleicao_relator", $custom) ? $custom["prazo_eleicao_relator"][0] : $prazo_eleicao_relator; - $prazo_relatoria = array_key_exists("prazo_relatoria", $custom) ? $custom["prazo_relatoria"][0] : $prazo_relatoria; + $prazo_relatoria = array_key_exists("prazo_relatoria", $custom) ? $custom["prazo_relatoria"][0] : $prazo_relatoria; $prazo_votacao = array_key_exists("prazo_votacao", $custom) ? $custom["prazo_votacao"][0] : $prazo_votacao; } if($options_plugin_delibera['validacao'] == "S") { ?> -

+

id="min_validacoes" name="min_validacoes" class="min_validacoes widefat" value=""/>

@@ -773,13 +773,13 @@ function delibera_pauta_meta() id="prazo_validacao" name="prazo_validacao" class="prazo_validacao widefat hasdatepicker" value=""/>

id="prazo_discussao" name="prazo_discussao" class="prazo_discussao widefat hasdatepicker" value=""/>

- slug == 'validacao') + if($situacao->slug == 'validacao') { delibera_marcar_naovalidada($args['post_ID']); } @@ -963,7 +963,7 @@ function delibera_tratar_prazo_validacao($args) function delibera_tratar_prazo_discussao($args) { $situacao = delibera_get_situacao($args['post_ID']); - if($situacao->slug == 'discussao') + if($situacao->slug == 'discussao') { $post_id = $args['post_ID']; if(count(delibera_get_comments_encaminhamentos($post_id)) > 0) @@ -977,7 +977,7 @@ function delibera_tratar_prazo_discussao($args) { wp_set_object_terms($post_id, 'relatoria', 'situacao', false); //Mudar situação para Votação } - else + else { wp_set_object_terms($post_id, 'emvotacao', 'situacao', false); //Mudar situação para Votação } @@ -996,7 +996,7 @@ function delibera_tratar_prazo_discussao($args) function delibera_tratar_prazo_relatoria($args) { $situacao = delibera_get_situacao($args['post_ID']); - if($situacao->slug == 'relatoria') + if($situacao->slug == 'relatoria') { $post_id = $args['post_ID']; if(count(delibera_get_comments_encaminhamentos($post_id)) > 0) @@ -1018,7 +1018,7 @@ function delibera_tratar_prazo_relatoria($args) function delibera_tratar_prazo_votacao($args) { $situacao = delibera_get_situacao($args['post_ID']); - if($situacao->slug == 'emvotacao') + if($situacao->slug == 'emvotacao') { delibera_computa_votos($args['post_ID']); } @@ -1037,15 +1037,15 @@ function delibera_reabrir_pauta($postID) { wp_set_object_terms($postID, 'validacao', 'situacao', false); //delibera_notificar_situacao($postID); - + delibera_novo_prazo($postID); } /** - * + * * Save o post da pauta * @param $post_id int - * @param $post + * @param $post */ function delibera_save_post($post_id, $post) { @@ -1055,10 +1055,10 @@ function delibera_save_post($post_id, $post) } $opt = delibera_get_config(); $autosave = ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ); - + if( ( // Se tem validação, tem que ter o prazo - $opt['validacao'] == 'N' || + $opt['validacao'] == 'N' || (array_key_exists('prazo_validacao', $_POST) && array_key_exists('min_validacoes', $_POST) ) ) && ( // Se tem relatoria, tem que ter o prazo @@ -1068,7 +1068,7 @@ function delibera_save_post($post_id, $post) ( // Se tem relatoria, e é preciso eleger o relator, tem que ter o prazo para eleição $opt['relatoria'] == 'N' || ( - $opt['eleicao_relator'] == 'N' || + $opt['eleicao_relator'] == 'N' || array_key_exists('prazo_eleicao_relator', $_POST) ) ) && @@ -1077,7 +1077,7 @@ function delibera_save_post($post_id, $post) ) { $events_meta = array(); - + $validacoes = get_post_meta($post_id, 'numero_validacoes', true); if($validacoes == "" || $validacoes === false || is_null($validacoes)) { @@ -1094,7 +1094,7 @@ function delibera_save_post($post_id, $post) $events_meta['delibera_numero_seguir'] = 0; $events_meta['delibera_seguiram'] = array(); } - + $events_meta['prazo_validacao'] = $opt['validacao'] == 'S' ? $_POST['prazo_validacao'] : date('d/m/Y'); $events_meta['prazo_discussao'] = $_POST['prazo_discussao']; $events_meta['prazo_relatoria'] = $opt['relatoria'] == 'S' ? $_POST['prazo_relatoria'] : date('d/m/Y'); @@ -1141,7 +1141,7 @@ function delibera_save_post($post_id, $post) { update_post_meta($post->ID, $key, $value); // Atualiza } - else + else { add_post_meta($post->ID, $key, $value, true); // Senão, cria } @@ -1155,13 +1155,13 @@ function delibera_save_post($post_id, $post) { delibera_forca_fim_prazo($post->ID); } - + if($post->post_status == 'publish' && !$autosave) { delibera_del_cron($post->ID); delibera_publish_pauta($post->ID, $post, true); } - + } } @@ -1184,13 +1184,13 @@ function delibera_publish_pauta($postID, $post, $alterar = false) { return $postID; } - - if ( + + if ( $alterar || ( - ($post->post_status == 'publish' || $_POST['publish'] == 'Publicar') && + ($post->post_status == 'publish' || $_POST['publish'] == 'Publicar') && ( ( - array_key_exists('prev_status', $_POST) && + array_key_exists('prev_status', $_POST) && ( $_POST['prev_status'] == 'draft' || $_POST['prev_status'] == 'pending' @@ -1212,15 +1212,15 @@ function delibera_publish_pauta($postID, $post, $alterar = false) $prazo_eleicao_relator = get_post_meta($postID, 'prazo_eleicao_relator', true); $prazo_votacao = get_post_meta($postID, 'prazo_votacao', true); $opt = delibera_get_config(); - + if(!array_key_exists('validacao', $opt) || $opt['validacao'] == 'S' ) { if(!$alterar) { - + wp_set_object_terms($post->ID, 'validacao', 'situacao', false); } - + delibera_criar_agenda( $post->ID, $prazo_validacao, @@ -1230,7 +1230,7 @@ function delibera_publish_pauta($postID, $post, $alterar = false) $opt['relatoria'] == 'S' && $opt['eleicao_relator'] == 'S' ? $prazo_eleicao_relator : false ); } - else + else { if(!$alterar) { @@ -1245,12 +1245,12 @@ function delibera_publish_pauta($postID, $post, $alterar = false) $opt['relatoria'] == 'S' && $opt['eleicao_relator'] == 'S' ? $prazo_eleicao_relator : false ); } - + if($alterar) { //delibera_notificar_situacao($post); } - else + else { delibera_notificar_nova_pauta($post); } @@ -1272,61 +1272,61 @@ function delibera_check_post_data($data, $postarr) $valida = delibera_tratar_data($value); if(!$autosave && ($valida === false || $valida < 1)) { - $erros[] = __("É necessário definir corretamente o prazo de validação", "delibera"); - } + $erros[] = __("É necessário definir corretamente o prazo de validação", "delibera"); + } } $value = $_POST['prazo_discussao']; $valida = delibera_tratar_data($value); if(!$autosave && ($valida === false || $valida < 1)) { - $erros[] = __("É necessário definir corretamente o prazo de discussão", "delibera"); + $erros[] = __("É necessário definir corretamente o prazo de discussão", "delibera"); } - + if($opt['relatoria'] == 'S') { $value = $_POST['prazo_relatoria']; $valida = delibera_tratar_data($value); if(!$autosave && ($valida === false || $valida < 1)) { - $erros[] = __("É necessário definir corretamente o prazo para relatoria", "delibera"); + $erros[] = __("É necessário definir corretamente o prazo para relatoria", "delibera"); } - + if($opt['eleicao_relator'] == 'S') { $value = $_POST['prazo__leicao_relator']; $valida = delibera_tratar_data($value); if(!$autosave && ($valida === false || $valida < 1)) { - $erros[] = __("É necessário definir corretamente o prazo para eleição de um relator", "delibera"); + $erros[] = __("É necessário definir corretamente o prazo para eleição de um relator", "delibera"); } } - + } - + $value = $_POST['prazo_votacao']; $valida = delibera_tratar_data($value); if(!$autosave && ($valida === false || $valida < 1)) { - $erros[] = __("É necessário definir corretamente o prazo para votação", "delibera"); + $erros[] = __("É necessário definir corretamente o prazo para votação", "delibera"); } - + if($opt['validacao'] == 'S') { $value = (int)$_POST['min_validacoes']; $valida = is_int($value) && $value > 0; if(!$autosave && ($valida === false)) { - $erros[] = __("É necessário definir corretamente o número mínimo de validações", "delibera"); - } + $erros[] = __("É necessário definir corretamente o número mínimo de validações", "delibera"); + } } - + if( count($erros) == 0 ) { return $data; } - else + else { //wp_die(__('Erro ao salvar dados da pauta, faltando informações de prazos e validações mínimas!','delibera')); wp_die(implode("
", $erros)); @@ -1339,7 +1339,7 @@ function delibera_check_post_data($data, $postarr) function delibera_get_comments_link() { global $post; - + return get_permalink($post->ID) . '#delibera-comments'; } @@ -1355,23 +1355,23 @@ function delibera_get_comment_link($comment_pass = false) { return str_replace('#comment', '#delibera-comment', get_comments_link()); } - + return str_replace('#comment', '#delibera-comment', get_comment_link($comment)); } function delibera_comment_post_redirect( $location ) { global $post, $comment_id; - - return ( $post->post_type == 'pauta' ) ? preg_replace("/#comment-([\d]+)/", "#delibera-comment-" . $comment_id, $location) : $location; + + return ( $post->post_type == 'pauta' ) ? preg_replace("/#comment-([\d]+)/", "#delibera-comment-" . $comment_id, $location) : $location; } add_filter( 'comment_post_redirect', 'delibera_comment_post_redirect' ); /** - * + * * Comentário em listagem (Visualização) * @param string $commentText */ -function delibera_comment_text($commentText) +function delibera_comment_text($commentText) { global $comment, $post, $delibera_comments_padrao; if(get_post_type($post) == "pauta" && $delibera_comments_padrao !== true) @@ -1382,7 +1382,7 @@ function delibera_comment_text($commentText) $total = 0; $nvotos = 0; switch ($tipo) - { + { case 'validacao': { $validacao = get_comment_meta($comment->comment_ID, "delibera_validacao", true); @@ -1448,7 +1448,7 @@ function delibera_comment_text($commentText) }break; case 'voto': { - $commentText = ' + $commentText = '
'.$commentText.'
@@ -1461,7 +1461,7 @@ function delibera_comment_text($commentText) } return $commentText; } - else + else { return '
'.$commentText.'
'; } @@ -1481,7 +1481,7 @@ function delibera_comment_text_filtro($text, $comment_id = false, $show = true) } $string_temp = wordwrap($text, $tamanho, '##!##'); $cut = strpos($string_temp, '##!##'); - + $text = delibera_show_hide_button($comment_id, $text, $cut, $show); } return $text; @@ -1502,7 +1502,7 @@ function delibera_show_hide_button($comment_id, $text, $cut, $show) $part = '
'; $part .= truncate($text, $cut, '…'); $part .= '
'; - + $comment_text = $part.$showhide.$text."".$showhide_button; } else @@ -1511,13 +1511,13 @@ function delibera_show_hide_button($comment_id, $text, $cut, $show) $comment_text = truncate($text, $cut,'…').'
'.$link; } - + return $comment_text; } /** - * - * + * + * * @param string $text String to truncate. * @param integer $length Length of returned string, including ellipsis. * @param string $ending Ending to be appended to the trimmed string. @@ -1617,7 +1617,7 @@ function truncate($text, $length = 100, $ending = '...', $exact = false, $consid } /** - * + * * Comentário na tela de Edição na administração * @param WP_comment $comment */ @@ -1627,7 +1627,7 @@ function delibera_edit_comment($comment) { $tipo = get_comment_meta($comment->comment_ID, "delibera_comment_tipo", true); switch ($tipo) - { + { case 'validacao': { $validacao = get_comment_meta($comment->comment_ID, "delibera_validacao", true); @@ -1681,10 +1681,10 @@ function delibera_can_comment($postID = '') $post = get_post($postID); $postID = $post->ID; } - + $situacoes_validas = array('validacao' => true, 'discussao' => true, 'emvotacao' => true, 'elegerelator' => true); $situacao = delibera_get_situacao($postID); - + if(array_key_exists($situacao->slug, $situacoes_validas)) { return delibera_current_user_can_participate(); @@ -1716,10 +1716,10 @@ function delibera_comments_is_open($postID = null) $post = get_post($postID); $postID = $post->ID; } - + $situacoes_validas = array('validacao' => true, 'discussao' => true, 'emvotacao' => true, 'elegerelator' => true,'relatoria'=>true); $situacao = delibera_get_situacao($postID); - + if(array_key_exists($situacao->slug, $situacoes_validas)) { return $situacoes_validas[$situacao->slug]; @@ -1749,14 +1749,14 @@ function delibera_comment_form_action($postID) add_action('comment_form', 'delibera_comment_form_action'); /** - * + * * Salvar custom fields do comentário * @param int $comment_id */ -function delibera_save_comment_metas($comment_id) +function delibera_save_comment_metas($comment_id) { $tipo = get_comment_meta($comment_id, "delibera_comment_tipo", true); - + if($tipo == false || $tipo == "") { if(array_key_exists("delibera_comment_tipo", $_POST)) @@ -1764,20 +1764,20 @@ function delibera_save_comment_metas($comment_id) $tipo = $_POST['delibera_comment_tipo']; } } - + delibera_curtir_comment_meta($comment_id); - + delibera_discordar_comment_meta($comment_id); - + $comment = get_comment($comment_id); - + switch($tipo) { case "validacao": { add_comment_meta($comment_id, 'delibera_validacao', $_POST['delibera_validacao'], true); add_comment_meta($comment_id, 'delibera_comment_tipo', 'validacao', true); - + if($_POST['delibera_validacao'] == "S") { $validacoes = get_post_meta($comment->comment_post_ID, 'numero_validacoes', true); @@ -1789,7 +1789,7 @@ function delibera_save_comment_metas($comment_id) $nvalidacoes++; update_post_meta($comment->comment_post_ID, 'delibera_numero_comments_validacoes', $nvalidacoes); }break; - + case 'discussao': case 'encaminhamento': { @@ -1805,7 +1805,7 @@ function delibera_save_comment_metas($comment_id) add_comment_meta($comment_id, 'delibera-baseouseem', $_POST['delibera-baseouseem'], true); } } - else + else { add_comment_meta($comment_id, 'delibera_comment_tipo', 'discussao', true); $ndiscussoes = get_post_meta($comment->comment_post_ID, 'delibera_numero_comments_discussoes', true); @@ -1819,11 +1819,11 @@ function delibera_save_comment_metas($comment_id) }break; case 'voto': { - + add_comment_meta($comment_id, 'delibera_comment_tipo', 'voto', true); - + $votos = array(); - + foreach ($_POST as $postkey => $postvar) { if( substr($postkey, 0, strlen('delibera_voto')) == 'delibera_voto' ) @@ -1831,23 +1831,23 @@ function delibera_save_comment_metas($comment_id) $votos[] = $postvar; } } - + add_comment_meta($comment_id, 'delibera_votos', $votos, true); - + $comment = get_comment($comment_id); delibera_valida_votos($comment->comment_post_ID); - + $nvotos = get_post_meta($comment->comment_post_ID, 'delibera_numero_comments_votos', true); $nvotos++; update_post_meta($comment->comment_post_ID, 'delibera_numero_comments_votos', $nvotos); - + if(has_action('delibera_novo_voto')) { do_action('delibera_novo_voto', $comment_id, $comment, $votos); } - + } break; - + default: { $npadroes = get_post_meta($comment->comment_post_ID, 'delibera_numero_comments_padroes', true); @@ -1878,12 +1878,12 @@ function delibera_pre_edit_comment($dados) { $comment_id = $comment->comment_ID; } - else + else { wp_die(__('Você não pode Editar esse tipo de comentário','delibera')); } } - + $tipo = get_comment_meta($comment_id, "delibera_comment_tipo", true); if(array_search($tipo, delibera_get_comments_types()) !== false) { @@ -1903,9 +1903,9 @@ function delibera_config_menu() { /*if (function_exists('add_menu_page')) add_menu_page( __('Delibera','delibera'), __('Delibera plugin','delibera'), 'manage_options', 'delibera-config', 'delibera_conf_page');*/ - + $base_page = 'delibera-config'; - + if (function_exists('add_menu_page')) { add_object_page( __('Delibera','delibera'), __('Delibera','delibera'), 'manage_options', $base_page, array(), WP_PLUGIN_URL."/delibera/images/delibera_icon.png"); @@ -1924,20 +1924,20 @@ function delibera_form_table($rows) { $content = ''; foreach ($rows as $row) { $content .= ''; + $content .= ''; } $content .= '
'; - + if (isset($row['id']) && $row['id'] != '') { $content .= ''; } else { $content .= $row['label']; } - + if (isset($row['desc']) && $row['desc'] != '') { $content .= '
'.$row['desc'].''; } $content .= '
'; $content .= $row['content']; - $content .= '
'; return $content; @@ -1948,7 +1948,7 @@ function delibera_form_table($rows) { function delibera_scripts() { global $post; - + if (is_pauta()) { wp_enqueue_script('jquery-expander', WP_CONTENT_URL.'/plugins/delibera/js/jquery.expander.js', array('jquery')); wp_enqueue_script('delibera', WP_CONTENT_URL.'/plugins/delibera/js/scripts.js', array('jquery-expander')); @@ -1956,29 +1956,29 @@ function delibera_scripts() wp_enqueue_script('delibera-concordar', WP_CONTENT_URL . '/plugins/delibera/js/delibera_concordar.js', array('delibera')); $situation = delibera_get_situacao($post->ID); - + $data = array( 'post_id' => $post->ID, 'ajax_url' => admin_url('admin-ajax.php'), ); - + if (is_object($situation)) { $data['situation'] = $situation->slug; } - + wp_localize_script('delibera', 'delibera', $data); } } add_action( 'wp_print_scripts', 'delibera_scripts' ); /** - * + * * Se tiver estilos customizados, ta aí a dica... * function delibera_print_styles() { - -} + +} add_action('wp_print_styles', 'delibera_print_styles');*/ function delibera_print_styles() @@ -1986,9 +1986,9 @@ function delibera_print_styles() if (is_pauta()) { wp_enqueue_style('jquery-ui-custom', plugins_url() . '/delibera/css/jquery-ui-1.9.2.custom.min.css'); } - + wp_enqueue_style('delibera_style', WP_CONTENT_URL.'/plugins/delibera/css/delibera.css'); -} +} add_action('admin_print_styles', 'delibera_print_styles'); function delibera_admin_scripts() @@ -1998,7 +1998,7 @@ function delibera_admin_scripts() wp_enqueue_script('jquery-ui-datepicker-ptbr', WP_CONTENT_URL.'/plugins/delibera/js/jquery.ui.datepicker-pt-BR.js', array('jquery-ui-datepicker')); wp_enqueue_script('delibera-admin',WP_CONTENT_URL.'/plugins/delibera/js/admin_scripts.js', array( 'jquery-ui-datepicker-ptbr')); } - + if(isset($_REQUEST['page']) && $_REQUEST['page'] == 'delibera-notifications') { wp_enqueue_script('delibera-admin-notifica',WP_CONTENT_URL.'/plugins/delibera/js/admin_notifica_scripts.js', array('jquery')); @@ -2011,7 +2011,7 @@ function delibera_admin_scripts() // Funções de conteudo /** - * + * * Retorna post do tipo pauta em uma determinada situacao (validacao, discussao, emvotacao ou comresolucao), usando um filtro * @param array $filtro * @param string $situacao @@ -2021,7 +2021,7 @@ function delibera_get_pautas_em($filtro = array(), $situacao = false) $filtro['post_type'] = "pauta"; $filtro['post_status'] = "publish"; $tax_query = array(); - + if(array_key_exists("tax_query", $filtro) && $situacao !== false) { $tax_query = $filtro['tax_query']; @@ -2040,7 +2040,7 @@ function delibera_get_pautas_em($filtro = array(), $situacao = false) } /** - * + * * Retorna pautas em Validação * @param array $filtro */ @@ -2050,7 +2050,7 @@ function delibera_get_propostas($filtro = array()) } /** - * + * * Retorna pautas em Discussão * @param array $filtro */ @@ -2074,7 +2074,7 @@ function delibera_des_filtro_qtranslate($where) add_filter('posts_where_request', 'delibera_des_filtro_qtranslate', 11); /** - * + * * Retorna pautas em Votação * @param array $filtro */ @@ -2084,7 +2084,7 @@ function delibera_get_emvotacao($filtro = array()) } /** - * + * * Retorna pautas já resolvidas * @param array $filtro */ @@ -2105,17 +2105,17 @@ function delibera_get_comments_padrao($args = array(), $file = '/comments.php' ) /** * Retorna comentários do Delibera de acordo com o tipo. - * + * * @param int $post_id * @param string|array $tipo um tipo ou um array de tipos - * @return array + * @return array */ function delibera_get_comments($post_id, $tipo, $args = array()) { if (is_string($tipo)) { $tipo = array($tipo); } - + $args = array_merge(array('post_id' => $post_id), $args); $comments = get_comments($args); $ret = array(); @@ -2136,7 +2136,7 @@ function delibera_wp_list_comments($args = array(), $comments = null) { global $post; global $delibera_comments_padrao; - + if(get_post_type($post) == "pauta") { $situacao = delibera_get_situacao($post->ID); @@ -2164,30 +2164,30 @@ function delibera_wp_list_comments($args = array(), $comments = null) //$args['callback'] = 'delibera_comments_list'; ?>
-
- slug == 'comresolucao') { $args['walker'] = new Delibera_Walker_Comment(); wp_list_comments($args, $comments); - + $encaminhamentos = delibera_get_comments_encaminhamentos($post->ID); $discussoes = delibera_get_comments_discussoes($post->ID); ?>
- +

- + comment_ID, 'delibera_comment_tipo', true); @@ -2300,7 +2300,7 @@ function delibera_comments_filter_portipo($comments, $tipos) } /** - * + * * Filtro que retorna Comentário filtrados pela a situação da pauta * @param array $comments * @param int $postID @@ -2309,11 +2309,11 @@ function delibera_comments_filter_portipo($comments, $tipos) function delibera_get_comments_filter($comments) { global $delibera_comments_padrao; - + if($delibera_comments_padrao === true) return $comments; - + $ret = array(); - + if(count($comments) > 0) { if(get_post_type($comments[0]->comment_post_ID) == "pauta") @@ -2339,7 +2339,7 @@ function delibera_get_comments_filter($comments) }break; case 'comresolucao': { - $ret = delibera_comments_filter_portipo($comments, array('resolucao')); + $ret = delibera_comments_filter_portipo($comments, array('resolucao')); }break; } return $ret; @@ -2353,10 +2353,10 @@ function delibera_get_comments_filter($comments) /** * Retorna um inteiro indicando quantos dias faltam para o fim do prazo * de uma pauta. - * + * * Se o parâmetro $data for passado por referência o prazo para o fim da * pauta é associado a ele. - * + * * @param int $postID * @param string $data * @return int @@ -2367,11 +2367,11 @@ function delibera_get_prazo($postID, &$data = null) $prazo = ""; $idata = strtotime(date('Y/m/d').' 23:59:59'); $diff = -1; - + if(is_object($situacao)) { switch ($situacao->slug) - { + { case 'validacao': { $prazo = get_post_meta($postID, 'prazo_validacao', true); @@ -2393,17 +2393,17 @@ function delibera_get_prazo($postID, &$data = null) $prazo = get_post_meta($postID, 'prazo_votacao', true); } break; } - + $iprazo = strtotime(substr($prazo, 6).substr($prazo, 2, 4).substr($prazo, 0, 2).' 23:59:59'); - + $diff = $iprazo - $idata; } $dias = -1; - + if($diff >= 0) $dias = ceil($diff/(60*60*24)); - + if(!is_null($data)) $data = $prazo; - + return $dias; } @@ -2420,7 +2420,7 @@ function delibera_edit_columns($columns) function delibera_post_custom_column($column) { global $post; - + switch ( $column ) { case 'tema': @@ -2442,7 +2442,7 @@ function delibera_post_custom_column($column) } break; } - + } add_action('manage_posts_custom_column', 'delibera_post_custom_column'); @@ -2481,11 +2481,11 @@ function delibera_comment_number_filtro($count, $postID) return $count; } $situacao = delibera_get_situacao($postID); - + if (!$situacao) { return; } - + switch($situacao->slug) { case 'validacao': @@ -2537,7 +2537,7 @@ function delibera_restrict_listings() function delibera_convert_situacao_id_to_taxonomy_term_in_query(&$query) { - global $pagenow; + global $pagenow; $qv = &$query->query_vars; if (isset($qv['post_type']) && $qv['post_type'] == 'pauta' && @@ -2565,10 +2565,10 @@ function delibera_convert_situacao_id_to_taxonomy_term_in_query(&$query) require_once __DIR__ . DIRECTORY_SEPARATOR . 'delibera_relatorio.php'; /** - * + * * Pega os ultimos conteúdos - * @param string $tipo (option) 'pauta' ou 'comments', padrão 'pauta' - * @param array $args (option) query padrão do post ou do comments + * @param string $tipo (option) 'pauta' ou 'comments', padrão 'pauta' + * @param array $args (option) query padrão do post ou do comments * @param int $count (option) padrão 5 */ function delibera_ultimas($tipo = 'pauta', $args = array(), $count = 5) @@ -2598,7 +2598,7 @@ function delibera_timeline($post_id = false, $tipo_data = false) function delibera_the_posts($posts) { if (empty($posts)) return $posts; - + $timeline_found = false; // use this flag to see if styles and scripts need to be enqueued $relatoria = false; foreach ($posts as $post) @@ -2616,7 +2616,7 @@ function delibera_the_posts($posts) } } } - + if ($timeline_found) { // enqueue here @@ -2624,7 +2624,7 @@ function delibera_the_posts($posts) wp_enqueue_script( 'delibera_timeline_js', WP_CONTENT_URL.'/plugins/delibera/timeline/js/delibera_timeline.js', array( 'jquery' )); wp_enqueue_script( 'jquery-ui-draggable'); } - + return $posts; } @@ -2639,7 +2639,7 @@ function delibera_the_posts($posts) * verifica se o número mínimo de validações foi * atingido e se sim muda a situação da pauta de * "emvotacao" para "discussao". - * + * * @param unknown $post * @return null */ @@ -2647,7 +2647,7 @@ function delibera_valida_validacoes($post) { $validacoes = get_post_meta($post, 'numero_validacoes', true); $min_validacoes = get_post_meta($post, 'min_validacoes', true); - + if($validacoes >= $min_validacoes) { wp_set_object_terms($post, 'discussao', 'situacao', false); //Mudar situação para Discussão @@ -2665,7 +2665,7 @@ function delibera_valida_validacoes($post) } } -/* Faz os testes de permissões para garantir que nenhum engraçadinho +/* Faz os testes de permissões para garantir que nenhum engraçadinho * está injetando variáveis maliciosas. * TODO: Incluir todas as variaveis a serem verificadas aqui */ @@ -2674,13 +2674,13 @@ function delibera_valida_permissoes($comment_ID) if (get_post_type() == 'pauta' && !delibera_current_user_can_participate()) { if (array_key_exists('delibera_validacao', $_REQUEST) || array_key_exists('delibera_encaminha', $_REQUEST) ) - wp_die("Nananina não! Você não tem que ter permissão pra votar.","Tocooo!!"); + wp_die("Nananina não! Você não tem que ter permissão pra votar.","Tocooo!!"); } } add_action( 'wp_blacklist_check', 'delibera_valida_permissoes' ); /** - * + * * Verifica se o número de votos é igual ao número de representantes para deflagar fim da votação * @param integer $postID */ @@ -2696,11 +2696,11 @@ function delibera_valida_votos($postID) $users_count += $result[0]->n; } } - + $votos = delibera_get_comments_votacoes($postID); - + $votos_count = count($votos); - + if($votos_count >= $users_count) { delibera_computa_votos($postID, $votos); @@ -2708,7 +2708,7 @@ function delibera_valida_votos($postID) } /** - * + * * Faz a apuração dos votos e toma as devidas ações: * Empate: Mais prazo; * Vencedor: Marco com resolucao e marca o encaminhamento. @@ -2727,7 +2727,7 @@ function delibera_computa_votos($postID, $votos = null) { $encaminhamentos_votos[$encaminhamento->comment_ID] = 0; } - + foreach ($votos as $voto_comment) { $voto = get_comment_meta($voto_comment->comment_ID, 'delibera_votos', true); @@ -2738,7 +2738,7 @@ function delibera_computa_votos($postID, $votos = null) } $maisvotado = array(-1, -1); $iguais = array(); - + foreach ($encaminhamentos_votos as $encaminhamentos_voto_key => $encaminhamentos_voto_valor) { if($encaminhamentos_voto_valor > $maisvotado[1]) @@ -2754,13 +2754,13 @@ function delibera_computa_votos($postID, $votos = null) delete_comment_meta($encaminhamentos_voto_key, 'delibera_comment_numero_votos'); add_comment_meta($encaminhamentos_voto_key, 'delibera_comment_numero_votos', $encaminhamentos_voto_valor, true); } - + // nao finaliza a votacao caso haja um empate, exceto quando o administrador clicar no botão "Forçar fim do prazo" if(count($iguais) > 0 && !(isset($_REQUEST['action']) && $_REQUEST['action'] == 'delibera_forca_fim_prazo_action')) // Empato { delibera_novo_prazo($postID); } - else + else { wp_set_object_terms($postID, 'comresolucao', 'situacao', false); update_comment_meta($maisvotado[0], 'delibera_comment_tipo', 'resolucao'); @@ -2780,7 +2780,7 @@ function delibera_emvotacao($post) { if($opt['eleicao_relator'] == 'S') { - + } } } @@ -2802,13 +2802,13 @@ function delibera_novo_prazo($postID) $nova_datarel = date("d/m/Y", $inova_datarel); $inova_datar = strtotime("+{$opts['dias_relatoria']} days",$inova_datarel); $nova_datar = date("d/m/Y", $inova_datar); - + $events_meta['prazo_validacao'] = $opts['validacao'] == 'S' ? $nova_data : date('d/m/Y'); $events_meta['prazo_discussao'] = $nova_datad; $events_meta['prazo_relatoria'] = $opts['relatoria'] == 'S' ? $nova_datar : date('d/m/Y'); $events_meta['prazo_eleicao_relator'] = $opts['relatoria'] == 'S' && $opts['eleicao_relator'] == 'S' ? $nova_datarel : date('d/m/Y'); $events_meta['prazo_votacao'] = $nova_datavt; - + foreach ($events_meta as $key => $value) // Buscar dados { if(get_post_meta($postID, $key, true)) // Se já existe @@ -2868,9 +2868,9 @@ function delibera_set_novo_prazo_discussao_relatoria($postID, $inova_data, $opts } function delibera_footer() { - + echo ''; - + } add_action('wp_footer', 'delibera_footer'); @@ -2879,12 +2879,12 @@ function delibera_loaded() { // load plugin translations load_plugin_textdomain('delibera', false, dirname(plugin_basename( __FILE__ )).'/lang'); } -add_action('plugins_loaded','delibera_loaded'); +add_action('plugins_loaded','delibera_loaded'); function delibera_get_plan_config() { $plan = 'N'; - + if( is_multisite() && get_current_blog_id() != 1 ) { switch_to_blog(1); @@ -2897,7 +2897,7 @@ function delibera_get_plan_config() $opt = delibera_get_config(); $plan = $opt['plan_restriction']; } - + return $plan; } @@ -2923,12 +2923,12 @@ function get_page_by_slug($page_slug, $output = OBJECT, $post_type = 'page' ) { * Retorna a lista de idiomas disponível. Se o plugin * qtrans estiver habilitado retorna os idiomas dele, se * não usa o idioma definido no wp-config.php - * + * * @return array */ function delibera_get_available_languages() { $langs = array(get_locale()); - + if(function_exists('qtrans_enableLanguage')) { global $q_config; @@ -2941,21 +2941,21 @@ function delibera_get_available_languages() { /** * Verifica se o usuário atual pode participar das discussão * de uma pauta votando ou discutindo. - * + * * Por padrão retorna true apenas de o usuário tiver a capability 'votar', * mas se a opção "Todos os usuários da rede podem participar" estiver habilitada * retorna true para todos os usuários logados. - * + * * Quando estiver na single da pauta, retorna false sempre que ela * estiver com o prazo encerrado. - * + * * @return bool */ function delibera_current_user_can_participate($permissao = 'votar') { global $post; - + $options = delibera_get_config(); - + if (is_singular('pauta') && delibera_get_prazo($post->ID) == -1) { return false; } else if (is_multisite() && $options['todos_usuarios_logados_podem_participar'] == 'S') { @@ -2972,7 +2972,7 @@ function delibera_nova_pauta_create_action(){ $title = $_POST['nova-pauta-titulo']; $content = $_POST['nova-pauta-conteudo']; $excerpt = $_POST['nova-pauta-resumo']; - + $pauta = array(); $pauta['post_title'] = $title; $pauta['post_excerpt'] = $excerpt; @@ -3002,19 +3002,19 @@ function delibera_nova_pauta_create_action(){ $pauta['post_content'] = $content; } - // para que a situação da pauta seja criada corretamente, + // para que a situação da pauta seja criada corretamente, // é necessário criar a pauta como rascunho para depois publicar no final desta função $pauta['post_status'] = 'draft'; - + $pauta_id = wp_insert_post($pauta); - + if(is_int($pauta_id) && $pauta_id > 0){ - - /* Os valores adicionados ao array $_POST são baseados no if da função delibera_save_post(), + + /* Os valores adicionados ao array $_POST são baseados no if da função delibera_save_post(), * comentado abaixo - if( + if( ( // Se tem validação, tem que ter o prazo - $opt['validacao'] == 'N' || + $opt['validacao'] == 'N' || (array_key_exists('prazo_validacao', $_POST) && array_key_exists('min_validacoes', $_POST) ) ) && ( // Se tem relatoria, tem que ter o prazo @@ -3024,7 +3024,7 @@ function delibera_nova_pauta_create_action(){ ( // Se tem relatoria, e é preciso eleger o relator, tem que ter o prazo para eleição $opt['relatoria'] == 'N' || ( - $opt['eleicao_relator'] == 'N' || + $opt['eleicao_relator'] == 'N' || array_key_exists('prazo_eleicao_relator', $_POST) ) ) && @@ -3032,12 +3032,12 @@ function delibera_nova_pauta_create_action(){ array_key_exists('prazo_votacao', $_POST) ) */ - + if($opt['validacao'] == 'S'){ $_POST['prazo_validacao'] = date('d/m/Y', strtotime ('+'.$opt['dias_validacao'].' DAYS')); $_POST['min_validacoes'] = $opt['minimo_validacao']; } - + if($opt['relatoria'] == 'S'){ $_POST['prazo_relatoria'] = date('d/m/Y', strtotime ('+'.$opt['dias_relatoria'].' DAYS')); if($opt['eleicao_relator'] == 'S'){ @@ -3057,29 +3057,29 @@ function delibera_nova_pauta_create_action(){ // isto é necessário por causa do if da função delibera_publish_pauta() $_POST['publish'] = 'Publicar'; $_POST['prev_status'] = 'draft'; - + // verifica se todos os temas enviados por post são válidos $temas = get_terms('tema', array('hide_empty' => true)); $temas_ids = array(); - + if(isset($_POST['tema']) && is_array($_POST['tema'])) foreach($temas as $tema) if(in_array ($tema->term_id, $_POST['tema'])) $temas_ids[] = $tema->term_id; - + // coloca os termos de temas no post wp_set_post_terms($pauta_id, $temas_ids, 'tema'); - - // publica o post + + // publica o post wp_publish_post($pauta_id); - - // isto serve para criar o slug corretamente, + + // isto serve para criar o slug corretamente, // já que no wp_insert_post não cria o slug quando o status é draft e o wp_publish_post tb não cria o slug unset($pauta['post_status']); $pauta['ID'] = $pauta_id; $pauta['post_name'] = sanitize_post_field('post_name', $title, $pauta_id, 'save'); wp_update_post($pauta); - + // redireciona para a pauta criada $permalink = get_post_permalink($pauta_id); wp_safe_redirect($permalink); @@ -3095,13 +3095,13 @@ function delibera_nova_pauta_create_action(){ * onde o Delibera foi instalado para a página de pautas após o * login se a opção "Todos os usuários logados na rede podem participar?" * estiver habilitada. - * + * * Se não fizermos esse redicionamento estes usuários serão redirecionados * para suas páginas de perfil fora do site onde o Delibera está instalado. * add_filter('login_redirect', function($redirect_to, $request, $user) { $options = delibera_get_config(); - + if ($options['todos_usuarios_logados_podem_participar'] == 'S' && !is_user_member_of_blog()) { return site_url('pauta'); } else { From dc5713bf03022cdf28ec0f5825618fdef8bd2c62 Mon Sep 17 00:00:00 2001 From: Lucas Pirola Date: Mon, 18 Jan 2016 21:26:01 -0200 Subject: [PATCH 004/435] =?UTF-8?q?Move=20fun=C3=A7=C3=B5es=20para=20checa?= =?UTF-8?q?r=20permiss=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- delibera.php | 47 --------------------------------------------- delibera_roles.php | 48 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 47 deletions(-) diff --git a/delibera.php b/delibera.php index ec1079c..c57bd1e 100644 --- a/delibera.php +++ b/delibera.php @@ -1674,27 +1674,6 @@ function delibera_edit_comment($comment) add_filter('add_meta_boxes_comment', 'delibera_edit_comment'); -function delibera_can_comment($postID = '') -{ - if(is_null($postID)) - { - $post = get_post($postID); - $postID = $post->ID; - } - - $situacoes_validas = array('validacao' => true, 'discussao' => true, 'emvotacao' => true, 'elegerelator' => true); - $situacao = delibera_get_situacao($postID); - - if(array_key_exists($situacao->slug, $situacoes_validas)) - { - return delibera_current_user_can_participate(); - } - elseif($situacao->slug == 'relatoria') - { - return current_user_can('relatoria'); - } - return false; -} function delibera_comments_open($open, $post_id) { @@ -2938,32 +2917,6 @@ function delibera_get_available_languages() { return $langs; } -/** - * Verifica se o usuário atual pode participar das discussão - * de uma pauta votando ou discutindo. - * - * Por padrão retorna true apenas de o usuário tiver a capability 'votar', - * mas se a opção "Todos os usuários da rede podem participar" estiver habilitada - * retorna true para todos os usuários logados. - * - * Quando estiver na single da pauta, retorna false sempre que ela - * estiver com o prazo encerrado. - * - * @return bool - */ -function delibera_current_user_can_participate($permissao = 'votar') { - global $post; - - $options = delibera_get_config(); - - if (is_singular('pauta') && delibera_get_prazo($post->ID) == -1) { - return false; - } else if (is_multisite() && $options['todos_usuarios_logados_podem_participar'] == 'S') { - return is_user_logged_in(); - } else { - return current_user_can($permissao); - } -} add_action('init', 'delibera_nova_pauta_create_action'); function delibera_nova_pauta_create_action(){ diff --git a/delibera_roles.php b/delibera_roles.php index e5bf040..c70bdab 100644 --- a/delibera_roles.php +++ b/delibera_roles.php @@ -75,4 +75,52 @@ )),*/ ); +/** + * Verifica se o usuário atual pode participar das discussão + * de uma pauta votando ou discutindo. + * + * Por padrão retorna true apenas de o usuário tiver a capability 'votar', + * mas se a opção "Todos os usuários da rede podem participar" estiver habilitada + * retorna true para todos os usuários logados. + * + * Quando estiver na single da pauta, retorna false sempre que ela + * estiver com o prazo encerrado. + * + * @return bool + */ +function delibera_current_user_can_participate($permissao = 'votar') { + global $post; + + $options = delibera_get_config(); + + if (is_singular('pauta') && delibera_get_prazo($post->ID) == -1) { + return false; + } else if (is_multisite() && $options['todos_usuarios_logados_podem_participar'] == 'S') { + return is_user_logged_in(); + } else { + return current_user_can($permissao); + } +} + +function delibera_can_comment($postID = '') +{ + if(is_null($postID)) + { + $post = get_post($postID); + $postID = $post->ID; + } + + $situacoes_validas = array('validacao' => true, 'discussao' => true, 'emvotacao' => true, 'elegerelator' => true); + $situacao = delibera_get_situacao($postID); + + if(array_key_exists($situacao->slug, $situacoes_validas)) + { + return delibera_current_user_can_participate(); + } + elseif($situacao->slug == 'relatoria') + { + return current_user_can('relatoria'); + } + return false; +} ?> \ No newline at end of file From 83e859fa15223c755b838dd6038d8a971a7abbfa Mon Sep 17 00:00:00 2001 From: Lucas Pirola Date: Mon, 18 Jan 2016 22:03:01 -0200 Subject: [PATCH 005/435] Move funcoes executadas no inicio do carregamento do plugin --- delibera.php | 390 +--------------------------------------------- delibera_conf.php | 2 + delibera_init.php | 384 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 391 insertions(+), 385 deletions(-) create mode 100644 delibera_init.php diff --git a/delibera.php b/delibera.php index c57bd1e..274ab1f 100644 --- a/delibera.php +++ b/delibera.php @@ -58,23 +58,11 @@ require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_admin_functions.php'; -function delibera_init() -{ - add_action('admin_menu', 'delibera_config_menu'); - - delibera_Add_custom_Post(); - - delibera_Add_custom_taxonomy(); - - global $delibera_comments_padrao; - $delibera_comments_padrao = false; - -} -add_action('init','delibera_init'); - // setup plugin require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_setup.php'; +require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_init.php'; + /** * * Revemos acentos do texto @@ -136,57 +124,6 @@ function delibera_insert_term($label, $tax, $term, $idiomas = array()) } } -function delibera_Add_custom_Post() -{ - $labels = array - ( - 'name' => __('Pautas','delibera'), - 'singular_name' => __('Pauta','delibera'), - 'add_new' => __('Adicionar Nova','delibera'), - 'add_new_item' => __('Adicionar nova pauta ','delibera'), - 'edit_item' => __('Editar Pauta','delibera'), - 'new_item' => __('Nova Pauta','delibera'), - 'view_item' => __('Visualizar Pauta','delibera'), - 'search_items' => __('Procurar Pautas','delibera'), - 'not_found' => __('Nenhuma Pauta localizada','delibera'), - 'not_found_in_trash' => __('Nenhuma Pauta localizada na lixeira','delibera'), - 'parent_item_colon' => '', - 'menu_name' => __('Pautas','delibera') - - ); - - $args = array - ( - 'label' => __('Pautas','delibera'), - 'labels' => $labels, - 'description' => __('Pauta de discussão','delibera'), - 'public' => true, - 'publicly_queryable' => true, // public - //'exclude_from_search' => '', // public - 'show_ui' => true, // public - 'show_in_menu' => true, - 'menu_position' => 5, - // 'menu_icon' => '', - 'capability_type' => array('pauta','pautas'), - 'map_meta_cap' => true, - 'hierarchical' => false, - 'supports' => array('title', 'editor', 'author', 'excerpt', 'trackbacks', 'revisions', 'comments'), - 'register_meta_box_cb' => 'delibera_pauta_custom_meta', // função para chamar na edição - //'taxonomies' => array('post_tag'), // Taxionomias já existentes relaciondas, vamos criar e registrar na sequência - 'permalink_epmask' => 'EP_PERMALINK ', - 'has_archive' => true, // Opção de arquivamento por slug - 'rewrite' => true, - 'query_var' => true, - 'can_export' => true//, // veja abaixo - //'show_in_nav_menus' => '', // public - //'_builtin' => '', // Core - //'_edit_link' => '' // Core - - ); - - register_post_type("pauta", $args); -} - function delibera_pauta_redirect_filter($location, $post_id = null) { if (strpos($_SERVER['HTTP_REFERER'], "post_type=pauta")) @@ -196,208 +133,6 @@ function delibera_pauta_redirect_filter($location, $post_id = null) { } add_filter('redirect_post_location', 'delibera_pauta_redirect_filter', '99'); -function delibera_Add_custom_taxonomy() -{ - $labels = array - ( - 'name' => __('Temas', 'delibera'), - 'singular_name' => __('Tema', 'delibera'), - 'search_items' => __('Procurar por Temas','delibera'), - 'all_items' => __('Todos os Temas','delibera'), - 'parent_item' => __( 'Tema Pai','delibera'), - 'parent_item_colon' => __( 'Tema Pai:','delibera'), - 'edit_item' => __('Editar Tema','delibera'), - 'update_item' => __('Atualizar um Tema','delibera'), - 'add_new_item' => __('Adicionar Novo Tema','delibera'), - 'add_new' => __('Adicionar Novo','delibera'), - 'new_item_name' => __('Novo Tema','delibera'), - 'view_item' => __('Visualizar Tema','delibera'), - 'not_found' => __('Nenhum Tema localizado','delibera'), - 'not_found_in_trash' => __('Nenhum Tema localizado na lixeira','delibera'), - 'menu_name' => __('Temas','delibera') - ); - - $args = array - ( - 'label' => __('Temas','delibera'), - 'labels' => $labels, - 'public' => true, - 'capabilities' => array('assign_terms' => 'edit_pautas', - 'edit_terms' => 'edit_pautas'), - //'show_in_nav_menus' => true, // Public - // 'show_ui' => '', // Public - 'hierarchical' => true, - //'update_count_callback' => '', //Contar objetos associados - 'rewrite' => true, - //'query_var' => '', - //'_builtin' => '' // Core - ); - - register_taxonomy('tema', array('pauta'), $args); - - - - $labels = array - ( - 'name' => __('Situações','delibera'), - 'singular_name' => __('Situação', 'delibera'), - 'search_items' => __('Procurar por Situação','delibera'), - 'all_items' => __('Todas as Situações','delibera'), - 'parent_item' => null, - 'parent_item_colon' => null, - 'edit_item' => __('Editar Situação','delibera'), - 'update_item' => __('Atualizar uma Situação','delibera'), - 'add_new_item' => __('Adicionar Nova Situação','delibera'), - 'add_new' => __('Adicionar Nova', 'delibera'), - 'new_item_name' => __('Nova Situação','delibera'), - 'view_item' => __('Visualizar Situação','delibera'), - 'not_found' => __('Nenhuma Situação localizado','delibera'), - 'not_found_in_trash' => __('Nenhuma Situação localizada na lixeira','delibera'), - 'menu_name' => __('Situações','delibera') - ); - - $args = array - ( - 'label' => __('Situações','delibera'), - 'labels' => $labels, - 'public' => false, - 'show_in_nav_menus' => true, // Public - //'show_ui' => true, // Public - 'hierarchical' => false//, - //'update_count_callback' => '', //Contar objetos associados - //'rewrite' => '', // - //'query_var' => '', - //'_builtin' => '' // Core - ); - - register_taxonomy('situacao', array('pauta'), $args); - - // Se precisar trocar os nomes dos terms denovo - /*$term = get_term_by('slug', 'comresolucao', 'situacao'); - wp_update_term($term->term_id, 'situacao', array('name' => 'Resolução')); - $term = get_term_by('slug', 'emvotacao', 'situacao'); - wp_update_term($term->term_id, 'situacao', array('name' => 'Regime de Votação')); - $term = get_term_by('slug', 'discussao', 'situacao'); - wp_update_term($term->term_id, 'situacao', array('name' => 'Pauta em discussão')); - $term = get_term_by('slug', 'validacao', 'situacao'); - wp_update_term($term->term_id, 'situacao', array('name' => 'Proposta de Pauta')); - $term = get_term_by('slug', 'naovalidada', 'situacao'); - wp_update_term($term->term_id, 'situacao', array('name' => 'Pauta Recusada'));*/ - - $opt = delibera_get_config(); - - if(taxonomy_exists('situacao')) - { - if(term_exists('comresolucao', 'situacao', null) == false) - { - delibera_insert_term('Resolução', 'situacao', array( - 'description'=> 'Pauta com resoluções aprovadas', - 'slug' => 'comresolucao', - ), - array( - 'qtrans_term_pt' => 'Resolução', - 'qtrans_term_en' => 'Resolution', - 'qtrans_term_es' => 'Resolución', - ) - ); - } - if(term_exists('emvotacao', 'situacao', null) == false) - { - delibera_insert_term('Regime de Votação', 'situacao', array( - 'description'=> 'Pauta com encaminhamentos em Votacao', - 'slug' => 'emvotacao', - ), - array( - 'qtrans_term_pt' => 'Regime de Votação', - 'qtrans_term_en' => 'Voting', - 'qtrans_term_es' => 'Sistema de Votación', - ) - ); - } - if(isset($opt['relatoria']) && $opt['relatoria'] == 'S') - { - if($opt['eleicao_relator'] == 'S') - { - if(term_exists('eleicaoredator', 'situacao', null) == false) - { - delibera_insert_term('Regime de Votação de Relator', 'situacao', array( - 'description'=> 'Pauta em Eleição de Relator', - 'slug' => 'eleicaoredator', - ), - array( - 'qtrans_term_pt' => 'Regime de Votação de Relator', - 'qtrans_term_en' => 'Election of Rapporteur', - 'qtrans_term_es' => 'Elección del Relator', - ) - ); - } - } - - if(term_exists('relatoria', 'situacao', null) == false) - { - delibera_insert_term('Relatoria', 'situacao', array( - 'description'=> 'Pauta com encaminhamentos em Relatoria', - 'slug' => 'relatoria', - ), - array( - 'qtrans_term_pt' => 'Relatoria', - 'qtrans_term_en' => 'Rapporteur', - 'qtrans_term_es' => 'Relator', - ) - ); - } - } - if(term_exists('discussao', 'situacao', null) == false) - { - delibera_insert_term('Pauta em discussão', 'situacao', array( - 'description'=> 'Pauta em Discussão', - 'slug' => 'discussao', - ), - array( - 'qtrans_term_pt' => 'Pauta em discussão', - 'qtrans_term_en' => 'Agenda en discusión', - 'qtrans_term_es' => 'Topic under discussion', - ) - ); - } - if(isset($opt['validacao']) && $opt['validacao'] == 'S') - { - if(term_exists('validacao', 'situacao', null) == false) - { - delibera_insert_term('Proposta de Pauta', 'situacao', array( - 'description'=> 'Pauta em Validação', - 'slug' => 'validacao', - ), - array( - 'qtrans_term_pt' => 'Proposta de Pauta', - 'qtrans_term_en' => 'Proposed Topic', - 'qtrans_term_es' => 'Agenda Propuesta', - ) - ); - } - if(term_exists('naovalidada', 'situacao', null) == false) - { - delibera_insert_term('Pauta Recusada', 'situacao', array( - 'description'=> 'Pauta não Validação', - 'slug' => 'naovalidada', - ), - array( - 'qtrans_term_pt' => 'Pauta Recusada', - 'qtrans_term_en' => 'Rejected Topic', - 'qtrans_term_es' => 'Agenda Rechazada', - ) - ); - } - } - } - - if(file_exists(__DIR__.DIRECTORY_SEPARATOR.'delibera_taxs.php')) - { - require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_taxs.php'; - } - -} - require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_themes.php'; if(file_exists(__DIR__.DIRECTORY_SEPARATOR.'delibera_filtros.php')) @@ -1286,9 +1021,9 @@ function delibera_check_post_data($data, $postarr) { $value = $_POST['prazo_relatoria']; $valida = delibera_tratar_data($value); - if(!$autosave && ($valida === false || $valida < 1)) - { - $erros[] = __("É necessário definir corretamente o prazo para relatoria", "delibera"); + if(!$autosave && ($valida === false || $valida < 1)) + { + $erros[] = __("É necessário definir corretamente o prazo para relatoria", "Delibera"); } if($opt['eleicao_relator'] == 'S') @@ -1922,71 +1657,6 @@ function delibera_form_table($rows) { return $content; } -// Scripts - -function delibera_scripts() -{ - global $post; - - if (is_pauta()) { - wp_enqueue_script('jquery-expander', WP_CONTENT_URL.'/plugins/delibera/js/jquery.expander.js', array('jquery')); - wp_enqueue_script('delibera', WP_CONTENT_URL.'/plugins/delibera/js/scripts.js', array('jquery-expander')); - wp_enqueue_script('delibera-seguir', WP_CONTENT_URL . '/plugins/delibera/js/delibera_seguir.js', array('delibera')); - wp_enqueue_script('delibera-concordar', WP_CONTENT_URL . '/plugins/delibera/js/delibera_concordar.js', array('delibera')); - - $situation = delibera_get_situacao($post->ID); - - $data = array( - 'post_id' => $post->ID, - 'ajax_url' => admin_url('admin-ajax.php'), - ); - - if (is_object($situation)) { - $data['situation'] = $situation->slug; - } - - wp_localize_script('delibera', 'delibera', $data); - } -} -add_action( 'wp_print_scripts', 'delibera_scripts' ); - -/** - * - * Se tiver estilos customizados, ta aí a dica... - * -function delibera_print_styles() -{ - -} -add_action('wp_print_styles', 'delibera_print_styles');*/ - -function delibera_print_styles() -{ - if (is_pauta()) { - wp_enqueue_style('jquery-ui-custom', plugins_url() . '/delibera/css/jquery-ui-1.9.2.custom.min.css'); - } - - wp_enqueue_style('delibera_style', WP_CONTENT_URL.'/plugins/delibera/css/delibera.css'); -} -add_action('admin_print_styles', 'delibera_print_styles'); - -function delibera_admin_scripts() -{ - if(is_pauta()) - { - wp_enqueue_script('jquery-ui-datepicker-ptbr', WP_CONTENT_URL.'/plugins/delibera/js/jquery.ui.datepicker-pt-BR.js', array('jquery-ui-datepicker')); - wp_enqueue_script('delibera-admin',WP_CONTENT_URL.'/plugins/delibera/js/admin_scripts.js', array( 'jquery-ui-datepicker-ptbr')); - } - - if(isset($_REQUEST['page']) && $_REQUEST['page'] == 'delibera-notifications') - { - wp_enqueue_script('delibera-admin-notifica',WP_CONTENT_URL.'/plugins/delibera/js/admin_notifica_scripts.js', array('jquery')); - } -} -add_action( 'admin_print_scripts', 'delibera_admin_scripts' ); - -// Fim Scripts - // Funções de conteudo /** @@ -2846,19 +2516,6 @@ function delibera_set_novo_prazo_discussao_relatoria($postID, $inova_data, $opts delibera_criar_agenda($postID, false, $nova_data, $nova_data_votacao, $nova_relatoria, $nova_eleicao_rel); } -function delibera_footer() { - - echo ''; - -} -add_action('wp_footer', 'delibera_footer'); - - -function delibera_loaded() { - // load plugin translations - load_plugin_textdomain('delibera', false, dirname(plugin_basename( __FILE__ )).'/lang'); -} -add_action('plugins_loaded','delibera_loaded'); function delibera_get_plan_config() { @@ -2881,43 +2538,6 @@ function delibera_get_plan_config() } -$conf = delibera_get_config(); -if(array_key_exists('plan_restriction', $conf) && $conf['plan_restriction'] == 'S') -{ - require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_plan.php'; -} - -/* - * Get page by slug -*/ -function get_page_by_slug($page_slug, $output = OBJECT, $post_type = 'page' ) { - global $wpdb; - $page = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_name = %s AND post_type= %s", $page_slug, $post_type ) ); - if ( $page ) - return get_page($page, $output); - return null; -} - -/** - * Retorna a lista de idiomas disponível. Se o plugin - * qtrans estiver habilitado retorna os idiomas dele, se - * não usa o idioma definido no wp-config.php - * - * @return array - */ -function delibera_get_available_languages() { - $langs = array(get_locale()); - - if(function_exists('qtrans_enableLanguage')) - { - global $q_config; - $langs = $q_config['enabled_languages']; - } - - return $langs; -} - - add_action('init', 'delibera_nova_pauta_create_action'); function delibera_nova_pauta_create_action(){ $opt = delibera_get_config(); diff --git a/delibera_conf.php b/delibera_conf.php index d7ecd3d..3914412 100644 --- a/delibera_conf.php +++ b/delibera_conf.php @@ -1,4 +1,6 @@ __('Pautas','delibera'), + 'singular_name' => __('Pauta','delibera'), + 'add_new' => __('Adicionar Nova','delibera'), + 'add_new_item' => __('Adicionar nova pauta ','delibera'), + 'edit_item' => __('Editar Pauta','delibera'), + 'new_item' => __('Nova Pauta','delibera'), + 'view_item' => __('Visualizar Pauta','delibera'), + 'search_items' => __('Procurar Pautas','delibera'), + 'not_found' => __('Nenhuma Pauta localizada','delibera'), + 'not_found_in_trash' => __('Nenhuma Pauta localizada na lixeira','delibera'), + 'parent_item_colon' => '', + 'menu_name' => __('Pautas','delibera') + + ); + + $args = array + ( + 'label' => __('Pautas','delibera'), + 'labels' => $labels, + 'description' => __('Pauta de discussão','delibera'), + 'public' => true, + 'publicly_queryable' => true, // public + //'exclude_from_search' => '', // public + 'show_ui' => true, // public + 'show_in_menu' => true, + 'menu_position' => 5, + // 'menu_icon' => '', + 'capability_type' => array('pauta','pautas'), + 'map_meta_cap' => true, + 'hierarchical' => false, + 'supports' => array('title', 'editor', 'author', 'excerpt', 'trackbacks', 'revisions', 'comments'), + 'register_meta_box_cb' => 'delibera_pauta_custom_meta', // função para chamar na edição + //'taxonomies' => array('post_tag'), // Taxionomias já existentes relaciondas, vamos criar e registrar na sequência + 'permalink_epmask' => 'EP_PERMALINK ', + 'has_archive' => true, // Opção de arquivamento por slug + 'rewrite' => true, + 'query_var' => true, + 'can_export' => true//, // veja abaixo + //'show_in_nav_menus' => '', // public + //'_builtin' => '', // Core + //'_edit_link' => '' // Core + + ); + + register_post_type("pauta", $args); +} + +function delibera_Add_custom_taxonomy() +{ + $labels = array + ( + 'name' => __('Temas', 'delibera'), + 'singular_name' => __('Tema', 'delibera'), + 'search_items' => __('Procurar por Temas','delibera'), + 'all_items' => __('Todos os Temas','delibera'), + 'parent_item' => __( 'Tema Pai','delibera'), + 'parent_item_colon' => __( 'Tema Pai:','delibera'), + 'edit_item' => __('Editar Tema','delibera'), + 'update_item' => __('Atualizar um Tema','delibera'), + 'add_new_item' => __('Adicionar Novo Tema','delibera'), + 'add_new' => __('Adicionar Novo','delibera'), + 'new_item_name' => __('Novo Tema','delibera'), + 'view_item' => __('Visualizar Tema','delibera'), + 'not_found' => __('Nenhum Tema localizado','delibera'), + 'not_found_in_trash' => __('Nenhum Tema localizado na lixeira','delibera'), + 'menu_name' => __('Temas','delibera') + ); + + $args = array + ( + 'label' => __('Temas','delibera'), + 'labels' => $labels, + 'public' => true, + 'capabilities' => array('assign_terms' => 'edit_pautas', + 'edit_terms' => 'edit_pautas'), + //'show_in_nav_menus' => true, // Public + // 'show_ui' => '', // Public + 'hierarchical' => true, + //'update_count_callback' => '', //Contar objetos associados + 'rewrite' => true, + //'query_var' => '', + //'_builtin' => '' // Core + ); + + register_taxonomy('tema', array('pauta'), $args); + + + + $labels = array + ( + 'name' => __('Situações','delibera'), + 'singular_name' => __('Situação', 'delibera'), + 'search_items' => __('Procurar por Situação','delibera'), + 'all_items' => __('Todas as Situações','delibera'), + 'parent_item' => null, + 'parent_item_colon' => null, + 'edit_item' => __('Editar Situação','delibera'), + 'update_item' => __('Atualizar uma Situação','delibera'), + 'add_new_item' => __('Adicionar Nova Situação','delibera'), + 'add_new' => __('Adicionar Nova', 'delibera'), + 'new_item_name' => __('Nova Situação','delibera'), + 'view_item' => __('Visualizar Situação','delibera'), + 'not_found' => __('Nenhuma Situação localizado','delibera'), + 'not_found_in_trash' => __('Nenhuma Situação localizada na lixeira','delibera'), + 'menu_name' => __('Situações','delibera') + ); + + $args = array + ( + 'label' => __('Situações','delibera'), + 'labels' => $labels, + 'public' => false, + 'show_in_nav_menus' => true, // Public + //'show_ui' => true, // Public + 'hierarchical' => false//, + //'update_count_callback' => '', //Contar objetos associados + //'rewrite' => '', // + //'query_var' => '', + //'_builtin' => '' // Core + ); + + register_taxonomy('situacao', array('pauta'), $args); + + // Se precisar trocar os nomes dos terms denovo + /*$term = get_term_by('slug', 'comresolucao', 'situacao'); + wp_update_term($term->term_id, 'situacao', array('name' => 'Resolução')); + $term = get_term_by('slug', 'emvotacao', 'situacao'); + wp_update_term($term->term_id, 'situacao', array('name' => 'Regime de Votação')); + $term = get_term_by('slug', 'discussao', 'situacao'); + wp_update_term($term->term_id, 'situacao', array('name' => 'Pauta em discussão')); + $term = get_term_by('slug', 'validacao', 'situacao'); + wp_update_term($term->term_id, 'situacao', array('name' => 'Proposta de Pauta')); + $term = get_term_by('slug', 'naovalidada', 'situacao'); + wp_update_term($term->term_id, 'situacao', array('name' => 'Pauta Recusada'));*/ + + $opt = delibera_get_config(); + + if(taxonomy_exists('situacao')) + { + if(term_exists('comresolucao', 'situacao', null) == false) + { + delibera_insert_term('Resolução', 'situacao', array( + 'description'=> 'Pauta com resoluções aprovadas', + 'slug' => 'comresolucao', + ), + array( + 'qtrans_term_pt' => 'Resolução', + 'qtrans_term_en' => 'Resolution', + 'qtrans_term_es' => 'Resolución', + ) + ); + } + if(term_exists('emvotacao', 'situacao', null) == false) + { + delibera_insert_term('Regime de Votação', 'situacao', array( + 'description'=> 'Pauta com encaminhamentos em Votacao', + 'slug' => 'emvotacao', + ), + array( + 'qtrans_term_pt' => 'Regime de Votação', + 'qtrans_term_en' => 'Voting', + 'qtrans_term_es' => 'Sistema de Votación', + ) + ); + } + if(isset($opt['relatoria']) && $opt['relatoria'] == 'S') + { + if($opt['eleicao_relator'] == 'S') + { + if(term_exists('eleicaoredator', 'situacao', null) == false) + { + delibera_insert_term('Regime de Votação de Relator', 'situacao', array( + 'description'=> 'Pauta em Eleição de Relator', + 'slug' => 'eleicaoredator', + ), + array( + 'qtrans_term_pt' => 'Regime de Votação de Relator', + 'qtrans_term_en' => 'Election of Rapporteur', + 'qtrans_term_es' => 'Elección del Relator', + ) + ); + } + } + + if(term_exists('relatoria', 'situacao', null) == false) + { + delibera_insert_term('Relatoria', 'situacao', array( + 'description'=> 'Pauta com encaminhamentos em Relatoria', + 'slug' => 'relatoria', + ), + array( + 'qtrans_term_pt' => 'Relatoria', + 'qtrans_term_en' => 'Rapporteur', + 'qtrans_term_es' => 'Relator', + ) + ); + } + } + if(term_exists('discussao', 'situacao', null) == false) + { + delibera_insert_term('Pauta em discussão', 'situacao', array( + 'description'=> 'Pauta em Discussão', + 'slug' => 'discussao', + ), + array( + 'qtrans_term_pt' => 'Pauta em discussão', + 'qtrans_term_en' => 'Agenda en discusión', + 'qtrans_term_es' => 'Topic under discussion', + ) + ); + } + if(isset($opt['validacao']) && $opt['validacao'] == 'S') + { + if(term_exists('validacao', 'situacao', null) == false) + { + delibera_insert_term('Proposta de Pauta', 'situacao', array( + 'description'=> 'Pauta em Validação', + 'slug' => 'validacao', + ), + array( + 'qtrans_term_pt' => 'Proposta de Pauta', + 'qtrans_term_en' => 'Proposed Topic', + 'qtrans_term_es' => 'Agenda Propuesta', + ) + ); + } + if(term_exists('naovalidada', 'situacao', null) == false) + { + delibera_insert_term('Pauta Recusada', 'situacao', array( + 'description'=> 'Pauta não Validação', + 'slug' => 'naovalidada', + ), + array( + 'qtrans_term_pt' => 'Pauta Recusada', + 'qtrans_term_en' => 'Rejected Topic', + 'qtrans_term_es' => 'Agenda Rechazada', + ) + ); + } + } + } + + if(file_exists(__DIR__.DIRECTORY_SEPARATOR.'delibera_taxs.php')) + { + require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_taxs.php'; + } + +} + + +function delibera_init() +{ + add_action('admin_menu', 'delibera_config_menu'); + + delibera_Add_custom_Post(); + + delibera_Add_custom_taxonomy(); + + global $delibera_comments_padrao; + $delibera_comments_padrao = false; + +} +add_action('init','delibera_init'); + +// Scripts + +function delibera_scripts() +{ + global $post; + + if (is_pauta()) { + wp_enqueue_script('jquery-expander', WP_CONTENT_URL.'/plugins/delibera/js/jquery.expander.js', array('jquery')); + wp_enqueue_script('delibera', WP_CONTENT_URL.'/plugins/delibera/js/scripts.js', array('jquery-expander')); + wp_enqueue_script('delibera-seguir', WP_CONTENT_URL . '/plugins/delibera/js/delibera_seguir.js', array('delibera')); + wp_enqueue_script('delibera-concordar', WP_CONTENT_URL . '/plugins/delibera/js/delibera_concordar.js', array('delibera')); + + $situation = delibera_get_situacao($post->ID); + + $data = array( + 'post_id' => $post->ID, + 'ajax_url' => admin_url('admin-ajax.php'), + ); + + if (is_object($situation)) { + $data['situation'] = $situation->slug; + } + + wp_localize_script('delibera', 'delibera', $data); + } +} +add_action( 'wp_print_scripts', 'delibera_scripts' ); + +/** + * + * Se tiver estilos customizados, ta aí a dica... + * +function delibera_print_styles() +{ + +} +add_action('wp_print_styles', 'delibera_print_styles');*/ + +function delibera_print_styles() +{ + if (is_pauta()) { + wp_enqueue_style('jquery-ui-custom', plugins_url() . '/delibera/css/jquery-ui-1.9.2.custom.min.css'); + } + + wp_enqueue_style('delibera_style', WP_CONTENT_URL.'/plugins/delibera/css/delibera.css'); +} +add_action('admin_print_styles', 'delibera_print_styles'); + +function delibera_admin_scripts() +{ + if(is_pauta()) + { + wp_enqueue_script('jquery-ui-datepicker-ptbr', WP_CONTENT_URL.'/plugins/delibera/js/jquery.ui.datepicker-pt-BR.js', array('jquery-ui-datepicker')); + wp_enqueue_script('delibera-admin',WP_CONTENT_URL.'/plugins/delibera/js/admin_scripts.js', array( 'jquery-ui-datepicker-ptbr')); + } + + if(isset($_REQUEST['page']) && $_REQUEST['page'] == 'delibera-notifications') + { + wp_enqueue_script('delibera-admin-notifica',WP_CONTENT_URL.'/plugins/delibera/js/admin_notifica_scripts.js', array('jquery')); + } +} +add_action( 'admin_print_scripts', 'delibera_admin_scripts' ); + +// Fim Scripts + +function delibera_footer() { + + echo ''; + +} +add_action('wp_footer', 'delibera_footer'); + + +function delibera_loaded() { + // load plugin translations + load_plugin_textdomain('delibera', false, dirname(plugin_basename( __FILE__ )).'/lang'); +} +add_action('plugins_loaded','delibera_loaded'); + +$conf = delibera_get_config(); +if(array_key_exists('plan_restriction', $conf) && $conf['plan_restriction'] == 'S') +{ + require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_plan.php'; +} + +/* + * Get page by slug + */ +function get_page_by_slug($page_slug, $output = OBJECT, $post_type = 'page' ) { + global $wpdb; + $page = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_name = %s AND post_type= %s", $page_slug, $post_type ) ); + if ( $page ) + return get_page($page, $output); + return null; +} + +/** + * Retorna a lista de idiomas disponível. Se o plugin + * qtrans estiver habilitado retorna os idiomas dele, se + * não usa o idioma definido no wp-config.php + * + * @return array + */ +function delibera_get_available_languages() { + $langs = array(get_locale()); + + if(function_exists('qtrans_enableLanguage')) + { + global $q_config; + $langs = $q_config['enabled_languages']; + } + + return $langs; +} \ No newline at end of file From 32d4130ffc2a119b16d30630190320474a8f1e91 Mon Sep 17 00:00:00 2001 From: Lucas Pirola Date: Mon, 18 Jan 2016 22:14:04 -0200 Subject: [PATCH 006/435] =?UTF-8?q?padroniza=20arquivos=20que=20realizam?= =?UTF-8?q?=20altera=C3=A7=C3=B5es=20nos=20coment=C3=A1rios?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- delibera.php | 104 +---------------- delibera_comments.php | 106 ++++++++++++++++++ ...comment.php => delibera_comments_query.php | 12 +- 3 files changed, 113 insertions(+), 109 deletions(-) create mode 100644 delibera_comments.php rename delibera_WP_comment.php => delibera_comments_query.php (99%) diff --git a/delibera.php b/delibera.php index 274ab1f..54536f5 100644 --- a/delibera.php +++ b/delibera.php @@ -140,108 +140,6 @@ function delibera_pauta_redirect_filter($location, $post_id = null) { require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_filtros.php'; } -function delibera_get_comment_type($comment) -{ - $comment_ID = $comment; - if(is_object($comment_ID)) $comment_ID = $comment->comment_ID; - return get_comment_meta($comment_ID, "delibera_comment_tipo", true); -} - -/** - * Retorna o nome "amigável" do tipo de um comentário. - * - * @param object $comment - * @param string $tipo - * @param bool $echo - * @return string - */ -function delibera_get_comment_type_label($comment, $tipo = false, $echo = true) -{ - if($tipo === false) $tipo = get_comment_meta($comment->comment_ID, "delibera_comment_tipo", true); - switch ($tipo) - { - case 'validacao': - if($echo) _e('Validação', 'delibera'); - return __('Validação', 'delibera'); - break; - case 'encaminhamento_selecionado': - case 'encaminhamento': - if($echo) _e('Proposta', 'delibera'); - return __('Proposta', 'delibera'); - break; - case 'voto': - if($echo) _e('Voto', 'delibera'); - return __('Voto', 'delibera'); - break; - case 'resolucao': - if($echo) _e('Resolução', 'delibera'); - return __('Resolução', 'delibera'); - break; - case 'discussao': - if($echo) _e('Opinião', 'delibera'); - return __('Opinião', 'delibera'); - default: - break; - } -} - -/** - * Retorna uma string com a quantidade de comentários - * associados a pauta do tipo correspondente a situação - * atual. - * - * @param int $postId - * @return string (exemplo: "5 votos") - */ -function delibera_get_comments_count_by_type($postId) -{ - $situacao = delibera_get_situacao($postId); - - switch ($situacao->slug) { - case 'validacao': - $count = count(delibera_get_comments_validacoes($postId)); - - if ($count == 0) { - $label = __('Nenhuma validação', 'delibera'); - } else if ($count == 1) { - $label = __('1 validação', 'delibera'); - } else { - $label = sprintf(__('%d validações', 'delibera'), $count); - } - - return $label; - case 'discussao': - $count = count(delibera_get_comments_discussoes($postId)); - - if ($count == 0) { - $label = __('Nenhum comentário', 'delibera'); - } else if ($count == 1) { - $label = __('1 comentário', 'delibera'); - } else { - $label = sprintf(__('%d comentários', 'delibera'), $count); - } - - return $label; - case 'emvotacao': - $count = count(delibera_get_comments_votacoes($postId)); - - if ($count == 0) { - $label = __('Nenhum voto', 'delibera'); - } else if ($count == 1) { - $label = __('1 voto', 'delibera'); - } else { - $label = sprintf(__('%d votos', 'delibera'), $count); - } - - return $label; - } -} - -function delibera_get_comments_types() -{ - return array('validacao', 'discussao', 'encaminhamento', 'encaminhamento_selecionado', 'voto', 'resolucao'); -} - function delibera_pauta_custom_meta() { add_meta_box("pauta_meta", "Detalhes da Pauta", 'delibera_pauta_meta', 'pauta', 'side', 'default'); @@ -1778,7 +1676,7 @@ function delibera_get_comments($post_id, $tipo, $args = array()) return $ret; } -require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_WP_comment.php'; +require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_comments.php'; function delibera_wp_list_comments($args = array(), $comments = null) diff --git a/delibera_comments.php b/delibera_comments.php new file mode 100644 index 0000000..35868d5 --- /dev/null +++ b/delibera_comments.php @@ -0,0 +1,106 @@ +comment_ID; + return get_comment_meta($comment_ID, "delibera_comment_tipo", true); +} + +/** + * Retorna o nome "amigável" do tipo de um comentário. + * + * @param object $comment + * @param string $tipo + * @param bool $echo + * @return string + */ +function delibera_get_comment_type_label($comment, $tipo = false, $echo = true) +{ + if($tipo === false) $tipo = get_comment_meta($comment->comment_ID, "delibera_comment_tipo", true); + switch ($tipo) + { + case 'validacao': + if($echo) _e('Validação', 'delibera'); + return __('Validação', 'delibera'); + break; + case 'encaminhamento_selecionado': + case 'encaminhamento': + if($echo) _e('Proposta', 'delibera'); + return __('Proposta', 'delibera'); + break; + case 'voto': + if($echo) _e('Voto', 'delibera'); + return __('Voto', 'delibera'); + break; + case 'resolucao': + if($echo) _e('Resolução', 'delibera'); + return __('Resolução', 'delibera'); + break; + case 'discussao': + if($echo) _e('Opinião', 'delibera'); + return __('Opinião', 'delibera'); + default: + break; + } +} + +/** + * Retorna uma string com a quantidade de comentários + * associados a pauta do tipo correspondente a situação + * atual. + * + * @param int $postId + * @return string (exemplo: "5 votos") + */ +function delibera_get_comments_count_by_type($postId) +{ + $situacao = delibera_get_situacao($postId); + + switch ($situacao->slug) { + case 'validacao': + $count = count(delibera_get_comments_validacoes($postId)); + + if ($count == 0) { + $label = __('Nenhuma validação', 'delibera'); + } else if ($count == 1) { + $label = __('1 validação', 'delibera'); + } else { + $label = sprintf(__('%d validações', 'delibera'), $count); + } + + return $label; + case 'discussao': + $count = count(delibera_get_comments_discussoes($postId)); + + if ($count == 0) { + $label = __('Nenhum comentário', 'delibera'); + } else if ($count == 1) { + $label = __('1 comentário', 'delibera'); + } else { + $label = sprintf(__('%d comentários', 'delibera'), $count); + } + + return $label; + case 'emvotacao': + $count = count(delibera_get_comments_votacoes($postId)); + + if ($count == 0) { + $label = __('Nenhum voto', 'delibera'); + } else if ($count == 1) { + $label = __('1 voto', 'delibera'); + } else { + $label = sprintf(__('%d votos', 'delibera'), $count); + } + + return $label; + } +} + +function delibera_get_comments_types() +{ + return array('validacao', 'discussao', 'encaminhamento', 'encaminhamento_selecionado', 'voto', 'resolucao'); +} \ No newline at end of file diff --git a/delibera_WP_comment.php b/delibera_comments_query.php similarity index 99% rename from delibera_WP_comment.php rename to delibera_comments_query.php index 8ce55ed..43222b0 100644 --- a/delibera_WP_comment.php +++ b/delibera_comments_query.php @@ -28,7 +28,7 @@ function query( $query_vars ) { 'post_parent' => '', 'post_status' => '', 'post_type' => '', - 'tax_query' => '', + 'tax_query' => '', 'status' => '', 'type' => '', 'user_id' => '', @@ -151,9 +151,9 @@ function query( $query_vars ) { } $join .= $compact['join']; $where .= $compact['where']; - } - - + } + + $pieces = array( 'fields', 'join', 'where', 'orderby', 'order', 'limits' ); $clauses = apply_filters_ref_array( 'comments_clauses', array( compact( $pieces ), &$this ) ); foreach ( $pieces as $piece ) @@ -170,6 +170,6 @@ function query( $query_vars ) { return $comments; } - -} + +} ?> \ No newline at end of file From 05b72e8a5f577a987297045aa358cb3957160fec Mon Sep 17 00:00:00 2001 From: Lucas Pirola Date: Mon, 18 Jan 2016 22:42:29 -0200 Subject: [PATCH 007/435] =?UTF-8?q?Move=20mais=20funcoes=20respons=C3=A1ve?= =?UTF-8?q?is=20por=20mudan=C3=A7as=20nos=20coment=C3=A1rios?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- delibera.php | 436 ----------------------------------- delibera_admin_functions.php | 60 ++++- delibera_comments.php | 399 +++++++++++++++++++++++++++++++- 3 files changed, 447 insertions(+), 448 deletions(-) diff --git a/delibera.php b/delibera.php index 54536f5..23678e4 100644 --- a/delibera.php +++ b/delibera.php @@ -970,184 +970,6 @@ function delibera_check_post_data($data, $postarr) add_filter('wp_insert_post_data', 'delibera_check_post_data', 10, 2); -function delibera_get_comments_link() { - global $post; - - return get_permalink($post->ID) . '#delibera-comments'; -} - -function delibera_get_comment_link($comment_pass = false) -{ - global $comment; - if(is_object($comment_pass)) - { - $comment = $comment_pass; - } - - if(!isset($comment)) - { - return str_replace('#comment', '#delibera-comment', get_comments_link()); - } - - return str_replace('#comment', '#delibera-comment', get_comment_link($comment)); -} - -function delibera_comment_post_redirect( $location ) { - global $post, $comment_id; - - return ( $post->post_type == 'pauta' ) ? preg_replace("/#comment-([\d]+)/", "#delibera-comment-" . $comment_id, $location) : $location; -} -add_filter( 'comment_post_redirect', 'delibera_comment_post_redirect' ); - -/** - * - * Comentário em listagem (Visualização) - * @param string $commentText - */ -function delibera_comment_text($commentText) -{ - global $comment, $post, $delibera_comments_padrao; - if(get_post_type($post) == "pauta" && $delibera_comments_padrao !== true) - { - $commentId = isset($comment) ? $comment->comment_ID : false; - $commentText = delibera_comment_text_filtro($commentText, $commentId); - $tipo = get_comment_meta($commentId, "delibera_comment_tipo", true); - $total = 0; - $nvotos = 0; - switch ($tipo) - { - case 'validacao': - { - $validacao = get_comment_meta($comment->comment_ID, "delibera_validacao", true); - $sim = ($validacao == "S" ? true : false); - $commentText = ' -
- '.($sim ? ' - - ' : ' - -
- '); - }break; - case 'discussao': - case 'encaminhamento': - case 'relatoria': - { - $situacao = delibera_get_situacao($comment->comment_post_ID); - if($situacao->slug == 'discussao' || $situacao->slug == 'relatoria') - { - if ($tipo == "discussao") - { - $class_comment = "discussao delibera-comment-text"; - } - else - { - $class_comment = "encaminhamento delibera-comment-text"; - } - $commentText = "
comment_ID."\" class='".$class_comment."'>".$commentText."
"; - } - elseif($situacao->slug == 'comresolucao' && !defined('PRINT')) - { - $total = get_post_meta($comment->comment_post_ID, 'delibera_numero_comments_votos', true); - $nvotos = get_comment_meta($comment->comment_ID, "delibera_comment_numero_votos", true); - $commentText = ' -
- '.$commentText.' -
-
- '.$nvotos.($nvotos == 1 ? " ".__('Voto','delibera') : " ".__('Votos','delibera') ). - '('.( $nvotos > 0 && $total > 0 ? (($nvotos*100)/$total) : 0).'%) -
- '; - } - if(has_filter('delibera_mostra_discussao')) - { - $commentText = apply_filters('delibera_mostra_discussao', $commentText, $total, $nvotos, $situacao->slug); - } - }break; - case 'resolucao': - { - $total = get_post_meta($comment->comment_post_ID, 'delibera_numero_comments_votos', true); - $nvotos = get_comment_meta($comment->comment_ID, "delibera_comment_numero_votos", true); - $commentText = ' -
- '.$commentText.' -
-
- '.$nvotos.($nvotos == 1 ? " ".__('Voto','delibera') : " ".__('Votos','delibera') ). - '('.( $nvotos > 0 && $total > 0 ? (($nvotos*100)/$total) : 0).'%) -
- '; - }break; - case 'voto': - { - $commentText = ' -
- '.$commentText.' -
- '; - }break; - } - if(has_filter('delibera_mostra_discussao')) - { - $commentText = apply_filters('delibera_mostra_discussao', $commentText, $tipo, $total, $nvotos); - } - return $commentText; - } - else - { - return '
'.$commentText.'
'; - } -} - -add_filter('comment_text', 'delibera_comment_text'); - -function delibera_comment_text_filtro($text, $comment_id = false, $show = true) -{ - $opt = delibera_get_config(); - $tamanho = $opt['numero_max_palavras_comentario']; - if($opt['limitar_tamanho_comentario'] === 'S' && strlen($text) > $tamanho) - { - if($comment_id === false) - { - $comment_id = get_comment_ID(); - } - $string_temp = wordwrap($text, $tamanho, '##!##'); - $cut = strpos($string_temp, '##!##'); - - $text = delibera_show_hide_button($comment_id, $text, $cut, $show); - } - return $text; -} - -function delibera_show_hide_button($comment_id, $text, $cut, $show) -{ - $comment_text = $text; - $label = __('Continue lendo este comentário', 'delibera'); - if($show === true) - { - $showhide = ' - ".$showhide_button; - } - else - { - $link = ''.$label.""; - $comment_text = truncate($text, $cut,'…').'
- '.$link; - } - - return $comment_text; -} - /** * * @@ -1249,264 +1071,6 @@ function truncate($text, $length = 100, $ending = '...', $exact = false, $consid return $truncate; } -/** - * - * Comentário na tela de Edição na administração - * @param WP_comment $comment - */ -function delibera_edit_comment($comment) -{ - if(get_post_type($comment->comment_post_ID) == "pauta") - { - $tipo = get_comment_meta($comment->comment_ID, "delibera_comment_tipo", true); - switch ($tipo) - { - case 'validacao': - { - $validacao = get_comment_meta($comment->comment_ID, "delibera_validacao", true); - $sim = ($validacao == "S" ? true : false); - ?> -
- - - - - -
- - comment_ID, "delibera_comment_tipo", true); - $checked = $tipo == "discussao" ? "" : ' checked="checked" '; - ?> - - - - - - ID; - } - - $situacoes_validas = array('validacao' => true, 'discussao' => true, 'emvotacao' => true, 'elegerelator' => true,'relatoria'=>true); - $situacao = delibera_get_situacao($postID); - - if(array_key_exists($situacao->slug, $situacoes_validas)) - { - return $situacoes_validas[$situacao->slug]; - } - - return false; -} - -function delibera_comment_form_action($postID) -{ - if(is_pauta()) - { - global $comment_footer; - echo $comment_footer; - echo ""; - if(function_exists('ecu_upload_form') && $situacao->slug != 'relatoria' && $situacao->slug != 'discussao') - { - echo ''; - } - } -} - -add_action('comment_form', 'delibera_comment_form_action'); - -/** - * - * Salvar custom fields do comentário - * @param int $comment_id - */ -function delibera_save_comment_metas($comment_id) -{ - $tipo = get_comment_meta($comment_id, "delibera_comment_tipo", true); - - if($tipo == false || $tipo == "") - { - if(array_key_exists("delibera_comment_tipo", $_POST)) - { - $tipo = $_POST['delibera_comment_tipo']; - } - } - - delibera_curtir_comment_meta($comment_id); - - delibera_discordar_comment_meta($comment_id); - - $comment = get_comment($comment_id); - - switch($tipo) - { - case "validacao": - { - add_comment_meta($comment_id, 'delibera_validacao', $_POST['delibera_validacao'], true); - add_comment_meta($comment_id, 'delibera_comment_tipo', 'validacao', true); - - if($_POST['delibera_validacao'] == "S") - { - $validacoes = get_post_meta($comment->comment_post_ID, 'numero_validacoes', true); - $validacoes++; - update_post_meta($comment->comment_post_ID, 'numero_validacoes', $validacoes); // Atualiza - delibera_valida_validacoes($comment->comment_post_ID); - } - $nvalidacoes = get_post_meta($comment->comment_post_ID, 'delibera_numero_comments_validacoes', true); - $nvalidacoes++; - update_post_meta($comment->comment_post_ID, 'delibera_numero_comments_validacoes', $nvalidacoes); - }break; - - case 'discussao': - case 'encaminhamento': - { - $encaminhamento = $_POST['delibera_encaminha']; - if($encaminhamento == "S") - { - add_comment_meta($comment_id, 'delibera_comment_tipo', 'encaminhamento', true); - $nencaminhamentos = get_post_meta($comment->comment_post_ID, 'delibera_numero_comments_encaminhamentos', true); - $nencaminhamentos++; - update_post_meta($comment->comment_post_ID, 'delibera_numero_comments_encaminhamentos', $nencaminhamentos); - if(array_key_exists('delibera-baseouseem', $_POST)) - { - add_comment_meta($comment_id, 'delibera-baseouseem', $_POST['delibera-baseouseem'], true); - } - } - else - { - add_comment_meta($comment_id, 'delibera_comment_tipo', 'discussao', true); - $ndiscussoes = get_post_meta($comment->comment_post_ID, 'delibera_numero_comments_discussoes', true); - $ndiscussoes++; - update_post_meta($comment->comment_post_ID, 'delibera_numero_comments_discussoes', $ndiscussoes); - } - if(has_action('delibera_nova_discussao')) - { - do_action('delibera_nova_discussao', $comment_id, $comment, $encaminhamento); - } - }break; - case 'voto': - { - - add_comment_meta($comment_id, 'delibera_comment_tipo', 'voto', true); - - $votos = array(); - - foreach ($_POST as $postkey => $postvar) - { - if( substr($postkey, 0, strlen('delibera_voto')) == 'delibera_voto' ) - { - $votos[] = $postvar; - } - } - - add_comment_meta($comment_id, 'delibera_votos', $votos, true); - - $comment = get_comment($comment_id); - delibera_valida_votos($comment->comment_post_ID); - - $nvotos = get_post_meta($comment->comment_post_ID, 'delibera_numero_comments_votos', true); - $nvotos++; - update_post_meta($comment->comment_post_ID, 'delibera_numero_comments_votos', $nvotos); - - if(has_action('delibera_novo_voto')) - { - do_action('delibera_novo_voto', $comment_id, $comment, $votos); - } - - } break; - - default: - { - $npadroes = get_post_meta($comment->comment_post_ID, 'delibera_numero_comments_padroes', true); - $npadroes++; - update_post_meta($comment->comment_post_ID, 'delibera_numero_comments_padroes', $npadroes); - }break; - } - if(array_search($tipo, delibera_get_comments_types()) !== false) - { - wp_set_comment_status($comment_id, 'approve'); - delibera_notificar_novo_comentario($comment); - do_action('delibera_nova_interacao', $comment_id); - } -} -add_action ('comment_post', 'delibera_save_comment_metas', 1); - -function delibera_pre_edit_comment($dados) -{ - $comment_id = 0; - if(array_key_exists('comment_ID', $_POST)) - { - $comment_id = $_POST['comment_ID']; - } - else - { - global $comment; - if(isset($comment->comment_ID)) - { - $comment_id = $comment->comment_ID; - } - else - { - wp_die(__('Você não pode Editar esse tipo de comentário','delibera')); - } - } - - $tipo = get_comment_meta($comment_id, "delibera_comment_tipo", true); - if(array_search($tipo, delibera_get_comments_types()) !== false) - { - wp_die(__('Você não pode Editar esse tipo de comentário','delibera')); - } -} - -//add_filter('comment_save_pre', 'delibera_pre_edit_comment'); //TODO Verificar edição - -// require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_template.php'; - // Fim Inicialização do plugin // Menu de configuração diff --git a/delibera_admin_functions.php b/delibera_admin_functions.php index 8170bf4..7d71736 100644 --- a/delibera_admin_functions.php +++ b/delibera_admin_functions.php @@ -84,4 +84,62 @@ function delibera_custom_bulk_admin_notices() { } } -add_action('admin_notices', 'delibera_custom_bulk_admin_notices'); \ No newline at end of file +add_action('admin_notices', 'delibera_custom_bulk_admin_notices'); + +/** + * + * Comentário na tela de Edição na administração + * @param WP_comment $comment + */ +function delibera_edit_comment($comment) +{ + if(get_post_type($comment->comment_post_ID) == "pauta") + { + $tipo = get_comment_meta($comment->comment_ID, "delibera_comment_tipo", true); + switch ($tipo) + { + case 'validacao': + { + $validacao = get_comment_meta($comment->comment_ID, "delibera_validacao", true); + $sim = ($validacao == "S" ? true : false); + ?> +
+ + + + + +
+ + comment_ID, "delibera_comment_tipo", true); + $checked = $tipo == "discussao" ? "" : ' checked="checked" '; + ?> + + + + + + slug) { case 'validacao': $count = count(delibera_get_comments_validacoes($postId)); - + if ($count == 0) { $label = __('Nenhuma validação', 'delibera'); } else if ($count == 1) { @@ -71,11 +71,11 @@ function delibera_get_comments_count_by_type($postId) } else { $label = sprintf(__('%d validações', 'delibera'), $count); } - + return $label; case 'discussao': $count = count(delibera_get_comments_discussoes($postId)); - + if ($count == 0) { $label = __('Nenhum comentário', 'delibera'); } else if ($count == 1) { @@ -83,11 +83,11 @@ function delibera_get_comments_count_by_type($postId) } else { $label = sprintf(__('%d comentários', 'delibera'), $count); } - + return $label; case 'emvotacao': $count = count(delibera_get_comments_votacoes($postId)); - + if ($count == 0) { $label = __('Nenhum voto', 'delibera'); } else if ($count == 1) { @@ -95,7 +95,7 @@ function delibera_get_comments_count_by_type($postId) } else { $label = sprintf(__('%d votos', 'delibera'), $count); } - + return $label; } } @@ -103,4 +103,381 @@ function delibera_get_comments_count_by_type($postId) function delibera_get_comments_types() { return array('validacao', 'discussao', 'encaminhamento', 'encaminhamento_selecionado', 'voto', 'resolucao'); -} \ No newline at end of file +} + +function delibera_get_comments_link() { + global $post; + + return get_permalink($post->ID) . '#delibera-comments'; +} + +function delibera_get_comment_link($comment_pass = false) +{ + global $comment; + if(is_object($comment_pass)) + { + $comment = $comment_pass; + } + + if(!isset($comment)) + { + return str_replace('#comment', '#delibera-comment', get_comments_link()); + } + + return str_replace('#comment', '#delibera-comment', get_comment_link($comment)); +} + +function delibera_comment_post_redirect( $location ) { + global $post, $comment_id; + + return ( $post->post_type == 'pauta' ) ? preg_replace("/#comment-([\d]+)/", "#delibera-comment-" . $comment_id, $location) : $location; +} +add_filter( 'comment_post_redirect', 'delibera_comment_post_redirect' ); + +/** + * + * Comentário em listagem (Visualização) + * @param string $commentText + */ +function delibera_comment_text($commentText) +{ + global $comment, $post, $delibera_comments_padrao; + if(get_post_type($post) == "pauta" && $delibera_comments_padrao !== true) + { + $commentId = isset($comment) ? $comment->comment_ID : false; + $commentText = delibera_comment_text_filtro($commentText, $commentId); + $tipo = get_comment_meta($commentId, "delibera_comment_tipo", true); + $total = 0; + $nvotos = 0; + switch ($tipo) + { + case 'validacao': + { + $validacao = get_comment_meta($comment->comment_ID, "delibera_validacao", true); + $sim = ($validacao == "S" ? true : false); + $commentText = ' +
+ '.($sim ? ' + + ' : ' + +
+ '); + }break; + case 'discussao': + case 'encaminhamento': + case 'relatoria': + { + $situacao = delibera_get_situacao($comment->comment_post_ID); + if($situacao->slug == 'discussao' || $situacao->slug == 'relatoria') + { + if ($tipo == "discussao") + { + $class_comment = "discussao delibera-comment-text"; + } + else + { + $class_comment = "encaminhamento delibera-comment-text"; + } + $commentText = "
comment_ID."\" class='".$class_comment."'>".$commentText."
"; + } + elseif($situacao->slug == 'comresolucao' && !defined('PRINT')) + { + $total = get_post_meta($comment->comment_post_ID, 'delibera_numero_comments_votos', true); + $nvotos = get_comment_meta($comment->comment_ID, "delibera_comment_numero_votos", true); + $commentText = ' +
+ '.$commentText.' +
+
+ '.$nvotos.($nvotos == 1 ? " ".__('Voto','delibera') : " ".__('Votos','delibera') ). + '('.( $nvotos > 0 && $total > 0 ? (($nvotos*100)/$total) : 0).'%) +
+ '; + } + if(has_filter('delibera_mostra_discussao')) + { + $commentText = apply_filters('delibera_mostra_discussao', $commentText, $total, $nvotos, $situacao->slug); + } + }break; + case 'resolucao': + { + $total = get_post_meta($comment->comment_post_ID, 'delibera_numero_comments_votos', true); + $nvotos = get_comment_meta($comment->comment_ID, "delibera_comment_numero_votos", true); + $commentText = ' +
+ '.$commentText.' +
+
+ '.$nvotos.($nvotos == 1 ? " ".__('Voto','delibera') : " ".__('Votos','delibera') ). + '('.( $nvotos > 0 && $total > 0 ? (($nvotos*100)/$total) : 0).'%) +
+ '; + }break; + case 'voto': + { + $commentText = ' +
+ '.$commentText.' +
+ '; + }break; + } + if(has_filter('delibera_mostra_discussao')) + { + $commentText = apply_filters('delibera_mostra_discussao', $commentText, $tipo, $total, $nvotos); + } + return $commentText; + } + else + { + return '
'.$commentText.'
'; + } +} + +add_filter('comment_text', 'delibera_comment_text'); + +function delibera_comment_text_filtro($text, $comment_id = false, $show = true) +{ + $opt = delibera_get_config(); + $tamanho = $opt['numero_max_palavras_comentario']; + if($opt['limitar_tamanho_comentario'] === 'S' && strlen($text) > $tamanho) + { + if($comment_id === false) + { + $comment_id = get_comment_ID(); + } + $string_temp = wordwrap($text, $tamanho, '##!##'); + $cut = strpos($string_temp, '##!##'); + + $text = delibera_show_hide_button($comment_id, $text, $cut, $show); + } + return $text; +} + +function delibera_show_hide_button($comment_id, $text, $cut, $show) +{ + $comment_text = $text; + $label = __('Continue lendo este comentário', 'delibera'); + if($show === true) + { + $showhide = ' + ".$showhide_button; + } + else + { + $link = ''.$label.""; + $comment_text = truncate($text, $cut,'…').'
+ '.$link; + } + + return $comment_text; +} + +function delibera_comments_open($open, $post_id) +{ + if ( 'pauta' == get_post_type($post_id) ) + return $open && delibera_can_comment($post_id); + else + return $open; +} +add_filter('comments_open', 'delibera_comments_open', 10, 2); + +/** + * Verifica se é possível fazer comentários, se o usuário tiver poder para tanto + * @param unknown_type $postID + */ +function delibera_comments_is_open($postID = null) +{ + if(is_null($postID)) + { + $post = get_post($postID); + $postID = $post->ID; + } + + $situacoes_validas = array('validacao' => true, 'discussao' => true, 'emvotacao' => true, 'elegerelator' => true,'relatoria'=>true); + $situacao = delibera_get_situacao($postID); + + if(array_key_exists($situacao->slug, $situacoes_validas)) + { + return $situacoes_validas[$situacao->slug]; + } + + return false; +} + +function delibera_comment_form_action($postID) +{ + if(is_pauta()) + { + global $comment_footer; + echo $comment_footer; + echo ""; + if(function_exists('ecu_upload_form') && $situacao->slug != 'relatoria' && $situacao->slug != 'discussao') + { + echo ''; + } + } +} + +add_action('comment_form', 'delibera_comment_form_action'); + +/** + * + * Salvar custom fields do comentário + * @param int $comment_id + */ +function delibera_save_comment_metas($comment_id) +{ + $tipo = get_comment_meta($comment_id, "delibera_comment_tipo", true); + + if($tipo == false || $tipo == "") + { + if(array_key_exists("delibera_comment_tipo", $_POST)) + { + $tipo = $_POST['delibera_comment_tipo']; + } + } + + delibera_curtir_comment_meta($comment_id); + + delibera_discordar_comment_meta($comment_id); + + $comment = get_comment($comment_id); + + switch($tipo) + { + case "validacao": + { + add_comment_meta($comment_id, 'delibera_validacao', $_POST['delibera_validacao'], true); + add_comment_meta($comment_id, 'delibera_comment_tipo', 'validacao', true); + + if($_POST['delibera_validacao'] == "S") + { + $validacoes = get_post_meta($comment->comment_post_ID, 'numero_validacoes', true); + $validacoes++; + update_post_meta($comment->comment_post_ID, 'numero_validacoes', $validacoes); // Atualiza + delibera_valida_validacoes($comment->comment_post_ID); + } + $nvalidacoes = get_post_meta($comment->comment_post_ID, 'delibera_numero_comments_validacoes', true); + $nvalidacoes++; + update_post_meta($comment->comment_post_ID, 'delibera_numero_comments_validacoes', $nvalidacoes); + }break; + + case 'discussao': + case 'encaminhamento': + { + $encaminhamento = $_POST['delibera_encaminha']; + if($encaminhamento == "S") + { + add_comment_meta($comment_id, 'delibera_comment_tipo', 'encaminhamento', true); + $nencaminhamentos = get_post_meta($comment->comment_post_ID, 'delibera_numero_comments_encaminhamentos', true); + $nencaminhamentos++; + update_post_meta($comment->comment_post_ID, 'delibera_numero_comments_encaminhamentos', $nencaminhamentos); + if(array_key_exists('delibera-baseouseem', $_POST)) + { + add_comment_meta($comment_id, 'delibera-baseouseem', $_POST['delibera-baseouseem'], true); + } + } + else + { + add_comment_meta($comment_id, 'delibera_comment_tipo', 'discussao', true); + $ndiscussoes = get_post_meta($comment->comment_post_ID, 'delibera_numero_comments_discussoes', true); + $ndiscussoes++; + update_post_meta($comment->comment_post_ID, 'delibera_numero_comments_discussoes', $ndiscussoes); + } + if(has_action('delibera_nova_discussao')) + { + do_action('delibera_nova_discussao', $comment_id, $comment, $encaminhamento); + } + }break; + case 'voto': + { + + add_comment_meta($comment_id, 'delibera_comment_tipo', 'voto', true); + + $votos = array(); + + foreach ($_POST as $postkey => $postvar) + { + if( substr($postkey, 0, strlen('delibera_voto')) == 'delibera_voto' ) + { + $votos[] = $postvar; + } + } + + add_comment_meta($comment_id, 'delibera_votos', $votos, true); + + $comment = get_comment($comment_id); + delibera_valida_votos($comment->comment_post_ID); + + $nvotos = get_post_meta($comment->comment_post_ID, 'delibera_numero_comments_votos', true); + $nvotos++; + update_post_meta($comment->comment_post_ID, 'delibera_numero_comments_votos', $nvotos); + + if(has_action('delibera_novo_voto')) + { + do_action('delibera_novo_voto', $comment_id, $comment, $votos); + } + + } break; + + default: + { + $npadroes = get_post_meta($comment->comment_post_ID, 'delibera_numero_comments_padroes', true); + $npadroes++; + update_post_meta($comment->comment_post_ID, 'delibera_numero_comments_padroes', $npadroes); + }break; + } + if(array_search($tipo, delibera_get_comments_types()) !== false) + { + wp_set_comment_status($comment_id, 'approve'); + delibera_notificar_novo_comentario($comment); + do_action('delibera_nova_interacao', $comment_id); + } +} +add_action ('comment_post', 'delibera_save_comment_metas', 1); + +function delibera_pre_edit_comment($dados) +{ + $comment_id = 0; + if(array_key_exists('comment_ID', $_POST)) + { + $comment_id = $_POST['comment_ID']; + } + else + { + global $comment; + if(isset($comment->comment_ID)) + { + $comment_id = $comment->comment_ID; + } + else + { + wp_die(__('Você não pode Editar esse tipo de comentário','delibera')); + } + } + + $tipo = get_comment_meta($comment_id, "delibera_comment_tipo", true); + if(array_search($tipo, delibera_get_comments_types()) !== false) + { + wp_die(__('Você não pode Editar esse tipo de comentário','delibera')); + } +} + +//add_filter('comment_save_pre', 'delibera_pre_edit_comment'); //TODO Verificar edição + +// require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_template.php'; \ No newline at end of file From 79468d3c9597d93cc89e3281eca8816ac156da20 Mon Sep 17 00:00:00 2001 From: Lucas Pirola Date: Mon, 18 Jan 2016 22:56:54 -0200 Subject: [PATCH 008/435] Padroniza nome dos arquivos que alteram configuracoes --- delibera.php | 2 +- delibera_conf.php | 56 +++++++++---------- delibera_roles.php => delibera_conf_roles.php | 0 ...era_themes.php => delibera_conf_themes.php | 0 4 files changed, 29 insertions(+), 29 deletions(-) rename delibera_roles.php => delibera_conf_roles.php (100%) rename delibera_themes.php => delibera_conf_themes.php (100%) diff --git a/delibera.php b/delibera.php index 23678e4..cab70d3 100644 --- a/delibera.php +++ b/delibera.php @@ -133,7 +133,7 @@ function delibera_pauta_redirect_filter($location, $post_id = null) { } add_filter('redirect_post_location', 'delibera_pauta_redirect_filter', '99'); -require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_themes.php'; +require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_conf_themes.php'; if(file_exists(__DIR__.DIRECTORY_SEPARATOR.'delibera_filtros.php')) { diff --git a/delibera_conf.php b/delibera_conf.php index 3914412..9912d28 100644 --- a/delibera_conf.php +++ b/delibera_conf.php @@ -1,22 +1,22 @@ getThemeDir('creta'); $opt['minimo_validacao'] = '10'; @@ -57,7 +57,7 @@ function delibera_get_main_config($config = array()) { $opt['cabecalho_arquivo'] = __( 'Bem-vindo a plataforma de debate do ', 'delibera' ).get_bloginfo('name'); $opt['todos_usuarios_logados_podem_participar'] = 'N'; $opt['data_fixa_nova_pauta_externa'] = ''; - + return array_merge($opt, $config); } add_filter('delibera_get_config', 'delibera_get_main_config'); @@ -65,24 +65,24 @@ function delibera_get_main_config($config = array()) { /** * Gera o HTML da página de configuração * do Delibera - * + * * @return null */ function delibera_conf_page() { global $deliberaThemes; - + $mensagem = ''; if ($_SERVER['REQUEST_METHOD']=='POST') { $opt = delibera_get_config(); - + if (!current_user_can('manage_options')) { die(__('Você não pode editar as configurações do delibera.','delibera')); } - + check_admin_referer('delibera-config'); - + foreach (array_keys(delibera_get_main_config()) as $option_name) { if (isset($_POST[$option_name])) { $opt[$option_name] = htmlspecialchars($_POST[$option_name]); @@ -98,7 +98,7 @@ function delibera_conf_page() wp_die($e->getMessage()); } } - + // atualiza os permalinks por conta da opção "criar_pauta_pelo_front_end" flush_rewrite_rules(); @@ -110,11 +110,11 @@ function delibera_conf_page() $opt = delibera_get_config(); ?> - +

Configurações gerais

-
+
@@ -122,9 +122,9 @@ function delibera_conf_page()
- __('Mínimo de validações para uma pauta:', 'delibera'), "content" => '' ); - + $rows[] = array( "id" => "dias_validacao", "label" => __('Dias para validação da pauta:', 'delibera'), "content" => '' ); - + $rows[] = array( "id" => "dias_discussao", "label" => __('Dias para discussão da pauta:', 'delibera'), "content" => '' ); - + $rows[] = array( "id" => "dias_votacao", "label" => __('Dias para votação de encaminhamentos:', 'delibera'), "content" => '' ); - + $rows[] = array( "id" => "dias_novo_prazo", "label" => __('Dias para novo prazo:', 'delibera'), @@ -242,16 +242,16 @@ function delibera_conf_page() } echo $table.'
'; ?> - +
- +
- Date: Mon, 18 Jan 2016 23:05:27 -0200 Subject: [PATCH 009/435] =?UTF-8?q?Padroniza=20nome=20do=20arquivo=20que?= =?UTF-8?q?=20faz=20altera=C3=A7=C3=A3o=20nos=20comment=C3=A1rios?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- delibera.php | 1 - delibera_comments.php | 1 + delibera_edit_comment.php => delibera_comments_edit.php | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename delibera_edit_comment.php => delibera_comments_edit.php (100%) diff --git a/delibera.php b/delibera.php index cab70d3..dd78c3c 100644 --- a/delibera.php +++ b/delibera.php @@ -804,7 +804,6 @@ function delibera_save_post($post_id, $post) require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_curtir.php'; require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_discordar.php'; require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_seguir.php'; -require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_edit_comment.php'; if(file_exists(__DIR__.DIRECTORY_SEPARATOR.'mailer') && file_exists(__DIR__.DIRECTORY_SEPARATOR.'mailer'.DIRECTORY_SEPARATOR.'delibera_mailer.php')) { diff --git a/delibera_comments.php b/delibera_comments.php index 5378a6f..3081e9f 100644 --- a/delibera_comments.php +++ b/delibera_comments.php @@ -1,6 +1,7 @@ Date: Tue, 19 Jan 2016 09:41:51 -0200 Subject: [PATCH 010/435] =?UTF-8?q?Padroniza=20nome=20dos=20arquivos=20por?= =?UTF-8?q?=20se=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- delibera_init.php | 3 ++- delibera_theme_selector.php => delibera_plan_theme.php | 0 ...a_registered_users_only.php => delibera_plan_users_only.php | 0 3 files changed, 2 insertions(+), 1 deletion(-) rename delibera_theme_selector.php => delibera_plan_theme.php (100%) rename delibera_registered_users_only.php => delibera_plan_users_only.php (100%) diff --git a/delibera_init.php b/delibera_init.php index 28e602f..3a0bfa7 100644 --- a/delibera_init.php +++ b/delibera_init.php @@ -304,7 +304,8 @@ function delibera_print_styles() { } -add_action('wp_print_styles', 'delibera_print_styles');*/ +add_action('wp_print_styles', 'delibera_print_styles'); +*/ function delibera_print_styles() { diff --git a/delibera_theme_selector.php b/delibera_plan_theme.php similarity index 100% rename from delibera_theme_selector.php rename to delibera_plan_theme.php diff --git a/delibera_registered_users_only.php b/delibera_plan_users_only.php similarity index 100% rename from delibera_registered_users_only.php rename to delibera_plan_users_only.php From 7c0641bcacae810a571d567ffe58c429a0bb61e7 Mon Sep 17 00:00:00 2001 From: Lucas Pirola Date: Tue, 19 Jan 2016 09:56:40 -0200 Subject: [PATCH 011/435] Criar arquivos utils para funcoes que nao sao actions ou filters --- delibera.php | 527 +----------------------------------------- delibera_comments.php | 322 +++++++++++++++++++++++++- delibera_init.php | 18 ++ delibera_plan.php | 19 ++ delibera_utils.php | 164 +++++++++++++ 5 files changed, 524 insertions(+), 526 deletions(-) create mode 100644 delibera_utils.php diff --git a/delibera.php b/delibera.php index dd78c3c..7d9cbea 100644 --- a/delibera.php +++ b/delibera.php @@ -63,32 +63,9 @@ require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_init.php'; -/** - * - * Revemos acentos do texto - * @param string $texto - * @return string - */ -function delibera_tiracento($texto) -{ - $trocarIsso = array('à','á','â','ã','ä','å','ç','è','é','ê','ë','ì','í','î','ï','ñ','ò','ó','ô','õ','ö','ù','ü','ú','ÿ','À','Á','Â','Ã','Ä','Å','Ç','È','É','Ê','Ë','Ì','Í','Î','Ï','Ñ','Ò','Ó','Ô','Õ','Ö','Ù','Ü','Ú','Ÿ',); - $porIsso = array('a','a','a','a','a','a','c','e','e','e','e','i','i','i','i','n','o','o','o','o','o','u','u','u','y','A','A','A','A','A','A','C','E','E','E','E','I','I','I','I','N','O','O','O','O','O','U','U','U','Y',); - $titletext = str_replace($trocarIsso, $porIsso, $texto); - return $titletext; -} +require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_utils.php'; -function delibera_slug_under($label) -{ - $slug = delibera_tiracento($label); - $slug = str_replace(array("'",'"','.',',',';','!'), '', $slug); - $slug = str_replace(array(' ', '-'), '_', $slug); - return strtolower($slug); -} - -function is_pauta($post = false) -{ - return get_post_type($post) == 'pauta' ? true : false; -} +require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_comments.php'; /** * @@ -439,15 +416,6 @@ function delibera_pauta_meta() /', '', $text)) <= $length) { - return $text; - } - // splits all html-tags to scanable lines - preg_match_all('/(<.+?>)?([^<>]*)/s', $text, $lines, PREG_SET_ORDER); - $total_length = strlen($ending); - $open_tags = array(); - $truncate = ''; - foreach ($lines as $line_matchings) { - // if there is any html-tag in this line, handle it and add it (uncounted) to the output - if (!empty($line_matchings[1])) { - // if it's an "empty element" with or without xhtml-conform closing slash - if (preg_match('/^<(\s*.+?\/\s*|\s*(img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param)(\s.+?)?)>$/is', $line_matchings[1])) { - // do nothing - // if tag is a closing tag - } else if (preg_match('/^<\s*\/([^\s]+?)\s*>$/s', $line_matchings[1], $tag_matchings)) { - // delete tag from $open_tags list - $pos = array_search($tag_matchings[1], $open_tags); - if ($pos !== false) { - unset($open_tags[$pos]); - } - // if tag is an opening tag - } else if (preg_match('/^<\s*([^\s>!]+).*?>$/s', $line_matchings[1], $tag_matchings)) { - // add tag to the beginning of $open_tags list - array_unshift($open_tags, strtolower($tag_matchings[1])); - } - // add html-tag to $truncate'd text - $truncate .= $line_matchings[1]; - } - // calculate the length of the plain text part of the line; handle entities as one character - $content_length = strlen(preg_replace('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', ' ', $line_matchings[2])); - if ($total_length+$content_length> $length) { - // the number of characters which are left - $left = $length - $total_length; - $entities_length = 0; - // search for html entities - if (preg_match_all('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', $line_matchings[2], $entities, PREG_OFFSET_CAPTURE)) { - // calculate the real length of all entities in the legal range - foreach ($entities[0] as $entity) { - if ($entity[1]+1-$entities_length <= $left) { - $left--; - $entities_length += strlen($entity[0]); - } else { - // no more characters left - break; - } - } - } - $truncate .= substr($line_matchings[2], 0, $left+$entities_length); - // maximum lenght is reached, so get off the loop - break; - } else { - $truncate .= $line_matchings[2]; - $total_length += $content_length; - } - // if the maximum length is reached, get off the loop - if($total_length>= $length) { - break; - } - } - } else { - if (strlen($text) <= $length) { - return $text; - } else { - $truncate = substr($text, 0, $length - strlen($ending)); - } - } - // if the words shouldn't be cut in the middle... - if (!$exact) { - // ...search the last occurance of a space... - $spacepos = strrpos($truncate, ' '); - if (isset($spacepos)) { - // ...and cut the text in this position - $truncate = substr($truncate, 0, $spacepos); - } - } - // add the defined ending to the text - $truncate .= $ending; - if($considerHtml) { - // close all unclosed html-tags - foreach ($open_tags as $tag) { - $truncate .= ''; - } - } - return $truncate; -} - -// Fim Inicialização do plugin - -// Menu de configuração - -function delibera_config_menu() -{ - /*if (function_exists('add_menu_page')) - add_menu_page( __('Delibera','delibera'), __('Delibera plugin','delibera'), 'manage_options', 'delibera-config', 'delibera_conf_page');*/ - - $base_page = 'delibera-config'; - - if (function_exists('add_menu_page')) - { - add_object_page( __('Delibera','delibera'), __('Delibera','delibera'), 'manage_options', $base_page, array(), WP_PLUGIN_URL."/delibera/images/delibera_icon.png"); - //add_submenu_page($base_page, __('Pesquisar Contatos','delibera'), __('Pesquisar Contatos','delibera'), 'manage_options', 'delibera-gerenciar', 'delibera_GerenciarContato' ); - //add_submenu_page($base_page, __('Criar Contato','delibera'), __('Criar Contato','delibera'), 'manage_options', 'delibera-criar', 'delibera_CriarContato' ); - //add_submenu_page($base_page, __('Importar Contatos','delibera'), __('Importar Contatos','delibera'), 'manage_options', 'delibera-importar', 'delibera_ImportarContato' ); - add_submenu_page($base_page, __('Configurações do Plugin','delibera'),__('Configurações do Plugin','delibera'), 'manage_options', 'delibera-config', 'delibera_conf_page'); - do_action('delibera_menu_itens', $base_page); - } -} - -/** - * Create a form table from an array of rows - */ -function delibera_form_table($rows) { - $content = ''; - foreach ($rows as $row) { - $content .= ''; - } - $content .= '
'; - - if (isset($row['id']) && $row['id'] != '') { - $content .= ''; - } else { - $content .= $row['label']; - } - - if (isset($row['desc']) && $row['desc'] != '') { - $content .= '
'.$row['desc'].''; - } - - $content .= '
'; - $content .= $row['content']; - $content .= '
'; - return $content; -} - -// Funções de conteudo - /** * * Retorna post do tipo pauta em uma determinada situacao (validacao, discussao, emvotacao ou comresolucao), usando um filtro @@ -1203,262 +1020,6 @@ function delibera_get_resolucoes($filtro = array()) return delibera_get_pautas_em($filtro, 'comresolucao'); } -require_once 'delibera_comments_template.php'; - -function delibera_get_comments_padrao($args = array(), $file = '/comments.php' ) -{ - global $delibera_comments_padrao; - $delibera_comments_padrao = true; - comments_template($file); - $delibera_comments_padrao = false; -} - -/** - * Retorna comentários do Delibera de acordo com o tipo. - * - * @param int $post_id - * @param string|array $tipo um tipo ou um array de tipos - * @return array - */ -function delibera_get_comments($post_id, $tipo, $args = array()) -{ - if (is_string($tipo)) { - $tipo = array($tipo); - } - - $args = array_merge(array('post_id' => $post_id), $args); - $comments = get_comments($args); - $ret = array(); - foreach ($comments as $comment) - { - $comment_tipo = get_comment_meta($comment->comment_ID, 'delibera_comment_tipo', true); - if (in_array($comment_tipo, $tipo)) { - $ret[] = $comment; - } - } - return $ret; -} - -require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_comments.php'; - - -function delibera_wp_list_comments($args = array(), $comments = null) -{ - global $post; - global $delibera_comments_padrao; - - if(get_post_type($post) == "pauta") - { - $situacao = delibera_get_situacao($post->ID); - - if($delibera_comments_padrao === true) - { - $args['post_id'] = $post->ID; - $args['walker'] = new Delibera_Walker_Comment_padrao(); - $comments = get_comments($args); - $ret = array(); - foreach ($comments as $comment) - { - $tipo_tmp = get_comment_meta($comment->comment_ID, 'delibera_comment_tipo', true); - if(strlen($tipo_tmp) <= 0 || $tipo_tmp === false) - { - $ret[] = $comment; - } - } - wp_list_comments($args, $ret); - } - elseif($situacao->slug == 'validacao') - { - //comment_form(); - $args['walker'] = new Delibera_Walker_Comment(); - //$args['callback'] = 'delibera_comments_list'; - ?> -
- -
- slug == 'comresolucao') - { - $args['walker'] = new Delibera_Walker_Comment(); - wp_list_comments($args, $comments); - - $encaminhamentos = delibera_get_comments_encaminhamentos($post->ID); - $discussoes = delibera_get_comments_discussoes($post->ID); - ?> -
- -
- -
-
-

- -
- - query( $args ); -} - -function delibera_get_comments_validacoes($post_id) -{ - return delibera_get_comments($post_id, 'validacao'); -} - -function delibera_get_comments_discussoes($post_id) -{ - return delibera_get_comments($post_id, 'discussao'); -} - -function delibera_get_comments_encaminhamentos($post_id) -{ - return delibera_get_comments($post_id, 'encaminhamento'); -} - -/** - * Retorna os encaminhamentos dos tipos 'encaminhamento' e - * 'encaminhamento_selecionado' (aqueles que foram selecionados - * pelo relator para ir para votação). - * - * @param int $post_id - * @return array - */ -function delibera_get_comments_all_encaminhamentos($post_id) -{ - return delibera_get_comments($post_id, array('encaminhamento', 'encaminhamento_selecionado')); -} - -/** - * Retorna os encaminhamentos do tipo 'encaminhamento_selecionado' - * (aqueles que foram selecionados pelo relator para ir para votação). - * - * @param int $post_id - * @return array - */ -function delibera_get_comments_encaminhamentos_selecionados($post_id) -{ - return delibera_get_comments($post_id, 'encaminhamento_selecionado'); -} - - -function delibera_get_comments_votacoes($post_id) -{ - return delibera_get_comments($post_id, 'voto'); -} - -function delibera_get_comments_resolucoes($post_id) -{ - if(has_filter('delibera_get_resolucoes')) - { - return apply_filters('delibera_get_resolucoes', delibera_get_comments($post_id, 'resolucao')); - } - return delibera_get_comments($post_id, 'resolucao'); -} - -/** - * - * Busca comentários com o tipo em tipos - * @param array $comments lista de comentários a ser filtrada - * @param array $tipos tipos aceitos - */ -function delibera_comments_filter_portipo($comments, $tipos) -{ - $ret = array(); - - foreach ($comments as $comment) - { - $tipo = get_comment_meta($comment->comment_ID, 'delibera_comment_tipo', true); - if(array_search($tipo, $tipos) !== false) - { - $ret[] = $comment; - } - } - return $ret; -} - -/** - * - * Filtro que retorna Comentário filtrados pela a situação da pauta - * @param array $comments - * @param int $postID - * @return array Comentários filtrados - */ -function delibera_get_comments_filter($comments) -{ - global $delibera_comments_padrao; - - if($delibera_comments_padrao === true) return $comments; - - $ret = array(); - - if(count($comments) > 0) - { - if(get_post_type($comments[0]->comment_post_ID) == "pauta") - { - $situacao = delibera_get_situacao($comments[0]->comment_post_ID); - switch ($situacao->slug) - { - case 'validacao': - { - $ret = delibera_comments_filter_portipo($comments, array('validacao')); - }break; - case 'discussao': - { - $ret = delibera_comments_filter_portipo($comments, array('discussao', 'encaminhamento')); - }break; - case 'relatoria': - { - $ret = delibera_comments_filter_portipo($comments, array('discussao', 'encaminhamento')); - }break; - case 'emvotacao': - { - $ret = delibera_comments_filter_portipo($comments, array('voto')); - }break; - case 'comresolucao': - { - $ret = delibera_comments_filter_portipo($comments, array('resolucao')); - }break; - } - return $ret; - } - } - return $comments; -} - -add_filter('comments_array', 'delibera_get_comments_filter'); /** * Retorna um inteiro indicando quantos dias faltam para o fim do prazo @@ -1557,70 +1118,6 @@ function delibera_post_custom_column($column) add_action('manage_posts_custom_column', 'delibera_post_custom_column'); -function delibera_comment_number($postID, $tipo) -{ - switch($tipo) - { - case 'validacao': - return doubleval(get_post_meta($postID, 'delibera_numero_comments_validacoes', true)); - break; - case 'discussao': - return doubleval(get_post_meta($postID, 'delibera_numero_comments_discussoes', true)); - break; - case 'encaminhamento': - return doubleval(get_post_meta($postID, 'delibera_numero_comments_encaminhamentos', true)); - break; - case 'voto': - return doubleval(get_post_meta($postID, 'delibera_numero_comments_votos', true)); - break; - /*case 'resolucao': - return doubleval(get_post_meta($postID, 'delibera_numero_comments_resolucoes', true)); TODO Número de resoluções, baseado no mínimo de votos, ou marcação especial - break;*/ - case 'todos': - return get_post($postID)->comment_count; - break; - default: - return doubleval(get_post_meta($postID, 'delibera_numero_comments_padroes', true)); - break; - } -} - -function delibera_comment_number_filtro($count, $postID) -{ - if (!is_pauta()) { - return $count; - } - $situacao = delibera_get_situacao($postID); - - if (!$situacao) { - return; - } - - switch($situacao->slug) - { - case 'validacao': - return doubleval(get_post_meta($postID, 'delibera_numero_comments_validacoes', true)); - break; - case 'discussao': - case 'comresolucao': - return doubleval( - get_post_meta($postID, 'delibera_numero_comments_encaminhamentos', true) + - get_post_meta($postID, 'delibera_numero_comments_discussoes', true) - ); - break; - case 'relatoria': - return doubleval(get_post_meta($postID, 'delibera_numero_comments_encaminhamentos', true)); - break; - case 'emvotacao': - return doubleval(get_post_meta($postID, 'delibera_numero_comments_votos', true)); - break; - default: - return doubleval(get_post_meta($postID, 'delibera_numero_comments_padroes', true)); - break; - } -} - -add_filter('get_comments_number', 'delibera_comment_number_filtro', 10, 2); function delibera_restrict_listings() { @@ -1978,26 +1475,6 @@ function delibera_set_novo_prazo_discussao_relatoria($postID, $inova_data, $opts } -function delibera_get_plan_config() -{ - $plan = 'N'; - - if( is_multisite() && get_current_blog_id() != 1 ) - { - switch_to_blog(1); - $opt = delibera_get_config(); - $plan = $opt['plan_restriction']; - restore_current_blog(); - } - else - { - $opt = delibera_get_config(); - $plan = $opt['plan_restriction']; - } - - return $plan; -} - add_action('init', 'delibera_nova_pauta_create_action'); function delibera_nova_pauta_create_action(){ diff --git a/delibera_comments.php b/delibera_comments.php index 3081e9f..f5c15eb 100644 --- a/delibera_comments.php +++ b/delibera_comments.php @@ -481,4 +481,324 @@ function delibera_pre_edit_comment($dados) //add_filter('comment_save_pre', 'delibera_pre_edit_comment'); //TODO Verificar edição -// require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_template.php'; \ No newline at end of file +// require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_template.php'; + +function delibera_get_comments_padrao($args = array(), $file = '/comments.php' ) +{ + global $delibera_comments_padrao; + $delibera_comments_padrao = true; + comments_template($file); + $delibera_comments_padrao = false; +} + +/** + * Retorna comentários do Delibera de acordo com o tipo. + * + * @param int $post_id + * @param string|array $tipo um tipo ou um array de tipos + * @return array + */ +function delibera_get_comments($post_id, $tipo, $args = array()) +{ + if (is_string($tipo)) { + $tipo = array($tipo); + } + + $args = array_merge(array('post_id' => $post_id), $args); + $comments = get_comments($args); + $ret = array(); + foreach ($comments as $comment) + { + $comment_tipo = get_comment_meta($comment->comment_ID, 'delibera_comment_tipo', true); + if (in_array($comment_tipo, $tipo)) { + $ret[] = $comment; + } + } + return $ret; +} + +require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_comments.php'; + + +function delibera_wp_list_comments($args = array(), $comments = null) +{ + global $post; + global $delibera_comments_padrao; + + if(get_post_type($post) == "pauta") + { + $situacao = delibera_get_situacao($post->ID); + + if($delibera_comments_padrao === true) + { + $args['post_id'] = $post->ID; + $args['walker'] = new Delibera_Walker_Comment_padrao(); + $comments = get_comments($args); + $ret = array(); + foreach ($comments as $comment) + { + $tipo_tmp = get_comment_meta($comment->comment_ID, 'delibera_comment_tipo', true); + if(strlen($tipo_tmp) <= 0 || $tipo_tmp === false) + { + $ret[] = $comment; + } + } + wp_list_comments($args, $ret); + } + elseif($situacao->slug == 'validacao') + { + //comment_form(); + $args['walker'] = new Delibera_Walker_Comment(); + //$args['callback'] = 'delibera_comments_list'; + ?> +
+ +
+ slug == 'comresolucao') + { + $args['walker'] = new Delibera_Walker_Comment(); + wp_list_comments($args, $comments); + + $encaminhamentos = delibera_get_comments_encaminhamentos($post->ID); + $discussoes = delibera_get_comments_discussoes($post->ID); + ?> +
+ +
+ +
+
+

+ +
+ + query( $args ); +} + +function delibera_get_comments_validacoes($post_id) +{ + return delibera_get_comments($post_id, 'validacao'); +} + +function delibera_get_comments_discussoes($post_id) +{ + return delibera_get_comments($post_id, 'discussao'); +} + +function delibera_get_comments_encaminhamentos($post_id) +{ + return delibera_get_comments($post_id, 'encaminhamento'); +} + +/** + * Retorna os encaminhamentos dos tipos 'encaminhamento' e + * 'encaminhamento_selecionado' (aqueles que foram selecionados + * pelo relator para ir para votação). + * + * @param int $post_id + * @return array + */ +function delibera_get_comments_all_encaminhamentos($post_id) +{ + return delibera_get_comments($post_id, array('encaminhamento', 'encaminhamento_selecionado')); +} + +/** + * Retorna os encaminhamentos do tipo 'encaminhamento_selecionado' + * (aqueles que foram selecionados pelo relator para ir para votação). + * + * @param int $post_id + * @return array + */ +function delibera_get_comments_encaminhamentos_selecionados($post_id) +{ + return delibera_get_comments($post_id, 'encaminhamento_selecionado'); +} + + +function delibera_get_comments_votacoes($post_id) +{ + return delibera_get_comments($post_id, 'voto'); +} + +function delibera_get_comments_resolucoes($post_id) +{ + if(has_filter('delibera_get_resolucoes')) + { + return apply_filters('delibera_get_resolucoes', delibera_get_comments($post_id, 'resolucao')); + } + return delibera_get_comments($post_id, 'resolucao'); +} + +/** + * + * Busca comentários com o tipo em tipos + * @param array $comments lista de comentários a ser filtrada + * @param array $tipos tipos aceitos + */ +function delibera_comments_filter_portipo($comments, $tipos) +{ + $ret = array(); + + foreach ($comments as $comment) + { + $tipo = get_comment_meta($comment->comment_ID, 'delibera_comment_tipo', true); + if(array_search($tipo, $tipos) !== false) + { + $ret[] = $comment; + } + } + return $ret; +} + +/** + * + * Filtro que retorna Comentário filtrados pela a situação da pauta + * @param array $comments + * @param int $postID + * @return array Comentários filtrados + */ +function delibera_get_comments_filter($comments) +{ + global $delibera_comments_padrao; + + if($delibera_comments_padrao === true) return $comments; + + $ret = array(); + + if(count($comments) > 0) + { + if(get_post_type($comments[0]->comment_post_ID) == "pauta") + { + $situacao = delibera_get_situacao($comments[0]->comment_post_ID); + switch ($situacao->slug) + { + case 'validacao': + { + $ret = delibera_comments_filter_portipo($comments, array('validacao')); + }break; + case 'discussao': + { + $ret = delibera_comments_filter_portipo($comments, array('discussao', 'encaminhamento')); + }break; + case 'relatoria': + { + $ret = delibera_comments_filter_portipo($comments, array('discussao', 'encaminhamento')); + }break; + case 'emvotacao': + { + $ret = delibera_comments_filter_portipo($comments, array('voto')); + }break; + case 'comresolucao': + { + $ret = delibera_comments_filter_portipo($comments, array('resolucao')); + }break; + } + return $ret; + } + } + return $comments; +} + +add_filter('comments_array', 'delibera_get_comments_filter'); + +function delibera_comment_number($postID, $tipo) +{ + switch($tipo) + { + case 'validacao': + return doubleval(get_post_meta($postID, 'delibera_numero_comments_validacoes', true)); + break; + case 'discussao': + return doubleval(get_post_meta($postID, 'delibera_numero_comments_discussoes', true)); + break; + case 'encaminhamento': + return doubleval(get_post_meta($postID, 'delibera_numero_comments_encaminhamentos', true)); + break; + case 'voto': + return doubleval(get_post_meta($postID, 'delibera_numero_comments_votos', true)); + break; + /*case 'resolucao': + return doubleval(get_post_meta($postID, 'delibera_numero_comments_resolucoes', true)); TODO Número de resoluções, baseado no mínimo de votos, ou marcação especial + break;*/ + case 'todos': + return get_post($postID)->comment_count; + break; + default: + return doubleval(get_post_meta($postID, 'delibera_numero_comments_padroes', true)); + break; + } +} + +function delibera_comment_number_filtro($count, $postID) +{ + if (!is_pauta()) { + return $count; + } + $situacao = delibera_get_situacao($postID); + + if (!$situacao) { + return; + } + + switch($situacao->slug) + { + case 'validacao': + return doubleval(get_post_meta($postID, 'delibera_numero_comments_validacoes', true)); + break; + case 'discussao': + case 'comresolucao': + return doubleval( + get_post_meta($postID, 'delibera_numero_comments_encaminhamentos', true) + + get_post_meta($postID, 'delibera_numero_comments_discussoes', true) + ); + break; + case 'relatoria': + return doubleval(get_post_meta($postID, 'delibera_numero_comments_encaminhamentos', true)); + break; + case 'emvotacao': + return doubleval(get_post_meta($postID, 'delibera_numero_comments_votos', true)); + break; + default: + return doubleval(get_post_meta($postID, 'delibera_numero_comments_padroes', true)); + break; + } +} + +add_filter('get_comments_number', 'delibera_comment_number_filtro', 10, 2); \ No newline at end of file diff --git a/delibera_init.php b/delibera_init.php index 3a0bfa7..00a5b0e 100644 --- a/delibera_init.php +++ b/delibera_init.php @@ -382,4 +382,22 @@ function delibera_get_available_languages() { } return $langs; +} + +function delibera_config_menu() +{ + /*if (function_exists('add_menu_page')) + add_menu_page( __('Delibera','delibera'), __('Delibera plugin','delibera'), 'manage_options', 'delibera-config', 'delibera_conf_page');*/ + + $base_page = 'delibera-config'; + + if (function_exists('add_menu_page')) + { + add_object_page( __('Delibera','delibera'), __('Delibera','delibera'), 'manage_options', $base_page, array(), WP_PLUGIN_URL."/delibera/images/delibera_icon.png"); + //add_submenu_page($base_page, __('Pesquisar Contatos','delibera'), __('Pesquisar Contatos','delibera'), 'manage_options', 'delibera-gerenciar', 'delibera_GerenciarContato' ); + //add_submenu_page($base_page, __('Criar Contato','delibera'), __('Criar Contato','delibera'), 'manage_options', 'delibera-criar', 'delibera_CriarContato' ); + //add_submenu_page($base_page, __('Importar Contatos','delibera'), __('Importar Contatos','delibera'), 'manage_options', 'delibera-importar', 'delibera_ImportarContato' ); + add_submenu_page($base_page, __('Configurações do Plugin','delibera'),__('Configurações do Plugin','delibera'), 'manage_options', 'delibera-config', 'delibera_conf_page'); + do_action('delibera_menu_itens', $base_page); + } } \ No newline at end of file diff --git a/delibera_plan.php b/delibera_plan.php index adc87ac..8160529 100644 --- a/delibera_plan.php +++ b/delibera_plan.php @@ -198,4 +198,23 @@ function delibera_plan_config_page() add_action('delibera_config_page_extra', 'delibera_plan_config_page'); +function delibera_get_plan_config() +{ + $plan = 'N'; + + if( is_multisite() && get_current_blog_id() != 1 ) + { + switch_to_blog(1); + $opt = delibera_get_config(); + $plan = $opt['plan_restriction']; + restore_current_blog(); + } + else + { + $opt = delibera_get_config(); + $plan = $opt['plan_restriction']; + } + + return $plan; +} ?> diff --git a/delibera_utils.php b/delibera_utils.php new file mode 100644 index 0000000..b8e8c83 --- /dev/null +++ b/delibera_utils.php @@ -0,0 +1,164 @@ +/', '', $text)) <= $length) { + return $text; + } + // splits all html-tags to scanable lines + preg_match_all('/(<.+?>)?([^<>]*)/s', $text, $lines, PREG_SET_ORDER); + $total_length = strlen($ending); + $open_tags = array(); + $truncate = ''; + foreach ($lines as $line_matchings) { + // if there is any html-tag in this line, handle it and add it (uncounted) to the output + if (!empty($line_matchings[1])) { + // if it's an "empty element" with or without xhtml-conform closing slash + if (preg_match('/^<(\s*.+?\/\s*|\s*(img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param)(\s.+?)?)>$/is', $line_matchings[1])) { + // do nothing + // if tag is a closing tag + } else if (preg_match('/^<\s*\/([^\s]+?)\s*>$/s', $line_matchings[1], $tag_matchings)) { + // delete tag from $open_tags list + $pos = array_search($tag_matchings[1], $open_tags); + if ($pos !== false) { + unset($open_tags[$pos]); + } + // if tag is an opening tag + } else if (preg_match('/^<\s*([^\s>!]+).*?>$/s', $line_matchings[1], $tag_matchings)) { + // add tag to the beginning of $open_tags list + array_unshift($open_tags, strtolower($tag_matchings[1])); + } + // add html-tag to $truncate'd text + $truncate .= $line_matchings[1]; + } + // calculate the length of the plain text part of the line; handle entities as one character + $content_length = strlen(preg_replace('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', ' ', $line_matchings[2])); + if ($total_length+$content_length> $length) { + // the number of characters which are left + $left = $length - $total_length; + $entities_length = 0; + // search for html entities + if (preg_match_all('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', $line_matchings[2], $entities, PREG_OFFSET_CAPTURE)) { + // calculate the real length of all entities in the legal range + foreach ($entities[0] as $entity) { + if ($entity[1]+1-$entities_length <= $left) { + $left--; + $entities_length += strlen($entity[0]); + } else { + // no more characters left + break; + } + } + } + $truncate .= substr($line_matchings[2], 0, $left+$entities_length); + // maximum lenght is reached, so get off the loop + break; + } else { + $truncate .= $line_matchings[2]; + $total_length += $content_length; + } + // if the maximum length is reached, get off the loop + if($total_length>= $length) { + break; + } + } + } else { + if (strlen($text) <= $length) { + return $text; + } else { + $truncate = substr($text, 0, $length - strlen($ending)); + } + } + // if the words shouldn't be cut in the middle... + if (!$exact) { + // ...search the last occurance of a space... + $spacepos = strrpos($truncate, ' '); + if (isset($spacepos)) { + // ...and cut the text in this position + $truncate = substr($truncate, 0, $spacepos); + } + } + // add the defined ending to the text + $truncate .= $ending; + if($considerHtml) { + // close all unclosed html-tags + foreach ($open_tags as $tag) { + $truncate .= ''; + } + } + return $truncate; +} + +/** + * Create a form table from an array of rows + */ +function delibera_form_table($rows) { + $content = ''; + foreach ($rows as $row) { + $content .= ''; + } + $content .= '
'; + + if (isset($row['id']) && $row['id'] != '') { + $content .= ''; + } else { + $content .= $row['label']; + } + + if (isset($row['desc']) && $row['desc'] != '') { + $content .= '
'.$row['desc'].''; + } + + $content .= '
'; + $content .= $row['content']; + $content .= '
'; + return $content; +} \ No newline at end of file From 9b6225ca7211555b2b359c44658755943020b6f6 Mon Sep 17 00:00:00 2001 From: Lucas Pirola Date: Tue, 19 Jan 2016 10:30:14 -0200 Subject: [PATCH 012/435] =?UTF-8?q?Remove=20arquivos=20n=C3=A3o=20utilizad?= =?UTF-8?q?os=20e=20move=20shortcode=20da=20timeline?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- delibera.php | 7 ---- delibera_loop_pauta.php | 64 ------------------------------- delibera_shortcodes.php | 56 +++++++++++++++------------ delibera_taxs.php | 5 --- timeline/delibera_timeline.php | 69 ++++++++++++---------------------- 5 files changed, 56 insertions(+), 145 deletions(-) delete mode 100644 delibera_loop_pauta.php delete mode 100644 delibera_taxs.php diff --git a/delibera.php b/delibera.php index 7d9cbea..1fc6f25 100644 --- a/delibera.php +++ b/delibera.php @@ -1195,13 +1195,6 @@ function delibera_ultimas($tipo = 'pauta', $args = array(), $count = 5) } } -function delibera_timeline($post_id = false, $tipo_data = false) -{ - require_once __DIR__.DIRECTORY_SEPARATOR.'timeline/delibera_timeline.php'; - $timeline = new delibera_timeline(); - $timeline->generate($post_id, $tipo_data); -} - function delibera_the_posts($posts) { if (empty($posts)) return $posts; diff --git a/delibera_loop_pauta.php b/delibera_loop_pauta.php deleted file mode 100644 index f19f153..0000000 --- a/delibera_loop_pauta.php +++ /dev/null @@ -1,64 +0,0 @@ -
> -

- - - - -
- -
- -
- post_content; - $content = apply_filters('the_content', $content); - $content = str_replace(']]>', ']]>', $content); - echo $content; - ?> - '' ) ); ?> -
- - -
- - - - - | - - - - - - - - ID)->name; ?> - -
-
diff --git a/delibera_shortcodes.php b/delibera_shortcodes.php index 4ac732c..b907ffe 100644 --- a/delibera_shortcodes.php +++ b/delibera_shortcodes.php @@ -1,16 +1,16 @@ -'; $post = $old; - + return ''; // Retornar código da representação } add_shortcode( 'delibera_lista_de_propostas', 'delibera_replace_propostas' ); function delibera_replace_pautas($matches) -{ +{ $temp = explode(',', $matches[1]); // configurações da shorttag $count = count($temp); - + $param = array(); // TODO Tratar Parametros - + $html = delibera_get_pautas($param); $wp_posts = $html; global $post; @@ -46,18 +46,18 @@ function delibera_replace_pautas($matches) } echo '
'; $post = $old; - + return ''; // Retornar código da representação } add_shortcode( 'delibera_lista_de_pautas', 'delibera_replace_pautas' ); function delibera_replace_resolucoes($matches) -{ +{ $temp = explode(',', $matches[1]); // configurações da shorttag $count = count($temp); - + $param = array(); // TODO Tratar Parametros - + $html = delibera_get_resolucoes($param); $wp_posts = $html; global $post; @@ -70,30 +70,37 @@ function delibera_replace_resolucoes($matches) } echo ''; $post = $old; - + return ''; // Retornar código da representação } add_shortcode( 'delibera_lista_de_resolucoes', 'delibera_replace_resolucoes' ); function delibera_replace_agendamentos($matches) -{ +{ global $wp_filter; $temp = explode(',', $matches[1]); // configurações da shorttag $count = count($temp); - + $param = array(); // TODO Tratar Parametros - + $html = print_r($wp_filter, true); - + return $html; // Retornar código da representação } add_shortcode( 'delibera_lista_de_agendamentos', 'delibera_replace_agendamentos' ); +function delibera_timeline($post_id = false, $tipo_data = false) +{ + require_once __DIR__.DIRECTORY_SEPARATOR.'timeline/delibera_timeline.php'; + $timeline = new delibera_timeline(); + $timeline->generate($post_id, $tipo_data); +} + function delibera_replace_timeline($args) { $atts = array('post_id' => false, 'tipo_data' => false); $atts = array_merge($atts, $args); - + return delibera_timeline($atts['post_id'], $atts['tipo_data']); } add_shortcode( 'delibera_timeline', 'delibera_replace_timeline' ); @@ -103,7 +110,7 @@ function delibera_replace_like($matches) $temp = explode(',', $matches[1]); // configurações da shorttag $count = count($temp); $param = array(); // TODO Tratar Parametros - + return delibera_gerar_curtir(get_the_ID()); } add_shortcode( 'delibera_like', 'delibera_replace_like' ); @@ -113,7 +120,7 @@ function delibera_replace_unlike($matches) $temp = explode(',', $matches[1]); // configurações da shorttag $count = count($temp); $param = array(); // TODO Tratar Parametros - + return delibera_gerar_discordar(get_the_ID()); } add_shortcode( 'delibera_unlike', 'delibera_replace_unlike' ); @@ -123,7 +130,7 @@ function delibera_replace_seguir($matches) $temp = explode(',', $matches[1]); // configurações da shorttag $count = count($temp); $param = array(); // TODO Tratar Parametros - + return delibera_gerar_seguir(get_the_ID()); } add_shortcode( 'delibera_seguir', 'delibera_replace_seguir' ); @@ -137,12 +144,11 @@ function delibera_replace_basear($args) $server = $_SERVER['SERVER_NAME']; $endereco = $_SERVER ['REQUEST_URI']; $site_url = "http".(array_key_exists('HTTPS', $_SERVER))."://".$server.$endereco; - + $html = ''; - + return $html; } add_shortcode( 'delibera_basear', 'delibera_replace_basear' ); - // End Parse shorttag ?> \ No newline at end of file diff --git a/delibera_taxs.php b/delibera_taxs.php deleted file mode 100644 index 1543980..0000000 --- a/delibera_taxs.php +++ /dev/null @@ -1,5 +0,0 @@ - \ No newline at end of file diff --git a/timeline/delibera_timeline.php b/timeline/delibera_timeline.php index 7e8cfb7..5e97da4 100644 --- a/timeline/delibera_timeline.php +++ b/timeline/delibera_timeline.php @@ -11,12 +11,12 @@ public function get_dados($postID = false, $tipo_data = false) $pautas = delibera_get_pautas_em(); $comments = delibera_wp_get_comments(); } - else + else { $pautas = array(get_post($postID)); $comments = delibera_wp_get_comments(array('post_id' => $postID)); } - + $events = array(); foreach($pautas as $pauta) { @@ -31,7 +31,7 @@ public function get_dados($postID = false, $tipo_data = false) 'body' => apply_filters('the_content', $pauta->post_content), //'date_event' => date('d/m/Y H:i:s', $data) 'date_event' => $data - ); + ); } foreach($comments as $comment) { @@ -46,32 +46,32 @@ public function get_dados($postID = false, $tipo_data = false) 'body' => apply_filters('comment_text', get_comment_text($comment->comment_ID)), //'date_event' => date('d/m/Y H:i:s', $data) 'date_event' => $data - ); + ); } ksort($events, SORT_NUMERIC); - + return $this->filtrar($events, $tipo_data); } - + public function get_config() { $opt = array(); $opt['tipo_data'] = 'quinzenal'; - + $opt_conf = get_option('delibera-timeline-config', array()); if(!is_array($opt_conf)) $opt_conf = array(); $opt = array_merge($opt, $opt_conf); - + return $opt; } - + public function filtrar($events, $tipo_data = false) { $new_events = array(); if($tipo_data === false) { $opt = $this->get_config(); - $tipo_data = $opt['tipo_data']; + $tipo_data = $opt['tipo_data']; } switch ($tipo_data) { @@ -124,32 +124,32 @@ public function filtrar($events, $tipo_data = false) } return $new_events; } - + public function generate($postID = false, $tipo_data = false) { $dates = $this->get_dados($postID, $tipo_data); $colors = array('green','blue','chreme'); $scrollPoints = ''; - + $i=0; $html = '
'; foreach($dates as $year=>$array) { // Loop through the years: - + $html .= '
'.$year.'
    '; - + foreach($array as $event) { // Loop through the events in the current year: - + $html .= '
  • '.htmlspecialchars($event['title']).' - +
    '.($event['type']=='image'?'
    Image
    ':nl2br($event['body'])).'
    '.htmlspecialchars($event['title']).'
    @@ -157,16 +157,16 @@ public function generate($postID = false, $tipo_data = false)
  • '; } - + $html .= '
'; - + // Generate a list of years for the time line scroll bar: $scrollPoints.='
'.$year.'
'; } $html_bar_head ='
- +
@@ -174,7 +174,7 @@ public function generate($postID = false, $tipo_data = false)
- +
@@ -185,7 +185,7 @@ public function generate($postID = false, $tipo_data = false) $html_bar_tail = '
- +
@@ -193,17 +193,17 @@ public function generate($postID = false, $tipo_data = false)
- +
- '; + '; echo $html_bar_head.$html.$html_bar_tail.'
'; } - + } add_filter('query_vars', 'timeline_variables'); @@ -224,23 +224,4 @@ function delibera_timeline_template_redirect() } } -add_action('template_redirect', 'delibera_timeline_template_redirect', 5); - -new delibera_timeline(); - -function delibera_timeline($post_id = false, $tipo_data = false) -{ - $timeline = new delibera_timeline(); - $timeline->generate($post_id, $tipo_data); -} - -function delibera_replace_timeline($args) -{ - $atts = array('post_id' => false, 'tipo_data' => false); - $atts = array_merge($atts, $args); - - return delibera_timeline($atts['post_id'], $atts['tipo_data']); -} -add_shortcode( 'delibera_timeline', 'delibera_replace_timeline' ); - -?> \ No newline at end of file +add_action('template_redirect', 'delibera_timeline_template_redirect', 5); \ No newline at end of file From 0040c06179c7aa43bf803819b77906a0c6508d98 Mon Sep 17 00:00:00 2001 From: Lucas Pirola Date: Tue, 19 Jan 2016 10:32:34 -0200 Subject: [PATCH 013/435] Corrige bug na timeline, quando lista posts admin carrega css indevido --- delibera.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/delibera.php b/delibera.php index 1fc6f25..1339315 100644 --- a/delibera.php +++ b/delibera.php @@ -1217,7 +1217,7 @@ function delibera_the_posts($posts) } } - if ($timeline_found) + if ( ($timeline_found) && (!is_admin()) ) { // enqueue here wp_enqueue_style('delibera_timeline_css', WP_CONTENT_URL.'/plugins/delibera/timeline/delibera_timeline.css'); From 0b6dee2f61987770ead1ec5c00640b0a5f988de2 Mon Sep 17 00:00:00 2001 From: Lucas Pirola Date: Tue, 19 Jan 2016 11:18:43 -0200 Subject: [PATCH 014/435] Move funcoes relacionada a pauta e a prazos para arquivos separados --- delibera.php | 1085 +--------------------------------- delibera_admin_functions.php | 41 +- delibera_topic.php | 585 ++++++++++++++++++ delibera_topic_deadline.php | 441 ++++++++++++++ delibera_utils.php | 24 + 5 files changed, 1094 insertions(+), 1082 deletions(-) create mode 100644 delibera_topic.php create mode 100644 delibera_topic_deadline.php diff --git a/delibera.php b/delibera.php index 1339315..0408c8d 100644 --- a/delibera.php +++ b/delibera.php @@ -67,6 +67,7 @@ require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_comments.php'; + /** * * Insere term no banco e atualizar línguas do qtranslate @@ -101,51 +102,7 @@ function delibera_insert_term($label, $tax, $term, $idiomas = array()) } } -function delibera_pauta_redirect_filter($location, $post_id = null) { - - if (strpos($_SERVER['HTTP_REFERER'], "post_type=pauta")) - return admin_url("edit.php")."?post_type=pauta&updated=1"; - else - return $location; -} -add_filter('redirect_post_location', 'delibera_pauta_redirect_filter', '99'); - -require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_conf_themes.php'; - -if(file_exists(__DIR__.DIRECTORY_SEPARATOR.'delibera_filtros.php')) -{ - require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_filtros.php'; -} - -function delibera_pauta_custom_meta() -{ - add_meta_box("pauta_meta", "Detalhes da Pauta", 'delibera_pauta_meta', 'pauta', 'side', 'default'); -} - -function delibera_forca_fim_prazo($postID) -{ - $situacao = delibera_get_situacao($postID); - switch($situacao->slug) - { - case 'discussao': - delibera_tratar_prazo_discussao(array( - 'post_ID' => $postID, - 'prazo_discussao' => date('d/m/Y') - )); - break; - case 'relatoria': - delibera_tratar_prazo_relatoria(array( - 'post_ID' => $postID, - 'prazo_relatoria' => date('d/m/Y') - )); - break; - case 'emvotacao': - delibera_computa_votos($postID); - break; - } - //delibera_notificar_situacao($postID); -} function delibera_admin_list_options($actions, $post) { @@ -177,600 +134,14 @@ function delibera_admin_list_options($actions, $post) add_filter('post_row_actions','delibera_admin_list_options', 10, 2); -function delibera_forca_fim_prazo_action() -{ - if(current_user_can('forcar_prazo') && check_admin_referer('delibera_forca_fim_prazo_action'.$_REQUEST['post'], '_wpnonce')) - { - delibera_forca_fim_prazo($_REQUEST['post']); - - wp_redirect( admin_url( 'edit.php?post_type=pauta') ); - } - else - { - wp_die(__('Você não tem permissão para forçar um prazo','delibera'), __('Sem permissão','delibera')); - } -} -add_action('admin_action_delibera_forca_fim_prazo_action', 'delibera_forca_fim_prazo_action'); - -function delibera_nao_validado_action() -{ - if(current_user_can('forcar_prazo') && check_admin_referer('delibera_nao_validado_action'.$_REQUEST['post'], '_wpnonce')) - { - delibera_marcar_naovalidada($_REQUEST['post']); - - wp_redirect( admin_url( 'edit.php?post_type=pauta') ); - } - else - { - wp_die(__('Você não tem permissão para invalidar uma pauta','delibera'), __('Sem permissão','delibera')); - } -} -add_action('admin_action_delibera_nao_validado_action', 'delibera_nao_validado_action'); - -function delibera_reabrir_pauta_action() -{ - if(current_user_can('delibera_reabrir_pauta') && check_admin_referer('delibera_reabrir_pauta_action'.$_REQUEST['post'], '_wpnonce')) - { - delibera_reabrir_pauta($_REQUEST['post']); - - wp_redirect( admin_url( 'edit.php?post_type=pauta') ); - } - else - { - wp_die(__('Você não tem permissão para re-abrir discussão sobre uma pauta','delibera'), __('Sem permissão','delibera')); - } -} -add_action('admin_action_delibera_reabrir_pauta_action', 'delibera_reabrir_pauta_action'); - require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_cron.php'; -/** - * - * Retorna a situação do post - * @param int $postID - * @return mixed validacao, discussao, elegerelator, relatoria, emvotacao, comresolucao, naovalidada ou false - */ -function delibera_get_situacao($postID) -{ - $situacao = get_the_terms($postID, 'situacao'); - $ret = false; - if(is_array($situacao) && count($situacao) > 0) - { - $ret = array_pop($situacao); - } - - if(!is_object($ret)) // if term situacao does not exists - { - $ret = new stdClass(); - $ret->slug = ''; - $ret->name = ''; - } - - if(has_filter('delibera_get_situacao')) - { - return apply_filters('delibera_get_situacao', $ret); - } - - return $ret; -} - -/** - * Retorna o label do botão com a situação da - * pauta. - * - * @param int $postId - * @return string - */ -function delibera_get_situation_button($postId) -{ - $situacao = get_the_terms($postId, 'situacao'); - - if (is_array($situacao) && !empty($situacao)) { - $situacao = array_pop($situacao); - } - - switch($situacao->slug) { - case 'emvotacao': - return 'Votar'; - case 'discussao': - return 'Discutir'; - case 'validacao': - return 'Votar'; - default: - return; - } -} - -function delibera_update_edit_form() { - echo ' enctype="multipart/form-data"'; -} // end update_edit_form -add_action('post_edit_form_tag', 'delibera_update_edit_form'); - -function delibera_pauta_meta() -{ - global $post; - - $custom = get_post_custom($post->ID); - $options_plugin_delibera = delibera_get_config(); - - if(!is_array($custom)) $custom = array(); - $validacoes = array_key_exists("numero_validacoes", $custom) ? $custom["numero_validacoes"][0] : 0; - - $min_validacoes = array_key_exists("min_validacoes", $custom) ? $custom["min_validacoes"][0] : htmlentities($options_plugin_delibera['minimo_validacao']); - - $situacao = delibera_get_situacao($post->ID); - - $dias_validacao = intval(htmlentities($options_plugin_delibera['dias_validacao'])); - $dias_discussao = intval(htmlentities($options_plugin_delibera['dias_discussao'])); - $dias_relatoria = intval(htmlentities($options_plugin_delibera['dias_relatoria'])); - $dias_votacao_relator = intval(htmlentities($options_plugin_delibera['dias_votacao_relator'])); - - $pauta_pdf_file = get_post_meta($post->ID, 'pauta_pdf_contribution', true); - - // Recupera arquivo caso já tenha sido adicionados - $pdf_html = "

"; - if( $pauta_pdf_file ) { - $pdf_html .= "Arquivo Atual
"; - } - $pdf_html .= "

"; - echo $pdf_html; - - if($options_plugin_delibera['validacao'] == "S") // Adiciona prazo de validação se for necessário - { - $dias_discussao += $dias_validacao; - } - - $dias_votacao = $dias_discussao + intval(htmlentities($options_plugin_delibera['dias_votacao'])); - - if($options_plugin_delibera['relatoria'] == "S") // Adiciona prazo de relatoria se for necessário - { - $dias_votacao += $dias_relatoria; - $dias_relatoria += $dias_discussao; - if($options_plugin_delibera['eleicao_relator'] == "S") // Adiciona prazo de vatacao relator se for necessário - { - $dias_votacao += $dias_votacao_relator; - $dias_relatoria += $dias_votacao_relator; - $dias_votacao_relator += $dias_discussao; - } - } - - $now = strtotime(date('Y/m/d')." 11:59:59"); - - $prazo_validacao_sugerido = strtotime("+$dias_validacao days", $now); - $prazo_discussao_sugerido = strtotime("+$dias_discussao days", $now); - $prazo_eleicao_relator_sugerido = strtotime("+$dias_votacao_relator days", $now); - $prazo_relatoria_sugerido = strtotime("+$dias_relatoria days", $now); - $prazo_votacao_sugerido = strtotime("+$dias_votacao days", $now); - - $prazo_validacao = date('d/m/Y', $prazo_validacao_sugerido); - $prazo_discussao = date('d/m/Y', $prazo_discussao_sugerido); - $prazo_eleicao_relator = date('d/m/Y', $prazo_eleicao_relator_sugerido); - $prazo_relatoria = date('d/m/Y', $prazo_relatoria_sugerido); - $prazo_votacao = date('d/m/Y', $prazo_votacao_sugerido); - - if ( - $options_plugin_delibera['representante_define_prazos'] == "N" && - !($post->post_status == 'draft' || - $post->post_status == 'auto-draft' || - $post->post_status == 'pending') - ) - { - $disable_edicao = 'readonly="readonly"'; - } else { - $disable_edicao = ''; - } - - if(!($post->post_status == 'draft' || - $post->post_status == 'auto-draft' || - $post->post_status == 'pending')) - { - $prazo_validacao = array_key_exists("prazo_validacao", $custom) ? $custom["prazo_validacao"][0] : $prazo_validacao; - $prazo_discussao = array_key_exists("prazo_discussao", $custom) ? $custom["prazo_discussao"][0] : $prazo_discussao; - $prazo_eleicao_relator = array_key_exists("prazo_eleicao_relator", $custom) ? $custom["prazo_eleicao_relator"][0] : $prazo_eleicao_relator; - $prazo_relatoria = array_key_exists("prazo_relatoria", $custom) ? $custom["prazo_relatoria"][0] : $prazo_relatoria; - $prazo_votacao = array_key_exists("prazo_votacao", $custom) ? $custom["prazo_votacao"][0] : $prazo_votacao; - } - - if($options_plugin_delibera['validacao'] == "S") - { - ?> -

- - id="min_validacoes" name="min_validacoes" class="min_validacoes widefat" value=""/> -

-

- - id="prazo_validacao" name="prazo_validacao" class="prazo_validacao widefat hasdatepicker" value=""/> -

- -

- - id="prazo_discussao" name="prazo_discussao" class="prazo_discussao widefat hasdatepicker" value=""/> -

- -

- - id="prazo_eleicao_relator" name="prazo_eleicao_relator" class="prazo_eleicao_relator widefat hasdatepicker" value=""/> -

- -

- - id="prazo_relatoria" name="prazo_relatoria" class="prazo_relatoria widefat hasdatepicker" value=""/> -

- -

- - id="prazo_votacao" name="prazo_votacao" class="prazo_votacao widefat hasdatepicker" value=""/> -

- $postID, - 'prazo_validacao' => $prazo_validacao - ) - ); - delibera_add_cron( - strtotime("-1 day", delibera_tratar_data($prazo_validacao)), - 'delibera_notificar_fim_prazo', - array( - 'post_ID' => $postID, - 'prazo_validacao' => $prazo_validacao - ) - ); - } - - if($prazo_discussao !== false) - { - delibera_add_cron( - delibera_tratar_data($prazo_discussao), - 'delibera_tratar_prazo_discussao', - array( - 'post_ID' => $postID, - 'prazo_discussao' => $prazo_discussao - ) - ); - delibera_add_cron( - strtotime("-1 day", delibera_tratar_data($prazo_discussao)), - 'delibera_notificar_fim_prazo', - array( - 'post_ID' => $postID, - 'prazo_discussao' => $prazo_discussao - ) - ); - } - - if($prazo_eleicao_relator != false) - { - delibera_add_cron( - delibera_tratar_data($prazo_eleicao_relator), - 'delibera_tratar_prazo_eleicao_relator', - array( - 'post_ID' => $postID, - 'prazo_votacao' => $prazo_eleicao_relator - ) - ); - delibera_add_cron( - strtotime("-1 day", delibera_tratar_data($prazo_eleicao_relator)), - 'delibera_notificar_fim_prazo', - array( - 'post_ID' => $postID, - 'prazo_votacao' => $prazo_eleicao_relator - ) - ); - } - - if($prazo_relatoria != false) - { - delibera_add_cron( - delibera_tratar_data($prazo_relatoria), - 'delibera_tratar_prazo_relatoria', - array( - 'post_ID' => $postID, - 'prazo_votacao' => $prazo_relatoria - ) - ); - delibera_add_cron( - strtotime("-1 day", delibera_tratar_data($prazo_relatoria)), - 'delibera_notificar_fim_prazo', - array( - 'post_ID' => $postID, - 'prazo_votacao' => $prazo_relatoria - ) - ); - } - - if($prazo_votacao != false) - { - delibera_add_cron( - delibera_tratar_data($prazo_votacao), - 'delibera_tratar_prazo_votacao', - array( - 'post_ID' => $postID, - 'prazo_votacao' => $prazo_votacao - ) - ); - delibera_add_cron( - strtotime("-1 day", delibera_tratar_data($prazo_votacao)), - 'delibera_notificar_fim_prazo', - array( - 'post_ID' => $postID, - 'prazo_votacao' => $prazo_votacao - ) - ); - } -} - -function delibera_tratar_prazos($args) -{ - $situacao = delibera_get_situacao($args['post_ID']); - switch ($situacao->slug) - { - case 'validacao': - delibera_tratar_prazo_validacao($args); - break; - case 'discussao': - delibera_tratar_prazo_discussao($args); - break; - case 'relatoria': - delibera_tratar_prazo_relatoria($args); - break; - case 'emvotacao': - delibera_tratar_prazo_votacao($args); - break; - } -} - -add_action('delibera_tratar_prazos', 'delibera_tratar_prazos', 1, 1); - -function delibera_tratar_prazo_validacao($args) -{ - $situacao = delibera_get_situacao($args['post_ID']); - if($situacao->slug == 'validacao') - { - delibera_marcar_naovalidada($args['post_ID']); - } -} - -function delibera_tratar_prazo_discussao($args) -{ - $situacao = delibera_get_situacao($args['post_ID']); - if($situacao->slug == 'discussao') - { - $post_id = $args['post_ID']; - if(count(delibera_get_comments_encaminhamentos($post_id)) > 0) - { - $opts = delibera_get_config(); - if($opts['eleicao_relator'] == 'S') - { - wp_set_object_terms($post_id, 'eleicaoredator', 'situacao', false); //Mudar situação para Votação - } - elseif($opts['relatoria'] == 'S') - { - wp_set_object_terms($post_id, 'relatoria', 'situacao', false); //Mudar situação para Votação - } - else - { - wp_set_object_terms($post_id, 'emvotacao', 'situacao', false); //Mudar situação para Votação - } - if(has_action('delibera_discussao_concluida')) - { - do_action('delibera_discussao_concluida', $post_id); - } - } - else - { - delibera_novo_prazo($post_id); - } - } -} - -function delibera_tratar_prazo_relatoria($args) -{ - $situacao = delibera_get_situacao($args['post_ID']); - if($situacao->slug == 'relatoria') - { - $post_id = $args['post_ID']; - if(count(delibera_get_comments_encaminhamentos($post_id)) > 0) - { - wp_set_object_terms($post_id, 'emvotacao', 'situacao', false); //Mudar situação para Votação - //delibera_notificar_situacao($post_id); - if(has_action('delibera_relatoria_concluida')) - { - do_action('delibera_relatoria_concluida', $post_id); - } - } - else - { - delibera_novo_prazo($post_id); - } - } -} - -function delibera_tratar_prazo_votacao($args) -{ - $situacao = delibera_get_situacao($args['post_ID']); - if($situacao->slug == 'emvotacao') - { - delibera_computa_votos($args['post_ID']); - } -} - -function delibera_marcar_naovalidada($postID) -{ - wp_set_object_terms($postID, 'naovalidada', 'situacao', false); - if(has_action('delibera_pauta_recusada')) - { - do_action('delibera_pauta_recusada', $postID); - } -} - -function delibera_reabrir_pauta($postID) -{ - wp_set_object_terms($postID, 'validacao', 'situacao', false); - //delibera_notificar_situacao($postID); - - delibera_novo_prazo($postID); -} - -/** - * - * Save o post da pauta - * @param $post_id int - * @param $post - */ -function delibera_save_post($post_id, $post) -{ - if(get_post_type( $post_id ) != "pauta") - { - return $post_id; - } - $opt = delibera_get_config(); - $autosave = ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ); - - if( - ( // Se tem validação, tem que ter o prazo - $opt['validacao'] == 'N' || - (array_key_exists('prazo_validacao', $_POST) && array_key_exists('min_validacoes', $_POST) ) - ) && - ( // Se tem relatoria, tem que ter o prazo - $opt['relatoria'] == 'N' || - array_key_exists('prazo_relatoria', $_POST) - ) && - ( // Se tem relatoria, e é preciso eleger o relator, tem que ter o prazo para eleição - $opt['relatoria'] == 'N' || - ( - $opt['eleicao_relator'] == 'N' || - array_key_exists('prazo_eleicao_relator', $_POST) - ) - ) && - array_key_exists('prazo_discussao', $_POST) && - array_key_exists('prazo_votacao', $_POST) - ) - { - $events_meta = array(); - - $validacoes = get_post_meta($post_id, 'numero_validacoes', true); - if($validacoes == "" || $validacoes === false || is_null($validacoes)) - { - $events_meta['numero_validacoes'] = 0; - $events_meta['delibera_numero_comments_validacoes'] = 0; - $events_meta['delibera_numero_comments_encaminhamentos'] = 0; - $events_meta['delibera_numero_comments_discussoes'] = 0; - $events_meta['delibera_numero_comments_votos'] = 0; - $events_meta['delibera_numero_comments_padroes'] = 0; - $events_meta['delibera_numero_curtir'] = 0; - $events_meta['delibera_curtiram'] = array(); - $events_meta['delibera_numero_discordar'] = 0; - $events_meta['delibera_discordaram'] = array(); - $events_meta['delibera_numero_seguir'] = 0; - $events_meta['delibera_seguiram'] = array(); - } - - $events_meta['prazo_validacao'] = $opt['validacao'] == 'S' ? $_POST['prazo_validacao'] : date('d/m/Y'); - $events_meta['prazo_discussao'] = $_POST['prazo_discussao']; - $events_meta['prazo_relatoria'] = $opt['relatoria'] == 'S' ? $_POST['prazo_relatoria'] : date('d/m/Y'); - $events_meta['prazo_eleicao_relator'] = $opt['relatoria'] == 'S' && $opt['eleicao_relator'] == 'S' ? $_POST['prazo_eleicao_relator'] : date('d/m/Y'); - $events_meta['prazo_votacao'] = $_POST['prazo_votacao']; - $events_meta['min_validacoes'] = $opt['validacao'] == 'S' ? $_POST['min_validacoes'] : 10; - - /* ######### START ######### */ - /* ######### FOR PDF UPLOAD FILE ######### */ - // Setup the array of supported file types. In this case, it's just PDF. - $supported_types = array('application/pdf'); - - // Get the file type of the upload - $arr_uploaded_file_type = wp_check_filetype(basename($_FILES['pauta_pdf_contribution']['name'])); - $uploaded_file_type = $arr_uploaded_file_type['type']; - - if (isset ($_FILES['pauta_pdf_contribution']['name']) && $_FILES['pauta_pdf_contribution']['name'] != '') { - if (!in_array($uploaded_file_type, $supported_types)) { - //TODO: Improve this message and avoid wp_die - wp_die("O arquivo para web não é um PDF (formato permitido)."); - } - - - // Use the WordPress API to upload the file - $upload_pauta_pdf = wp_upload_bits($_FILES['pauta_pdf_contribution']['name'], null, file_get_contents($_FILES['pauta_pdf_contribution']['tmp_name'])); - - if (isset($upload_pauta_pdf['error']) && $upload_pauta_pdf['error'] != 0) { - $events_meta['pauta_pdf_contribution'] = none; - wp_die('Erro ao salvar arquivo para Web. O erro foi: ' . $upload_pauta_pdf['error']); - } else { - $events_meta['pauta_pdf_contribution'] = $upload_pauta_pdf['url']; - - global $wpdb; - - $wpdb->query($wpdb->prepare("UPDATE " . $wpdb->prefix . "posts SET post_content=%s WHERE ID=%d", '', $post->ID)); - } - } - /* ######### FOR PDF UPLOAD FILE ######### */ - /* ######### END ######### */ - - foreach ($events_meta as $key => $value) // Buscar dados - { - if(get_post_meta($post->ID, $key, true)) // Se já existe - { - update_post_meta($post->ID, $key, $value); // Atualiza - } - else - { - add_post_meta($post->ID, $key, $value, true); // Senão, cria - } - } - - if( - array_key_exists('delibera_fim_prazo', $_POST) && - $_POST['delibera_fim_prazo'] == 'S' && - current_user_can('forcar_prazo') - ) - { - delibera_forca_fim_prazo($post->ID); - } - - if($post->post_status == 'publish' && !$autosave) - { - delibera_del_cron($post->ID); - delibera_publish_pauta($post->ID, $post, true); - } - - } - -} - -add_action ('save_post', 'delibera_save_post', 1, 2); +require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_topic.php'; require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_curtir.php'; + require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_discordar.php'; + require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_seguir.php'; if(file_exists(__DIR__.DIRECTORY_SEPARATOR.'mailer') && file_exists(__DIR__.DIRECTORY_SEPARATOR.'mailer'.DIRECTORY_SEPARATOR.'delibera_mailer.php')) @@ -778,347 +149,6 @@ function delibera_save_post($post_id, $post) //require_once __DIR__.DIRECTORY_SEPARATOR.'mailer'.DIRECTORY_SEPARATOR.'delibera_mailer.php'; } -function delibera_publish_pauta($postID, $post, $alterar = false) -{ - if(get_post_type( $postID ) != "pauta") - { - return $postID; - } - - if ( - $alterar || ( - ($post->post_status == 'publish' || $_POST['publish'] == 'Publicar') && - ( - ( - array_key_exists('prev_status', $_POST) && - ( - $_POST['prev_status'] == 'draft' || - $_POST['prev_status'] == 'pending' - ) - ) || - ( - array_key_exists('original_post_status', $_POST) && ( - $_POST['original_post_status'] == 'draft' || - $_POST['original_post_status'] == 'auto-draft' || - $_POST['original_post_status'] == 'pending') - ) - ) - ) - ) - { - $prazo_validacao = get_post_meta($postID, 'prazo_validacao', true); - $prazo_discussao = get_post_meta($postID, 'prazo_discussao', true); - $prazo_relatoria = get_post_meta($postID, 'prazo_relatoria', true); - $prazo_eleicao_relator = get_post_meta($postID, 'prazo_eleicao_relator', true); - $prazo_votacao = get_post_meta($postID, 'prazo_votacao', true); - $opt = delibera_get_config(); - - if(!array_key_exists('validacao', $opt) || $opt['validacao'] == 'S' ) - { - if(!$alterar) - { - - wp_set_object_terms($post->ID, 'validacao', 'situacao', false); - } - - delibera_criar_agenda( - $post->ID, - $prazo_validacao, - $prazo_discussao, - $prazo_votacao, - $opt['relatoria'] == 'S' ? $prazo_relatoria : false, - $opt['relatoria'] == 'S' && $opt['eleicao_relator'] == 'S' ? $prazo_eleicao_relator : false - ); - } - else - { - if(!$alterar) - { - wp_set_object_terms($post->ID, 'discussao', 'situacao', false); - } - delibera_criar_agenda( - $post->ID, - false, - $prazo_discussao, - $prazo_votacao, - $opt['relatoria'] == 'S' ? $prazo_relatoria : false, - $opt['relatoria'] == 'S' && $opt['eleicao_relator'] == 'S' ? $prazo_eleicao_relator : false - ); - } - - if($alterar) - { - //delibera_notificar_situacao($post); - } - else - { - delibera_notificar_nova_pauta($post); - } - } -} - -add_action ('publish_pauta', 'delibera_publish_pauta', 1, 2); - -function delibera_check_post_data($data, $postarr) -{ - $opt = delibera_get_config(); - $erros = array(); - $autosave = ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ); - if(get_post_type() == 'pauta' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'trash')) - { - if($opt['validacao'] == 'S') - { - $value = $_POST['prazo_validacao']; - $valida = delibera_tratar_data($value); - if(!$autosave && ($valida === false || $valida < 1)) - { - $erros[] = __("É necessário definir corretamente o prazo de validação", "delibera"); - } - } - $value = $_POST['prazo_discussao']; - $valida = delibera_tratar_data($value); - if(!$autosave && ($valida === false || $valida < 1)) - { - $erros[] = __("É necessário definir corretamente o prazo de discussão", "delibera"); - } - - if($opt['relatoria'] == 'S') - { - $value = $_POST['prazo_relatoria']; - $valida = delibera_tratar_data($value); - if(!$autosave && ($valida === false || $valida < 1)) - { - $erros[] = __("É necessário definir corretamente o prazo para relatoria", "Delibera"); - } - - if($opt['eleicao_relator'] == 'S') - { - $value = $_POST['prazo__leicao_relator']; - $valida = delibera_tratar_data($value); - if(!$autosave && ($valida === false || $valida < 1)) - { - $erros[] = __("É necessário definir corretamente o prazo para eleição de um relator", "delibera"); - } - } - - } - - $value = $_POST['prazo_votacao']; - $valida = delibera_tratar_data($value); - if(!$autosave && ($valida === false || $valida < 1)) - { - $erros[] = __("É necessário definir corretamente o prazo para votação", "delibera"); - } - - if($opt['validacao'] == 'S') - { - $value = (int)$_POST['min_validacoes']; - $valida = is_int($value) && $value > 0; - if(!$autosave && ($valida === false)) - { - $erros[] = __("É necessário definir corretamente o número mínimo de validações", "delibera"); - } - } - - if( - count($erros) == 0 - ) - { - return $data; - } - else - { - //wp_die(__('Erro ao salvar dados da pauta, faltando informações de prazos e validações mínimas!','delibera')); - wp_die(implode("
", $erros)); - } - } - return $data; -} - -add_filter('wp_insert_post_data', 'delibera_check_post_data', 10, 2); - -/** - * - * Retorna post do tipo pauta em uma determinada situacao (validacao, discussao, emvotacao ou comresolucao), usando um filtro - * @param array $filtro - * @param string $situacao - */ -function delibera_get_pautas_em($filtro = array(), $situacao = false) -{ - $filtro['post_type'] = "pauta"; - $filtro['post_status'] = "publish"; - $tax_query = array(); - - if(array_key_exists("tax_query", $filtro) && $situacao !== false) - { - $tax_query = $filtro['tax_query']; - $tax_query['relation'] = 'AND'; - } - if($situacao !== false) - { - $tax_query[] = array( - 'taxonomy' => 'situacao', - 'field' => 'slug', - 'terms' => $situacao - ); - $filtro['tax_query'] = $tax_query; - } - return get_posts($filtro); -} - -/** - * - * Retorna pautas em Validação - * @param array $filtro - */ -function delibera_get_propostas($filtro = array()) -{ - return delibera_get_pautas_em($filtro, 'validacao'); -} - -/** - * - * Retorna pautas em Discussão - * @param array $filtro - */ -function delibera_get_pautas($filtro = array()) -{ - return delibera_get_pautas_em($filtro, 'discussao'); -} - -function delibera_des_filtro_qtranslate($where) -{ - if(is_archive()) - { - global $q_config, $wpdb; - if($q_config['hide_untranslated'] && !is_singular()) { - $where = str_replace(" AND $wpdb->posts.post_content LIKE '%%'", '', $where); - } - } - return $where; -} - -add_filter('posts_where_request', 'delibera_des_filtro_qtranslate', 11); - -/** - * - * Retorna pautas em Votação - * @param array $filtro - */ -function delibera_get_emvotacao($filtro = array()) -{ - return delibera_get_pautas_em($filtro, 'emvotacao'); -} - -/** - * - * Retorna pautas já resolvidas - * @param array $filtro - */ -function delibera_get_resolucoes($filtro = array()) -{ - return delibera_get_pautas_em($filtro, 'comresolucao'); -} - - -/** - * Retorna um inteiro indicando quantos dias faltam para o fim do prazo - * de uma pauta. - * - * Se o parâmetro $data for passado por referência o prazo para o fim da - * pauta é associado a ele. - * - * @param int $postID - * @param string $data - * @return int - */ -function delibera_get_prazo($postID, &$data = null) -{ - $situacao = delibera_get_situacao($postID); - $prazo = ""; - $idata = strtotime(date('Y/m/d').' 23:59:59'); - $diff = -1; - - if(is_object($situacao)) - { - switch ($situacao->slug) - { - case 'validacao': - { - $prazo = get_post_meta($postID, 'prazo_validacao', true); - } break; - case 'discussao': - { - $prazo = get_post_meta($postID, 'prazo_discussao', true); - }break; - case 'elegerelator': - { - $prazo = get_post_meta($postID, 'prazo_eleicao_relator', true); - }break; - case 'relatoria': - { - $prazo = get_post_meta($postID, 'prazo_relatoria', true); - }break; - case 'emvotacao': - { - $prazo = get_post_meta($postID, 'prazo_votacao', true); - } break; - } - - $iprazo = strtotime(substr($prazo, 6).substr($prazo, 2, 4).substr($prazo, 0, 2).' 23:59:59'); - - $diff = $iprazo - $idata; - } - $dias = -1; - - if($diff >= 0) $dias = ceil($diff/(60*60*24)); - - if(!is_null($data)) $data = $prazo; - - return $dias; -} - -function delibera_edit_columns($columns) -{ - $columns[ 'tema' ] = __( 'Tema' ); - $columns[ 'situacao' ] = __( 'Situação' ); - $columns[ 'prazo' ] = __( 'Prazo' ); - return $columns; -} - -add_filter('manage_edit-pauta_columns', 'delibera_edit_columns'); - -function delibera_post_custom_column($column) -{ - global $post; - - switch ( $column ) - { - case 'tema': - echo the_terms($post->ID, "tema"); - break; - case 'situacao': - echo delibera_get_situacao($post->ID)->name; - break; - case 'prazo': - $data = ""; - $prazo = delibera_get_prazo($post->ID, $data); - if($prazo == -1) - { - echo __('Encerrado', 'delibera'); - } - elseif($data != "") - { - echo $data." (".$prazo.($prazo == 1 ? __(" dia", 'delibera') : __(" dias", 'delibera')).")"; - } - break; - } - -} - -add_action('manage_posts_custom_column', 'delibera_post_custom_column'); - - function delibera_restrict_listings() { global $typenow; @@ -1171,29 +201,6 @@ function delibera_convert_situacao_id_to_taxonomy_term_in_query(&$query) // gerar relatório em um arquivo xls require_once __DIR__ . DIRECTORY_SEPARATOR . 'delibera_relatorio.php'; -/** - * - * Pega os ultimos conteúdos - * @param string $tipo (option) 'pauta' ou 'comments', padrão 'pauta' - * @param array $args (option) query padrão do post ou do comments - * @param int $count (option) padrão 5 - */ -function delibera_ultimas($tipo = 'pauta', $args = array(), $count = 5) -{ - switch($tipo) - { - case 'pauta': - $filtro = array('orderby' => 'modified', 'order' => 'DESC', 'posts_per_page' => $count); - $filtro = array_merge($filtro, $args); - return delibera_get_pautas_em($filtro, false); - break; - case 'comments': - $filtro = array('orderby' => 'comment_date_gmt', 'order' => 'DESC', 'number' => $count, 'post_type' => 'pauta'); - $filtro = array_merge($filtro, $args); - return delibera_wp_get_comments($filtro); - break; - } -} function delibera_the_posts($posts) { @@ -1385,90 +392,6 @@ function delibera_emvotacao($post) } } -function delibera_novo_prazo($postID) -{ - $situacao = delibera_get_situacao($postID); - $opts = delibera_get_config(); - switch ($situacao->slug) - { - case 'validacao': - $inova_data = strtotime("+{$opts['dias_novo_prazo']} days"); - $nova_data = date("d/m/Y", $inova_data); - $inova_datad = strtotime("+{$opts['dias_discussao']} days",$inova_data); - $nova_datad = date("d/m/Y", $inova_datad); - $inova_datavt = strtotime("+{$opts['dias_votacao']} days",$inova_datad); - $nova_datavt = date("d/m/Y", $inova_datavt); - $inova_datarel = strtotime("+{$opts['dias_votacao_relator']} days",$inova_datavt); - $nova_datarel = date("d/m/Y", $inova_datarel); - $inova_datar = strtotime("+{$opts['dias_relatoria']} days",$inova_datarel); - $nova_datar = date("d/m/Y", $inova_datar); - - $events_meta['prazo_validacao'] = $opts['validacao'] == 'S' ? $nova_data : date('d/m/Y'); - $events_meta['prazo_discussao'] = $nova_datad; - $events_meta['prazo_relatoria'] = $opts['relatoria'] == 'S' ? $nova_datar : date('d/m/Y'); - $events_meta['prazo_eleicao_relator'] = $opts['relatoria'] == 'S' && $opts['eleicao_relator'] == 'S' ? $nova_datarel : date('d/m/Y'); - $events_meta['prazo_votacao'] = $nova_datavt; - - foreach ($events_meta as $key => $value) // Buscar dados - { - if(get_post_meta($postID, $key, true)) // Se já existe - { - update_post_meta($postID, $key, $value); // Atualiza - } - else - { - add_post_meta($postID, $key, $value, true); // Se não cria - } - } - delibera_del_cron($postID); - delibera_criar_agenda($postID, $nova_data, $nova_datad, $nova_datavt, $nova_datar, $nova_datarel); - break; - case 'discussao': - case 'relatoria': - $inova_data = strtotime("+{$opts['dias_novo_prazo']} days"); - delibera_set_novo_prazo_discussao_relatoria($postID, $inova_data, $opts); - break; - case 'emvotacao': - $inova_data = strtotime("+{$opts['dias_novo_prazo']} days"); - $nova_data = date("d/m/Y", $inova_data); - update_post_meta($postID, 'prazo_votacao', $nova_data); - delibera_del_cron($postID); - delibera_criar_agenda($postID, false, false, $nova_data); - break; - } - //delibera_notificar_situacao($postID); -} - -/** - * @param $postID - * @param $opts - */ -function delibera_set_novo_prazo_discussao_relatoria($postID, $inova_data, $opts) -{ - $nova_data = date("d/m/Y", $inova_data); - update_post_meta($postID, 'prazo_discussao', $nova_data); - $nova_eleicao_rel = false; - $nova_relatoria = false; - if ($opts['relatoria'] == "S") // Adiciona prazo de relatoria se for necessário - { - $opts['dias_votacao'] += $opts['dias_relatoria']; - if ($opts['eleicao_relator'] == "S") // Adiciona prazo de vatacao relator se for necessário - { - $opts['dias_votacao'] += $opts['dias_votacao_relator']; - $opts['dias_relatoria'] += $opts['dias_votacao_relator']; - $nova_eleicao_rel = date("d/m/Y", strtotime("+{$opts['dias_votacao_relator']} days", $inova_data)); - } - $nova_relatoria = date("d/m/Y", strtotime("+{$opts['dias_relatoria']} days", $inova_data)); - } - $inova_data_votacao = strtotime("+{$opts['dias_votacao']} days", $inova_data); - $nova_data_votacao = date("d/m/Y", $inova_data_votacao); - update_post_meta($postID, 'prazo_votacao', $nova_data_votacao); - delibera_del_cron($postID); - delibera_criar_agenda($postID, false, $nova_data, $nova_data_votacao, $nova_relatoria, $nova_eleicao_rel); -} - - - add_action('init', 'delibera_nova_pauta_create_action'); function delibera_nova_pauta_create_action(){ $opt = delibera_get_config(); diff --git a/delibera_admin_functions.php b/delibera_admin_functions.php index 7d71736..12a3bc9 100644 --- a/delibera_admin_functions.php +++ b/delibera_admin_functions.php @@ -142,4 +142,43 @@ function delibera_edit_comment($comment) } } -add_filter('add_meta_boxes_comment', 'delibera_edit_comment'); \ No newline at end of file +add_filter('add_meta_boxes_comment', 'delibera_edit_comment'); +function delibera_edit_columns($columns) +{ + $columns[ 'tema' ] = __( 'Tema' ); + $columns[ 'situacao' ] = __( 'Situação' ); + $columns[ 'prazo' ] = __( 'Prazo' ); + return $columns; +} + +add_filter('manage_edit-pauta_columns', 'delibera_edit_columns'); + +function delibera_post_custom_column($column) +{ + global $post; + + switch ( $column ) + { + case 'tema': + echo the_terms($post->ID, "tema"); + break; + case 'situacao': + echo delibera_get_situacao($post->ID)->name; + break; + case 'prazo': + $data = ""; + $prazo = delibera_get_prazo($post->ID, $data); + if($prazo == -1) + { + echo __('Encerrado', 'delibera'); + } + elseif($data != "") + { + echo $data." (".$prazo.($prazo == 1 ? __(" dia", 'delibera') : __(" dias", 'delibera')).")"; + } + break; + } + +} + +add_action('manage_posts_custom_column', 'delibera_post_custom_column'); \ No newline at end of file diff --git a/delibera_topic.php b/delibera_topic.php new file mode 100644 index 0000000..ac4e6d2 --- /dev/null +++ b/delibera_topic.php @@ -0,0 +1,585 @@ + 0) + { + $ret = array_pop($situacao); + } + + if(!is_object($ret)) // if term situacao does not exists + { + $ret = new stdClass(); + $ret->slug = ''; + $ret->name = ''; + } + + if(has_filter('delibera_get_situacao')) + { + return apply_filters('delibera_get_situacao', $ret); + } + + return $ret; +} + +/** + * Retorna o label do botão com a situação da + * pauta. + * + * @param int $postId + * @return string + */ +function delibera_get_situation_button($postId) +{ + $situacao = get_the_terms($postId, 'situacao'); + + if (is_array($situacao) && !empty($situacao)) { + $situacao = array_pop($situacao); + } + + switch($situacao->slug) { + case 'emvotacao': + return 'Votar'; + case 'discussao': + return 'Discutir'; + case 'validacao': + return 'Votar'; + default: + return; + } +} + +function delibera_update_edit_form() { + echo ' enctype="multipart/form-data"'; +} // end update_edit_form +add_action('post_edit_form_tag', 'delibera_update_edit_form'); + +function delibera_pauta_meta() +{ + global $post; + + $custom = get_post_custom($post->ID); + $options_plugin_delibera = delibera_get_config(); + + if(!is_array($custom)) $custom = array(); + $validacoes = array_key_exists("numero_validacoes", $custom) ? $custom["numero_validacoes"][0] : 0; + + $min_validacoes = array_key_exists("min_validacoes", $custom) ? $custom["min_validacoes"][0] : htmlentities($options_plugin_delibera['minimo_validacao']); + + $situacao = delibera_get_situacao($post->ID); + + $dias_validacao = intval(htmlentities($options_plugin_delibera['dias_validacao'])); + $dias_discussao = intval(htmlentities($options_plugin_delibera['dias_discussao'])); + $dias_relatoria = intval(htmlentities($options_plugin_delibera['dias_relatoria'])); + $dias_votacao_relator = intval(htmlentities($options_plugin_delibera['dias_votacao_relator'])); + + $pauta_pdf_file = get_post_meta($post->ID, 'pauta_pdf_contribution', true); + + // Recupera arquivo caso já tenha sido adicionados + $pdf_html = "

"; + if( $pauta_pdf_file ) { + $pdf_html .= "Arquivo Atual
"; + } + $pdf_html .= "

"; + echo $pdf_html; + + if($options_plugin_delibera['validacao'] == "S") // Adiciona prazo de validação se for necessário + { + $dias_discussao += $dias_validacao; + } + + $dias_votacao = $dias_discussao + intval(htmlentities($options_plugin_delibera['dias_votacao'])); + + if($options_plugin_delibera['relatoria'] == "S") // Adiciona prazo de relatoria se for necessário + { + $dias_votacao += $dias_relatoria; + $dias_relatoria += $dias_discussao; + if($options_plugin_delibera['eleicao_relator'] == "S") // Adiciona prazo de vatacao relator se for necessário + { + $dias_votacao += $dias_votacao_relator; + $dias_relatoria += $dias_votacao_relator; + $dias_votacao_relator += $dias_discussao; + } + } + + $now = strtotime(date('Y/m/d')." 11:59:59"); + + $prazo_validacao_sugerido = strtotime("+$dias_validacao days", $now); + $prazo_discussao_sugerido = strtotime("+$dias_discussao days", $now); + $prazo_eleicao_relator_sugerido = strtotime("+$dias_votacao_relator days", $now); + $prazo_relatoria_sugerido = strtotime("+$dias_relatoria days", $now); + $prazo_votacao_sugerido = strtotime("+$dias_votacao days", $now); + + $prazo_validacao = date('d/m/Y', $prazo_validacao_sugerido); + $prazo_discussao = date('d/m/Y', $prazo_discussao_sugerido); + $prazo_eleicao_relator = date('d/m/Y', $prazo_eleicao_relator_sugerido); + $prazo_relatoria = date('d/m/Y', $prazo_relatoria_sugerido); + $prazo_votacao = date('d/m/Y', $prazo_votacao_sugerido); + + if ( + $options_plugin_delibera['representante_define_prazos'] == "N" && + !($post->post_status == 'draft' || + $post->post_status == 'auto-draft' || + $post->post_status == 'pending') + ) + { + $disable_edicao = 'readonly="readonly"'; + } else { + $disable_edicao = ''; + } + + if(!($post->post_status == 'draft' || + $post->post_status == 'auto-draft' || + $post->post_status == 'pending')) + { + $prazo_validacao = array_key_exists("prazo_validacao", $custom) ? $custom["prazo_validacao"][0] : $prazo_validacao; + $prazo_discussao = array_key_exists("prazo_discussao", $custom) ? $custom["prazo_discussao"][0] : $prazo_discussao; + $prazo_eleicao_relator = array_key_exists("prazo_eleicao_relator", $custom) ? $custom["prazo_eleicao_relator"][0] : $prazo_eleicao_relator; + $prazo_relatoria = array_key_exists("prazo_relatoria", $custom) ? $custom["prazo_relatoria"][0] : $prazo_relatoria; + $prazo_votacao = array_key_exists("prazo_votacao", $custom) ? $custom["prazo_votacao"][0] : $prazo_votacao; + } + + if($options_plugin_delibera['validacao'] == "S") + { + ?> +

+ + id="min_validacoes" name="min_validacoes" class="min_validacoes widefat" value=""/> +

+

+ + id="prazo_validacao" name="prazo_validacao" class="prazo_validacao widefat hasdatepicker" value=""/> +

+ +

+ + id="prazo_discussao" name="prazo_discussao" class="prazo_discussao widefat hasdatepicker" value=""/> +

+ +

+ + id="prazo_eleicao_relator" name="prazo_eleicao_relator" class="prazo_eleicao_relator widefat hasdatepicker" value=""/> +

+ +

+ + id="prazo_relatoria" name="prazo_relatoria" class="prazo_relatoria widefat hasdatepicker" value=""/> +

+ +

+ + id="prazo_votacao" name="prazo_votacao" class="prazo_votacao widefat hasdatepicker" value=""/> +

+ post_status == 'publish' || $_POST['publish'] == 'Publicar') && + ( + ( + array_key_exists('prev_status', $_POST) && + ( + $_POST['prev_status'] == 'draft' || + $_POST['prev_status'] == 'pending' + ) + ) || + ( + array_key_exists('original_post_status', $_POST) && ( + $_POST['original_post_status'] == 'draft' || + $_POST['original_post_status'] == 'auto-draft' || + $_POST['original_post_status'] == 'pending') + ) + ) + ) + ) + { + $prazo_validacao = get_post_meta($postID, 'prazo_validacao', true); + $prazo_discussao = get_post_meta($postID, 'prazo_discussao', true); + $prazo_relatoria = get_post_meta($postID, 'prazo_relatoria', true); + $prazo_eleicao_relator = get_post_meta($postID, 'prazo_eleicao_relator', true); + $prazo_votacao = get_post_meta($postID, 'prazo_votacao', true); + $opt = delibera_get_config(); + + if(!array_key_exists('validacao', $opt) || $opt['validacao'] == 'S' ) + { + if(!$alterar) + { + + wp_set_object_terms($post->ID, 'validacao', 'situacao', false); + } + + delibera_criar_agenda( + $post->ID, + $prazo_validacao, + $prazo_discussao, + $prazo_votacao, + $opt['relatoria'] == 'S' ? $prazo_relatoria : false, + $opt['relatoria'] == 'S' && $opt['eleicao_relator'] == 'S' ? $prazo_eleicao_relator : false + ); + } + else + { + if(!$alterar) + { + wp_set_object_terms($post->ID, 'discussao', 'situacao', false); + } + delibera_criar_agenda( + $post->ID, + false, + $prazo_discussao, + $prazo_votacao, + $opt['relatoria'] == 'S' ? $prazo_relatoria : false, + $opt['relatoria'] == 'S' && $opt['eleicao_relator'] == 'S' ? $prazo_eleicao_relator : false + ); + } + + if($alterar) + { + //delibera_notificar_situacao($post); + } + else + { + delibera_notificar_nova_pauta($post); + } + } +} + +add_action ('publish_pauta', 'delibera_publish_pauta', 1, 2); + +function delibera_check_post_data($data, $postarr) +{ + $opt = delibera_get_config(); + $erros = array(); + $autosave = ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ); + if(get_post_type() == 'pauta' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'trash')) + { + if($opt['validacao'] == 'S') + { + $value = $_POST['prazo_validacao']; + $valida = delibera_tratar_data($value); + if(!$autosave && ($valida === false || $valida < 1)) + { + $erros[] = __("É necessário definir corretamente o prazo de validação", "delibera"); + } + } + $value = $_POST['prazo_discussao']; + $valida = delibera_tratar_data($value); + if(!$autosave && ($valida === false || $valida < 1)) + { + $erros[] = __("É necessário definir corretamente o prazo de discussão", "delibera"); + } + + if($opt['relatoria'] == 'S') + { + $value = $_POST['prazo_relatoria']; + $valida = delibera_tratar_data($value); + if(!$autosave && ($valida === false || $valida < 1)) + { + $erros[] = __("É necessário definir corretamente o prazo para relatoria", "Delibera"); + } + + if($opt['eleicao_relator'] == 'S') + { + $value = $_POST['prazo__leicao_relator']; + $valida = delibera_tratar_data($value); + if(!$autosave && ($valida === false || $valida < 1)) + { + $erros[] = __("É necessário definir corretamente o prazo para eleição de um relator", "delibera"); + } + } + + } + + $value = $_POST['prazo_votacao']; + $valida = delibera_tratar_data($value); + if(!$autosave && ($valida === false || $valida < 1)) + { + $erros[] = __("É necessário definir corretamente o prazo para votação", "delibera"); + } + + if($opt['validacao'] == 'S') + { + $value = (int)$_POST['min_validacoes']; + $valida = is_int($value) && $value > 0; + if(!$autosave && ($valida === false)) + { + $erros[] = __("É necessário definir corretamente o número mínimo de validações", "delibera"); + } + } + + if( + count($erros) == 0 + ) + { + return $data; + } + else + { + //wp_die(__('Erro ao salvar dados da pauta, faltando informações de prazos e validações mínimas!','delibera')); + wp_die(implode("
", $erros)); + } + } + return $data; +} + +add_filter('wp_insert_post_data', 'delibera_check_post_data', 10, 2); + +/** + * + * Retorna post do tipo pauta em uma determinada situacao (validacao, discussao, emvotacao ou comresolucao), usando um filtro + * @param array $filtro + * @param string $situacao + */ +function delibera_get_pautas_em($filtro = array(), $situacao = false) +{ + $filtro['post_type'] = "pauta"; + $filtro['post_status'] = "publish"; + $tax_query = array(); + + if(array_key_exists("tax_query", $filtro) && $situacao !== false) + { + $tax_query = $filtro['tax_query']; + $tax_query['relation'] = 'AND'; + } + if($situacao !== false) + { + $tax_query[] = array( + 'taxonomy' => 'situacao', + 'field' => 'slug', + 'terms' => $situacao + ); + $filtro['tax_query'] = $tax_query; + } + return get_posts($filtro); +} + +/** + * + * Retorna pautas em Validação + * @param array $filtro + */ +function delibera_get_propostas($filtro = array()) +{ + return delibera_get_pautas_em($filtro, 'validacao'); +} + +/** + * + * Retorna pautas em Discussão + * @param array $filtro + */ +function delibera_get_pautas($filtro = array()) +{ + return delibera_get_pautas_em($filtro, 'discussao'); +} + +function delibera_des_filtro_qtranslate($where) +{ + if(is_archive()) + { + global $q_config, $wpdb; + if($q_config['hide_untranslated'] && !is_singular()) { + $where = str_replace(" AND $wpdb->posts.post_content LIKE '%%'", '', $where); + } + } + return $where; +} + +add_filter('posts_where_request', 'delibera_des_filtro_qtranslate', 11); + +/** + * + * Retorna pautas em Votação + * @param array $filtro + */ +function delibera_get_emvotacao($filtro = array()) +{ + return delibera_get_pautas_em($filtro, 'emvotacao'); +} + +/** + * + * Retorna pautas já resolvidas + * @param array $filtro + */ +function delibera_get_resolucoes($filtro = array()) +{ + return delibera_get_pautas_em($filtro, 'comresolucao'); +} + +/** + * + * Save o post da pauta + * @param $post_id int + * @param $post + */ +function delibera_save_post($post_id, $post) +{ + if(get_post_type( $post_id ) != "pauta") + { + return $post_id; + } + $opt = delibera_get_config(); + $autosave = ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ); + + if( + ( // Se tem validação, tem que ter o prazo + $opt['validacao'] == 'N' || + (array_key_exists('prazo_validacao', $_POST) && array_key_exists('min_validacoes', $_POST) ) + ) && + ( // Se tem relatoria, tem que ter o prazo + $opt['relatoria'] == 'N' || + array_key_exists('prazo_relatoria', $_POST) + ) && + ( // Se tem relatoria, e é preciso eleger o relator, tem que ter o prazo para eleição + $opt['relatoria'] == 'N' || + ( + $opt['eleicao_relator'] == 'N' || + array_key_exists('prazo_eleicao_relator', $_POST) + ) + ) && + array_key_exists('prazo_discussao', $_POST) && + array_key_exists('prazo_votacao', $_POST) + ) + { + $events_meta = array(); + + $validacoes = get_post_meta($post_id, 'numero_validacoes', true); + if($validacoes == "" || $validacoes === false || is_null($validacoes)) + { + $events_meta['numero_validacoes'] = 0; + $events_meta['delibera_numero_comments_validacoes'] = 0; + $events_meta['delibera_numero_comments_encaminhamentos'] = 0; + $events_meta['delibera_numero_comments_discussoes'] = 0; + $events_meta['delibera_numero_comments_votos'] = 0; + $events_meta['delibera_numero_comments_padroes'] = 0; + $events_meta['delibera_numero_curtir'] = 0; + $events_meta['delibera_curtiram'] = array(); + $events_meta['delibera_numero_discordar'] = 0; + $events_meta['delibera_discordaram'] = array(); + $events_meta['delibera_numero_seguir'] = 0; + $events_meta['delibera_seguiram'] = array(); + } + + $events_meta['prazo_validacao'] = $opt['validacao'] == 'S' ? $_POST['prazo_validacao'] : date('d/m/Y'); + $events_meta['prazo_discussao'] = $_POST['prazo_discussao']; + $events_meta['prazo_relatoria'] = $opt['relatoria'] == 'S' ? $_POST['prazo_relatoria'] : date('d/m/Y'); + $events_meta['prazo_eleicao_relator'] = $opt['relatoria'] == 'S' && $opt['eleicao_relator'] == 'S' ? $_POST['prazo_eleicao_relator'] : date('d/m/Y'); + $events_meta['prazo_votacao'] = $_POST['prazo_votacao']; + $events_meta['min_validacoes'] = $opt['validacao'] == 'S' ? $_POST['min_validacoes'] : 10; + + /* ######### START ######### */ + /* ######### FOR PDF UPLOAD FILE ######### */ + // Setup the array of supported file types. In this case, it's just PDF. + $supported_types = array('application/pdf'); + + // Get the file type of the upload + $arr_uploaded_file_type = wp_check_filetype(basename($_FILES['pauta_pdf_contribution']['name'])); + $uploaded_file_type = $arr_uploaded_file_type['type']; + + if (isset ($_FILES['pauta_pdf_contribution']['name']) && $_FILES['pauta_pdf_contribution']['name'] != '') { + if (!in_array($uploaded_file_type, $supported_types)) { + //TODO: Improve this message and avoid wp_die + wp_die("O arquivo para web não é um PDF (formato permitido)."); + } + + + // Use the WordPress API to upload the file + $upload_pauta_pdf = wp_upload_bits($_FILES['pauta_pdf_contribution']['name'], null, file_get_contents($_FILES['pauta_pdf_contribution']['tmp_name'])); + + if (isset($upload_pauta_pdf['error']) && $upload_pauta_pdf['error'] != 0) { + $events_meta['pauta_pdf_contribution'] = none; + wp_die('Erro ao salvar arquivo para Web. O erro foi: ' . $upload_pauta_pdf['error']); + } else { + $events_meta['pauta_pdf_contribution'] = $upload_pauta_pdf['url']; + + global $wpdb; + + $wpdb->query($wpdb->prepare("UPDATE " . $wpdb->prefix . "posts SET post_content=%s WHERE ID=%d", '', $post->ID)); + } + } + /* ######### FOR PDF UPLOAD FILE ######### */ + /* ######### END ######### */ + + foreach ($events_meta as $key => $value) // Buscar dados + { + if(get_post_meta($post->ID, $key, true)) // Se já existe + { + update_post_meta($post->ID, $key, $value); // Atualiza + } + else + { + add_post_meta($post->ID, $key, $value, true); // Senão, cria + } + } + + if( + array_key_exists('delibera_fim_prazo', $_POST) && + $_POST['delibera_fim_prazo'] == 'S' && + current_user_can('forcar_prazo') + ) + { + delibera_forca_fim_prazo($post->ID); + } + + if($post->post_status == 'publish' && !$autosave) + { + delibera_del_cron($post->ID); + delibera_publish_pauta($post->ID, $post, true); + } + + } + +} + +add_action ('save_post', 'delibera_save_post', 1, 2); \ No newline at end of file diff --git a/delibera_topic_deadline.php b/delibera_topic_deadline.php new file mode 100644 index 0000000..c21d7ca --- /dev/null +++ b/delibera_topic_deadline.php @@ -0,0 +1,441 @@ +slug) + { + case 'discussao': + delibera_tratar_prazo_discussao(array( + 'post_ID' => $postID, + 'prazo_discussao' => date('d/m/Y') + )); + break; + case 'relatoria': + delibera_tratar_prazo_relatoria(array( + 'post_ID' => $postID, + 'prazo_relatoria' => date('d/m/Y') + )); + break; + case 'emvotacao': + delibera_computa_votos($postID); + break; + } + //delibera_notificar_situacao($postID); +} + + +function delibera_forca_fim_prazo_action() +{ + if(current_user_can('forcar_prazo') && check_admin_referer('delibera_forca_fim_prazo_action'.$_REQUEST['post'], '_wpnonce')) + { + delibera_forca_fim_prazo($_REQUEST['post']); + + wp_redirect( admin_url( 'edit.php?post_type=pauta') ); + } + else + { + wp_die(__('Você não tem permissão para forçar um prazo','delibera'), __('Sem permissão','delibera')); + } +} +add_action('admin_action_delibera_forca_fim_prazo_action', 'delibera_forca_fim_prazo_action'); + +function delibera_nao_validado_action() +{ + if(current_user_can('forcar_prazo') && check_admin_referer('delibera_nao_validado_action'.$_REQUEST['post'], '_wpnonce')) + { + delibera_marcar_naovalidada($_REQUEST['post']); + + wp_redirect( admin_url( 'edit.php?post_type=pauta') ); + } + else + { + wp_die(__('Você não tem permissão para invalidar uma pauta','delibera'), __('Sem permissão','delibera')); + } +} +add_action('admin_action_delibera_nao_validado_action', 'delibera_nao_validado_action'); + +function delibera_reabrir_pauta_action() +{ + if(current_user_can('delibera_reabrir_pauta') && check_admin_referer('delibera_reabrir_pauta_action'.$_REQUEST['post'], '_wpnonce')) + { + delibera_reabrir_pauta($_REQUEST['post']); + + wp_redirect( admin_url( 'edit.php?post_type=pauta') ); + } + else + { + wp_die(__('Você não tem permissão para re-abrir discussão sobre uma pauta','delibera'), __('Sem permissão','delibera')); + } +} +add_action('admin_action_delibera_reabrir_pauta_action', 'delibera_reabrir_pauta_action'); + +require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_cron.php'; + + +/** + * + * Faz agendamento das datas para seguir passos + * 1) Excluir ao atingir data de validação se não foi validade + * 2) Iniciar votação se tiver encaminhamento, ou novo prazo, caso contrário + * 3) Fim da votação + * @param $prazo_validacao + * @param $prazo_discussao + * @param $prazo_votacao + */ +function delibera_criar_agenda($postID, $prazo_validacao, $prazo_discussao, $prazo_votacao, $prazo_relatoria = false, $prazo_eleicao_relator = false) +{ + + if($prazo_validacao !== false) + { + delibera_add_cron( + delibera_tratar_data($prazo_validacao), + 'delibera_tratar_prazo_validacao', + array( + 'post_ID' => $postID, + 'prazo_validacao' => $prazo_validacao + ) + ); + delibera_add_cron( + strtotime("-1 day", delibera_tratar_data($prazo_validacao)), + 'delibera_notificar_fim_prazo', + array( + 'post_ID' => $postID, + 'prazo_validacao' => $prazo_validacao + ) + ); + } + + if($prazo_discussao !== false) + { + delibera_add_cron( + delibera_tratar_data($prazo_discussao), + 'delibera_tratar_prazo_discussao', + array( + 'post_ID' => $postID, + 'prazo_discussao' => $prazo_discussao + ) + ); + delibera_add_cron( + strtotime("-1 day", delibera_tratar_data($prazo_discussao)), + 'delibera_notificar_fim_prazo', + array( + 'post_ID' => $postID, + 'prazo_discussao' => $prazo_discussao + ) + ); + } + + if($prazo_eleicao_relator != false) + { + delibera_add_cron( + delibera_tratar_data($prazo_eleicao_relator), + 'delibera_tratar_prazo_eleicao_relator', + array( + 'post_ID' => $postID, + 'prazo_votacao' => $prazo_eleicao_relator + ) + ); + delibera_add_cron( + strtotime("-1 day", delibera_tratar_data($prazo_eleicao_relator)), + 'delibera_notificar_fim_prazo', + array( + 'post_ID' => $postID, + 'prazo_votacao' => $prazo_eleicao_relator + ) + ); + } + + if($prazo_relatoria != false) + { + delibera_add_cron( + delibera_tratar_data($prazo_relatoria), + 'delibera_tratar_prazo_relatoria', + array( + 'post_ID' => $postID, + 'prazo_votacao' => $prazo_relatoria + ) + ); + delibera_add_cron( + strtotime("-1 day", delibera_tratar_data($prazo_relatoria)), + 'delibera_notificar_fim_prazo', + array( + 'post_ID' => $postID, + 'prazo_votacao' => $prazo_relatoria + ) + ); + } + + if($prazo_votacao != false) + { + delibera_add_cron( + delibera_tratar_data($prazo_votacao), + 'delibera_tratar_prazo_votacao', + array( + 'post_ID' => $postID, + 'prazo_votacao' => $prazo_votacao + ) + ); + delibera_add_cron( + strtotime("-1 day", delibera_tratar_data($prazo_votacao)), + 'delibera_notificar_fim_prazo', + array( + 'post_ID' => $postID, + 'prazo_votacao' => $prazo_votacao + ) + ); + } +} + +function delibera_tratar_prazos($args) +{ + $situacao = delibera_get_situacao($args['post_ID']); + switch ($situacao->slug) + { + case 'validacao': + delibera_tratar_prazo_validacao($args); + break; + case 'discussao': + delibera_tratar_prazo_discussao($args); + break; + case 'relatoria': + delibera_tratar_prazo_relatoria($args); + break; + case 'emvotacao': + delibera_tratar_prazo_votacao($args); + break; + } +} + +add_action('delibera_tratar_prazos', 'delibera_tratar_prazos', 1, 1); + +function delibera_tratar_prazo_validacao($args) +{ + $situacao = delibera_get_situacao($args['post_ID']); + if($situacao->slug == 'validacao') + { + delibera_marcar_naovalidada($args['post_ID']); + } +} + +function delibera_tratar_prazo_discussao($args) +{ + $situacao = delibera_get_situacao($args['post_ID']); + if($situacao->slug == 'discussao') + { + $post_id = $args['post_ID']; + if(count(delibera_get_comments_encaminhamentos($post_id)) > 0) + { + $opts = delibera_get_config(); + if($opts['eleicao_relator'] == 'S') + { + wp_set_object_terms($post_id, 'eleicaoredator', 'situacao', false); //Mudar situação para Votação + } + elseif($opts['relatoria'] == 'S') + { + wp_set_object_terms($post_id, 'relatoria', 'situacao', false); //Mudar situação para Votação + } + else + { + wp_set_object_terms($post_id, 'emvotacao', 'situacao', false); //Mudar situação para Votação + } + if(has_action('delibera_discussao_concluida')) + { + do_action('delibera_discussao_concluida', $post_id); + } + } + else + { + delibera_novo_prazo($post_id); + } + } +} + +function delibera_tratar_prazo_relatoria($args) +{ + $situacao = delibera_get_situacao($args['post_ID']); + if($situacao->slug == 'relatoria') + { + $post_id = $args['post_ID']; + if(count(delibera_get_comments_encaminhamentos($post_id)) > 0) + { + wp_set_object_terms($post_id, 'emvotacao', 'situacao', false); //Mudar situação para Votação + //delibera_notificar_situacao($post_id); + if(has_action('delibera_relatoria_concluida')) + { + do_action('delibera_relatoria_concluida', $post_id); + } + } + else + { + delibera_novo_prazo($post_id); + } + } +} + +function delibera_tratar_prazo_votacao($args) +{ + $situacao = delibera_get_situacao($args['post_ID']); + if($situacao->slug == 'emvotacao') + { + delibera_computa_votos($args['post_ID']); + } +} + +function delibera_marcar_naovalidada($postID) +{ + wp_set_object_terms($postID, 'naovalidada', 'situacao', false); + if(has_action('delibera_pauta_recusada')) + { + do_action('delibera_pauta_recusada', $postID); + } +} + +function delibera_reabrir_pauta($postID) +{ + wp_set_object_terms($postID, 'validacao', 'situacao', false); + //delibera_notificar_situacao($postID); + + delibera_novo_prazo($postID); +} + + +function delibera_novo_prazo($postID) +{ + $situacao = delibera_get_situacao($postID); + $opts = delibera_get_config(); + switch ($situacao->slug) + { + case 'validacao': + $inova_data = strtotime("+{$opts['dias_novo_prazo']} days"); + $nova_data = date("d/m/Y", $inova_data); + $inova_datad = strtotime("+{$opts['dias_discussao']} days",$inova_data); + $nova_datad = date("d/m/Y", $inova_datad); + $inova_datavt = strtotime("+{$opts['dias_votacao']} days",$inova_datad); + $nova_datavt = date("d/m/Y", $inova_datavt); + $inova_datarel = strtotime("+{$opts['dias_votacao_relator']} days",$inova_datavt); + $nova_datarel = date("d/m/Y", $inova_datarel); + $inova_datar = strtotime("+{$opts['dias_relatoria']} days",$inova_datarel); + $nova_datar = date("d/m/Y", $inova_datar); + + $events_meta['prazo_validacao'] = $opts['validacao'] == 'S' ? $nova_data : date('d/m/Y'); + $events_meta['prazo_discussao'] = $nova_datad; + $events_meta['prazo_relatoria'] = $opts['relatoria'] == 'S' ? $nova_datar : date('d/m/Y'); + $events_meta['prazo_eleicao_relator'] = $opts['relatoria'] == 'S' && $opts['eleicao_relator'] == 'S' ? $nova_datarel : date('d/m/Y'); + $events_meta['prazo_votacao'] = $nova_datavt; + + foreach ($events_meta as $key => $value) // Buscar dados + { + if(get_post_meta($postID, $key, true)) // Se já existe + { + update_post_meta($postID, $key, $value); // Atualiza + } + else + { + add_post_meta($postID, $key, $value, true); // Se não cria + } + } + delibera_del_cron($postID); + delibera_criar_agenda($postID, $nova_data, $nova_datad, $nova_datavt, $nova_datar, $nova_datarel); + break; + case 'discussao': + case 'relatoria': + $inova_data = strtotime("+{$opts['dias_novo_prazo']} days"); + delibera_set_novo_prazo_discussao_relatoria($postID, $inova_data, $opts); + break; + case 'emvotacao': + $inova_data = strtotime("+{$opts['dias_novo_prazo']} days"); + $nova_data = date("d/m/Y", $inova_data); + update_post_meta($postID, 'prazo_votacao', $nova_data); + delibera_del_cron($postID); + delibera_criar_agenda($postID, false, false, $nova_data); + break; + } + //delibera_notificar_situacao($postID); +} + +/** + * @param $postID + * @param $opts + */ +function delibera_set_novo_prazo_discussao_relatoria($postID, $inova_data, $opts) +{ + $nova_data = date("d/m/Y", $inova_data); + update_post_meta($postID, 'prazo_discussao', $nova_data); + $nova_eleicao_rel = false; + $nova_relatoria = false; + if ($opts['relatoria'] == "S") // Adiciona prazo de relatoria se for necessário + { + $opts['dias_votacao'] += $opts['dias_relatoria']; + if ($opts['eleicao_relator'] == "S") // Adiciona prazo de vatacao relator se for necessário + { + $opts['dias_votacao'] += $opts['dias_votacao_relator']; + $opts['dias_relatoria'] += $opts['dias_votacao_relator']; + $nova_eleicao_rel = date("d/m/Y", strtotime("+{$opts['dias_votacao_relator']} days", $inova_data)); + } + $nova_relatoria = date("d/m/Y", strtotime("+{$opts['dias_relatoria']} days", $inova_data)); + } + $inova_data_votacao = strtotime("+{$opts['dias_votacao']} days", $inova_data); + $nova_data_votacao = date("d/m/Y", $inova_data_votacao); + update_post_meta($postID, 'prazo_votacao', $nova_data_votacao); + delibera_del_cron($postID); + delibera_criar_agenda($postID, false, $nova_data, $nova_data_votacao, $nova_relatoria, $nova_eleicao_rel); +} + +/** + * Retorna um inteiro indicando quantos dias faltam para o fim do prazo + * de uma pauta. + * + * Se o parâmetro $data for passado por referência o prazo para o fim da + * pauta é associado a ele. + * + * @param int $postID + * @param string $data + * @return int + */ +function delibera_get_prazo($postID, &$data = null) +{ + $situacao = delibera_get_situacao($postID); + $prazo = ""; + $idata = strtotime(date('Y/m/d').' 23:59:59'); + $diff = -1; + + if(is_object($situacao)) + { + switch ($situacao->slug) + { + case 'validacao': + { + $prazo = get_post_meta($postID, 'prazo_validacao', true); + } break; + case 'discussao': + { + $prazo = get_post_meta($postID, 'prazo_discussao', true); + }break; + case 'elegerelator': + { + $prazo = get_post_meta($postID, 'prazo_eleicao_relator', true); + }break; + case 'relatoria': + { + $prazo = get_post_meta($postID, 'prazo_relatoria', true); + }break; + case 'emvotacao': + { + $prazo = get_post_meta($postID, 'prazo_votacao', true); + } break; + } + + $iprazo = strtotime(substr($prazo, 6).substr($prazo, 2, 4).substr($prazo, 0, 2).' 23:59:59'); + + $diff = $iprazo - $idata; + } + $dias = -1; + + if($diff >= 0) $dias = ceil($diff/(60*60*24)); + + if(!is_null($data)) $data = $prazo; + + return $dias; +} \ No newline at end of file diff --git a/delibera_utils.php b/delibera_utils.php index b8e8c83..ec9dae4 100644 --- a/delibera_utils.php +++ b/delibera_utils.php @@ -161,4 +161,28 @@ function delibera_form_table($rows) { } $content .= ''; return $content; +} + +/** + * + * Pega os ultimos conteúdos + * @param string $tipo (option) 'pauta' ou 'comments', padrão 'pauta' + * @param array $args (option) query padrão do post ou do comments + * @param int $count (option) padrão 5 + */ +function delibera_ultimas($tipo = 'pauta', $args = array(), $count = 5) +{ + switch($tipo) + { + case 'pauta': + $filtro = array('orderby' => 'modified', 'order' => 'DESC', 'posts_per_page' => $count); + $filtro = array_merge($filtro, $args); + return delibera_get_pautas_em($filtro, false); + break; + case 'comments': + $filtro = array('orderby' => 'comment_date_gmt', 'order' => 'DESC', 'number' => $count, 'post_type' => 'pauta'); + $filtro = array_merge($filtro, $args); + return delibera_wp_get_comments($filtro); + break; + } } \ No newline at end of file From d6a9f3e88380b8b0cbb8c5c75d98a049fc47638a Mon Sep 17 00:00:00 2001 From: Lucas Pirola Date: Tue, 19 Jan 2016 11:19:15 -0200 Subject: [PATCH 015/435] =?UTF-8?q?corrige=20bug=20ao=20votar=20e=20o=20en?= =?UTF-8?q?caminhamento=20ainda=20n=C3=A3o=20recebeu=20nenhum=20voto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- delibera.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/delibera.php b/delibera.php index 0408c8d..d25959b 100644 --- a/delibera.php +++ b/delibera.php @@ -340,7 +340,12 @@ function delibera_computa_votos($postID, $votos = null) $voto = get_comment_meta($voto_comment->comment_ID, 'delibera_votos', true); foreach ($voto as $voto_para) { - $encaminhamentos_votos[$voto_para]++; + if (isset($encaminhamentos_votos[$voto_para])) + { + $encaminhamentos_votos[$voto_para]++; + } else { + $encaminhamentos_votos[$voto_para] = 1; + } } } $maisvotado = array(-1, -1); From f3e809ae234ff61ca57b2067a962b06d29def78f Mon Sep 17 00:00:00 2001 From: Lucas Pirola Date: Tue, 19 Jan 2016 12:18:19 -0200 Subject: [PATCH 016/435] =?UTF-8?q?Finaliza=20organiza=C3=A7=C3=A3o=20do?= =?UTF-8?q?=20plugin=20em=20v=C3=A1rios=20arquivos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- delibera.php | 525 +++------------------------------ delibera_admin_functions.php | 55 +++- delibera_comments.php | 150 +++++++++- delibera_init.php | 52 +++- delibera_topic.php | 150 +++++++++- timeline/delibera_timeline.php | 37 ++- 6 files changed, 462 insertions(+), 507 deletions(-) diff --git a/delibera.php b/delibera.php index d25959b..7c7ee7f 100644 --- a/delibera.php +++ b/delibera.php @@ -20,8 +20,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -// Defines - if(!defined('__DIR__')) { $iPos = strrpos(__FILE__, DIRECTORY_SEPARATOR); define("__DIR__", substr(__FILE__, 0, $iPos) . DIRECTORY_SEPARATOR); @@ -29,509 +27,75 @@ define('DELIBERA_ABOUT_PAGE', __('sobre-a-plataforma', 'delibera')); -// End Defines - -// Parse shorttag +require_once __DIR__ . DIRECTORY_SEPARATOR . 'delibera_shortcodes.php'; -require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_shortcodes.php'; +require_once __DIR__ . DIRECTORY_SEPARATOR . 'delibera_widgets.php'; -// End Parse shorttag +require_once __DIR__ . DIRECTORY_SEPARATOR . 'delibera_rewrite_rules.php'; -// Parse widgets +require_once __DIR__ . DIRECTORY_SEPARATOR . 'delibera_conf.php'; -require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_widgets.php'; +require_once __DIR__ . DIRECTORY_SEPARATOR . 'delibera_conf_roles.php'; -// End Parse widgets +require_once __DIR__ . DIRECTORY_SEPARATOR . 'delibera_conf_themes.php'; -// Parse rewrite-rules +require_once __DIR__ . DIRECTORY_SEPARATOR . 'print' . DIRECTORY_SEPARATOR . 'wp-print.php'; -require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_rewrite_rules.php'; +require_once __DIR__ . DIRECTORY_SEPARATOR . 'delibera_admin_functions.php'; -// End Parse rewrite-rules +require_once __DIR__ . DIRECTORY_SEPARATOR . 'delibera_setup.php'; -// pagina de configuracao do plugin -require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_conf.php'; +require_once __DIR__ . DIRECTORY_SEPARATOR . 'delibera_init.php'; -// Inicialização do plugin +require_once __DIR__ . DIRECTORY_SEPARATOR . 'delibera_utils.php'; -require_once __DIR__.'/print/wp-print.php'; +require_once __DIR__ . DIRECTORY_SEPARATOR . 'delibera_comments.php'; -require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_admin_functions.php'; +require_once __DIR__ . DIRECTORY_SEPARATOR . 'delibera_comments_query.php'; -// setup plugin -require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_setup.php'; +require_once __DIR__ . DIRECTORY_SEPARATOR . 'delibera_comments_template.php'; -require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_init.php'; +require_once __DIR__ . DIRECTORY_SEPARATOR . 'delibera_comments_edit.php'; -require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_utils.php'; +require_once __DIR__ . DIRECTORY_SEPARATOR . 'delibera_cron.php'; -require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_comments.php'; +require_once __DIR__ . DIRECTORY_SEPARATOR . 'delibera_topic.php'; +require_once __DIR__ . DIRECTORY_SEPARATOR . 'delibera_topic_deadline.php'; -/** - * - * Insere term no banco e atualizar línguas do qtranslate - * @param string $label - * @param string $tax Taxonomy - * @param array $term EX: array('description'=> __('Español'),'slug' => 'espanol', 'slug' => 'espanol') - * @param array $idiomas EX: array('qtrans_term_en' => 'United States of America', 'qtrans_term_pt' => 'Estados Unidos da América', 'qtrans_term_es' => 'Estados Unidos de América' - */ -function delibera_insert_term($label, $tax, $term, $idiomas = array()) +if (file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'delibera_filtros.php')) { - if(term_exists($term['slug'], $tax, null) == false) - { - wp_insert_term($label, $tax, $term); - global $q_config; - if(count($idiomas) > 0 && function_exists('qtrans_stripSlashesIfNecessary')) - { - if(isset($idiomas['qtrans_term_'.$q_config['default_language']]) && $idiomas['qtrans_term_'.$q_config['default_language']]!='') - { - $default = htmlspecialchars(qtrans_stripSlashesIfNecessary($idiomas['qtrans_term_'.$q_config['default_language']]), ENT_NOQUOTES); - if(!isset($q_config['term_name'][$default]) || !is_array($q_config['term_name'][$default])) $q_config['term_name'][$default] = array(); - foreach($q_config['enabled_languages'] as $lang) { - $idiomas['qtrans_term_'.$lang] = qtrans_stripSlashesIfNecessary($idiomas['qtrans_term_'.$lang]); - if($idiomas['qtrans_term_'.$lang]!='') { - $q_config['term_name'][$default][$lang] = htmlspecialchars($idiomas['qtrans_term_'.$lang], ENT_NOQUOTES); - } else { - $q_config['term_name'][$default][$lang] = $default; - } - } - update_option('qtranslate_term_name',$q_config['term_name']); - } - } - } -} - - - -function delibera_admin_list_options($actions, $post) -{ - if(get_post_type($post) == 'pauta' && $post->post_status == 'publish' ) - { - if(current_user_can('forcar_prazo')) - { - $url = 'admin.php?action=delibera_forca_fim_prazo_action&post='.$post->ID; - $url = wp_nonce_url($url, 'delibera_forca_fim_prazo_action'.$post->ID); - $actions['forcar_prazo'] = ''.__('Forçar fim de prazo','delibera').''; - - $url = 'admin.php?action=delibera_nao_validado_action&post='.$post->ID; - $url = wp_nonce_url($url, 'delibera_nao_validado_action'.$post->ID); - $actions['nao_validado'] = ''.__('Invalidar','delibera').''; - - } - if(delibera_get_situacao($post->ID)->slug == 'naovalidada' && current_user_can('delibera_reabrir_pauta')) - { - $url = 'admin.php?action=delibera_reabrir_pauta_action&post='.$post->ID; - $url = wp_nonce_url($url, 'delibera_reabrir_pauta_action'.$post->ID); - $actions['reabrir'] = ''.__('Reabrir','delibera').''; - } - - } - - //print_r(_get_cron_array()); - return $actions; + require_once __DIR__ . DIRECTORY_SEPARATOR . 'delibera_filtros.php'; } -add_filter('post_row_actions','delibera_admin_list_options', 10, 2); - -require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_cron.php'; - -require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_topic.php'; +require_once __DIR__ . DIRECTORY_SEPARATOR . 'delibera_curtir.php'; -require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_curtir.php'; +require_once __DIR__ . DIRECTORY_SEPARATOR . 'delibera_discordar.php'; -require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_discordar.php'; +require_once __DIR__ . DIRECTORY_SEPARATOR . 'delibera_seguir.php'; -require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_seguir.php'; - -if(file_exists(__DIR__.DIRECTORY_SEPARATOR.'mailer') && file_exists(__DIR__.DIRECTORY_SEPARATOR.'mailer'.DIRECTORY_SEPARATOR.'delibera_mailer.php')) +if (file_exists(__DIR__.DIRECTORY_SEPARATOR.'mailer') && + file_exists(__DIR__.DIRECTORY_SEPARATOR.'mailer' . DIRECTORY_SEPARATOR . 'delibera_mailer.php')) { //require_once __DIR__.DIRECTORY_SEPARATOR.'mailer'.DIRECTORY_SEPARATOR.'delibera_mailer.php'; } -function delibera_restrict_listings() -{ - global $typenow; - global $wp_query; - if ($typenow=='pauta') - { - $taxonomy = 'situacao'; - $situacao_taxonomy = get_taxonomy($taxonomy); - wp_dropdown_categories(array( - 'show_option_all' => sprintf(__('Mostrar todas as %s','delibera'),$situacao_taxonomy->label), - 'taxonomy' => $taxonomy, - 'name' => 'situacao', - 'orderby' => 'id', - 'selected' => isset($_REQUEST['situacao']) ? $_REQUEST['situacao'] : '', - 'hierarchical' => false, - 'depth' => 1, - 'show_count' => true, // This will give a view - 'hide_empty' => true, // This will give false positives, i.e. one's not empty related to the other terms. - )); - } -} -add_action('restrict_manage_posts','delibera_restrict_listings'); +require_once __DIR__ . DIRECTORY_SEPARATOR . 'delibera_notificar.php'; -function delibera_convert_situacao_id_to_taxonomy_term_in_query(&$query) -{ - global $pagenow; - $qv = &$query->query_vars; - if (isset($qv['post_type']) && - $qv['post_type'] == 'pauta' && - $pagenow=='edit.php' && - isset($qv['situacao']) - ) - { - $situacao = get_term_by('id', $_REQUEST['situacao'], 'situacao'); - $qv['situacao'] = $situacao->slug; - } -} -add_filter('parse_query','delibera_convert_situacao_id_to_taxonomy_term_in_query'); - -/** - * Notificações do sistema. - */ -require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_notificar.php'; +require_once __DIR__ . DIRECTORY_SEPARATOR . 'delibera_user_painel.php'; -/** - * Perfil do usuário - */ -require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_user_painel.php'; - -// gerar relatório em um arquivo xls require_once __DIR__ . DIRECTORY_SEPARATOR . 'delibera_relatorio.php'; - -function delibera_the_posts($posts) -{ - if (empty($posts)) return $posts; - - $timeline_found = false; // use this flag to see if styles and scripts need to be enqueued - $relatoria = false; - foreach ($posts as $post) - { - if (stripos($post->post_content, '[delibera_timeline') !== false) - { - $timeline_found = true; // bingo! - } - if(get_post_type($post) == 'pauta') - { - $situacao = delibera_get_situacao($post->ID); - if($situacao->slug == 'relatoria') - { - $relatoria = true; - } - } - } - - if ( ($timeline_found) && (!is_admin()) ) - { - // enqueue here - wp_enqueue_style('delibera_timeline_css', WP_CONTENT_URL.'/plugins/delibera/timeline/delibera_timeline.css'); - wp_enqueue_script( 'delibera_timeline_js', WP_CONTENT_URL.'/plugins/delibera/timeline/js/delibera_timeline.js', array( 'jquery' )); - wp_enqueue_script( 'jquery-ui-draggable'); - } - - return $posts; -} - -add_filter('the_posts', 'delibera_the_posts'); // the_posts gets triggered before wp_head - -// FIM Funções de conteudo - -// Validadores - -/** - * Sempre que um usuário valida uma pauta - * verifica se o número mínimo de validações foi - * atingido e se sim muda a situação da pauta de - * "emvotacao" para "discussao". - * - * @param unknown $post - * @return null - */ -function delibera_valida_validacoes($post) -{ - $validacoes = get_post_meta($post, 'numero_validacoes', true); - $min_validacoes = get_post_meta($post, 'min_validacoes', true); - - if($validacoes >= $min_validacoes) - { - wp_set_object_terms($post, 'discussao', 'situacao', false); //Mudar situação para Discussão - if(has_action('delibera_validacao_concluida')) - { - do_action('delibera_validacao_concluida', $post); - } - } - else - { - if(has_action('delibera_validacao')) - { - do_action('delibera_validacao', $post); - } - } -} - -/* Faz os testes de permissões para garantir que nenhum engraçadinho - * está injetando variáveis maliciosas. - * TODO: Incluir todas as variaveis a serem verificadas aqui - */ -function delibera_valida_permissoes($comment_ID) -{ - if (get_post_type() == 'pauta' && !delibera_current_user_can_participate()) - { - if (array_key_exists('delibera_validacao', $_REQUEST) || array_key_exists('delibera_encaminha', $_REQUEST) ) - wp_die("Nananina não! Você não tem que ter permissão pra votar.","Tocooo!!"); - } -} -add_action( 'wp_blacklist_check', 'delibera_valida_permissoes' ); - -/** - * - * Verifica se o número de votos é igual ao número de representantes para deflagar fim da votação - * @param integer $postID - */ -function delibera_valida_votos($postID) -{ - global $wp_roles,$wpdb; - $users_count = 0; - foreach ($wp_roles->roles as $nome => $role) - { - if(is_array($role['capabilities']) && array_key_exists('votar', $role['capabilities']) && $role['capabilities']['votar'] == 1 ? "SSSSSim" : "NNNnnnnnnnao") - { - $result = $wpdb->get_results("SELECT count(*) as n FROM $wpdb->usermeta WHERE meta_key = 'wp_capabilities' AND meta_value LIKE '%$nome%' "); - $users_count += $result[0]->n; - } - } - - $votos = delibera_get_comments_votacoes($postID); - - $votos_count = count($votos); - - if($votos_count >= $users_count) - { - delibera_computa_votos($postID, $votos); - } -} - -/** - * - * Faz a apuração dos votos e toma as devidas ações: - * Empate: Mais prazo; - * Vencedor: Marco com resolucao e marca o encaminhamento. - * @param interger $postID - * @param array $votos - */ -function delibera_computa_votos($postID, $votos = null) -{ - if(is_null($votos)) // Ocorre no fim do prazo de votação - { - $votos = delibera_get_comments_votacoes($postID); - } - $encaminhamentos = delibera_get_comments_encaminhamentos($postID); - $encaminhamentos_votos = array(); - foreach ($encaminhamentos as $encaminhamento) - { - $encaminhamentos_votos[$encaminhamento->comment_ID] = 0; - } - - foreach ($votos as $voto_comment) - { - $voto = get_comment_meta($voto_comment->comment_ID, 'delibera_votos', true); - foreach ($voto as $voto_para) - { - if (isset($encaminhamentos_votos[$voto_para])) - { - $encaminhamentos_votos[$voto_para]++; - } else { - $encaminhamentos_votos[$voto_para] = 1; - } - } - } - $maisvotado = array(-1, -1); - $iguais = array(); - - foreach ($encaminhamentos_votos as $encaminhamentos_voto_key => $encaminhamentos_voto_valor) - { - if($encaminhamentos_voto_valor > $maisvotado[1]) - { - $maisvotado[0] = $encaminhamentos_voto_key; - $maisvotado[1] = $encaminhamentos_voto_valor; - $iguais = array(); - } - elseif($encaminhamentos_voto_valor == $maisvotado[1]) - { - $iguais[] = $encaminhamentos_voto_key; - } - delete_comment_meta($encaminhamentos_voto_key, 'delibera_comment_numero_votos'); - add_comment_meta($encaminhamentos_voto_key, 'delibera_comment_numero_votos', $encaminhamentos_voto_valor, true); - } - - // nao finaliza a votacao caso haja um empate, exceto quando o administrador clicar no botão "Forçar fim do prazo" - if(count($iguais) > 0 && !(isset($_REQUEST['action']) && $_REQUEST['action'] == 'delibera_forca_fim_prazo_action')) // Empato - { - delibera_novo_prazo($postID); - } - else - { - wp_set_object_terms($postID, 'comresolucao', 'situacao', false); - update_comment_meta($maisvotado[0], 'delibera_comment_tipo', 'resolucao'); - add_post_meta($postID, 'data_resolucao', date('d/m/Y H:i:s'), true); - ////delibera_notificar_situacao($postID); - if(has_action('votacao_concluida')) - { - do_action('votacao_concluida', $post); - } - } -} - -function delibera_emvotacao($post) -{ - $opt = delibera_get_config(); - if($opt['relatoria'] == 'S') - { - if($opt['eleicao_relator'] == 'S') - { - - } - } -} - -add_action('init', 'delibera_nova_pauta_create_action'); -function delibera_nova_pauta_create_action(){ - $opt = delibera_get_config(); - if ($opt['criar_pauta_pelo_front_end'] == 'S' && is_user_logged_in() && isset($_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'delibera_nova_pauta')) { - $title = $_POST['nova-pauta-titulo']; - $content = $_POST['nova-pauta-conteudo']; - $excerpt = $_POST['nova-pauta-resumo']; - - $pauta = array(); - $pauta['post_title'] = $title; - $pauta['post_excerpt'] = $excerpt; - $pauta['post_type'] = 'pauta'; - - //Check if there is any file uploaded - // If there is any, then ignore 'content' and use File. - // else do add 'pauta' with the text content - if(!empty($_FILES['post_pdf_contribution']['name'])) { - // Setup the array of supported file types. In this case, it's just PDF. - $supported_types = array('application/pdf'); - // Get the file type of the upload - $pdf_contribution = wp_check_filetype(basename($_FILES['post_pdf_contribution']['name'])); - $sent_file_type = $pdf_contribution['type']; - // Check if the type is supported. If not, throw an error. - if (!in_array($sent_file_type, $supported_types)) { - //TODO: Improve this message and avoid wp_die - wp_die("O arquivo para web não é um PDF (formato permitido)."); - } - $uploaded_file = wp_upload_bits($_FILES['pauta_pdf_contribution']['name'], null, file_get_contents($_FILES['pauta_pdf_contribution']['tmp_name'])); - if(isset($uploaded_file['error']) && $uploaded_file['error'] != 0) { - wp_die('Erro ao salvar arquivo para Web. O erro foi: ' . $upload['error']); - } else { - $pauta['pauta_pdf_contribution'] = $uploaded_file['url']; - } - } else { - $pauta['post_content'] = $content; - } - - // para que a situação da pauta seja criada corretamente, - // é necessário criar a pauta como rascunho para depois publicar no final desta função - $pauta['post_status'] = 'draft'; - - $pauta_id = wp_insert_post($pauta); - - if(is_int($pauta_id) && $pauta_id > 0){ - - /* Os valores adicionados ao array $_POST são baseados no if da função delibera_save_post(), - * comentado abaixo - if( - ( // Se tem validação, tem que ter o prazo - $opt['validacao'] == 'N' || - (array_key_exists('prazo_validacao', $_POST) && array_key_exists('min_validacoes', $_POST) ) - ) && - ( // Se tem relatoria, tem que ter o prazo - $opt['relatoria'] == 'N' || - array_key_exists('prazo_relatoria', $_POST) - ) && - ( // Se tem relatoria, e é preciso eleger o relator, tem que ter o prazo para eleição - $opt['relatoria'] == 'N' || - ( - $opt['eleicao_relator'] == 'N' || - array_key_exists('prazo_eleicao_relator', $_POST) - ) - ) && - array_key_exists('prazo_discussao', $_POST) && - array_key_exists('prazo_votacao', $_POST) - ) - */ - - if($opt['validacao'] == 'S'){ - $_POST['prazo_validacao'] = date('d/m/Y', strtotime ('+'.$opt['dias_validacao'].' DAYS')); - $_POST['min_validacoes'] = $opt['minimo_validacao']; - } - - if($opt['relatoria'] == 'S'){ - $_POST['prazo_relatoria'] = date('d/m/Y', strtotime ('+'.$opt['dias_relatoria'].' DAYS')); - if($opt['eleicao_relator'] == 'S'){ - $_POST['prazo_eleicao_relator'] = date('d/m/Y', strtotime ('+'.$opt['dias_votacao_relator'].' DAYS')); - } - } - - if (trim($opt['data_fixa_nova_pauta_externa']) != '') { - $prazo_discussao = DateTime::createFromFormat('d/m/Y', $opt['data_fixa_nova_pauta_externa']); - $_POST['prazo_discussao'] = $prazo_discussao->format('d/m/Y'); - $_POST['prazo_votacao'] = date('d/m/Y', strtotime ('+'.$opt['dias_votacao'].' DAYS', $prazo_discussao->getTimestamp())); - } else { - $_POST['prazo_discussao'] = date('d/m/Y', strtotime ('+'.$opt['dias_discussao'].' DAYS')); - $_POST['prazo_votacao'] = date('d/m/Y', strtotime ('+'.$opt['dias_votacao'].' DAYS')); - } - - // isto é necessário por causa do if da função delibera_publish_pauta() - $_POST['publish'] = 'Publicar'; - $_POST['prev_status'] = 'draft'; - - // verifica se todos os temas enviados por post são válidos - $temas = get_terms('tema', array('hide_empty' => true)); - $temas_ids = array(); - - if(isset($_POST['tema']) && is_array($_POST['tema'])) - foreach($temas as $tema) - if(in_array ($tema->term_id, $_POST['tema'])) - $temas_ids[] = $tema->term_id; - - // coloca os termos de temas no post - wp_set_post_terms($pauta_id, $temas_ids, 'tema'); - - // publica o post - wp_publish_post($pauta_id); - - // isto serve para criar o slug corretamente, - // já que no wp_insert_post não cria o slug quando o status é draft e o wp_publish_post tb não cria o slug - unset($pauta['post_status']); - $pauta['ID'] = $pauta_id; - $pauta['post_name'] = sanitize_post_field('post_name', $title, $pauta_id, 'save'); - wp_update_post($pauta); - - // redireciona para a pauta criada - $permalink = get_post_permalink($pauta_id); - wp_safe_redirect($permalink); - die; - } - } -} - -// END - Interface pública para a criação de novas pautas - -/** - * Redireciona usuários que não são membros do site + /** + * Redir e ciona usuários que não são membros do site * onde o Delibera foi instalado para a página de pautas após o - * login se a opção "Todos os usuários logados na rede podem participar?" - * estiver habilitada. - * + * login se a opção "Todos os usuários logados na rede podem participar?" + * e s tiver habilitada. + * * Se não fizermos esse redicionamento estes usuários serão redirecionados - * para suas páginas de perfil fora do site onde o Delibera está instalado. + * para suas páginas de perfil fora do site onde o Delibera es t á i nstalado. * -add_filter('login_redirect', function($redirect_to, $request, $user) { +a d d_filter('login_redirect', function($redirect_to, $request, $user) { $options = delibera_get_config(); if ($options['todos_usuarios_logados_podem_participar'] == 'S' && !is_user_member_of_blog()) { @@ -540,23 +104,4 @@ function delibera_nova_pauta_create_action(){ return $redirect_to; } }, 10, 3); -TODO mundo redirecionado para a lista de pauta, talvez uma nova opções */ - -/*** - * Verifica se as pautas devem suportar sugestão de encaminhamento ou se - * as propostas entram apenas como opinião. Muito útil para consultas públicas. - * - * @return bool - */ -function delibera_pautas_suportam_encaminhamento() -{ - $options = delibera_get_config(); - - if ( $options['pauta_suporta_encaminhamento'] == 'S' ) { - return true; - } else { - return false; - } -} - -?> +TODO mundo redirecionado para a lista de pauta, talvez uma nova opções */ \ No newline at end of file diff --git a/delibera_admin_functions.php b/delibera_admin_functions.php index 12a3bc9..d1daf43 100644 --- a/delibera_admin_functions.php +++ b/delibera_admin_functions.php @@ -181,4 +181,57 @@ function delibera_post_custom_column($column) } -add_action('manage_posts_custom_column', 'delibera_post_custom_column'); \ No newline at end of file +add_action('manage_posts_custom_column', 'delibera_post_custom_column'); + +function delibera_admin_list_options($actions, $post) +{ + if(get_post_type($post) == 'pauta' && $post->post_status == 'publish' ) + { + if(current_user_can('forcar_prazo')) + { + $url = 'admin.php?action=delibera_forca_fim_prazo_action&post='.$post->ID; + $url = wp_nonce_url($url, 'delibera_forca_fim_prazo_action'.$post->ID); + $actions['forcar_prazo'] = ''.__('Forçar fim de prazo','delibera').''; + + $url = 'admin.php?action=delibera_nao_validado_action&post='.$post->ID; + $url = wp_nonce_url($url, 'delibera_nao_validado_action'.$post->ID); + $actions['nao_validado'] = ''.__('Invalidar','delibera').''; + + } + if(delibera_get_situacao($post->ID)->slug == 'naovalidada' && current_user_can('delibera_reabrir_pauta')) + { + $url = 'admin.php?action=delibera_reabrir_pauta_action&post='.$post->ID; + $url = wp_nonce_url($url, 'delibera_reabrir_pauta_action'.$post->ID); + $actions['reabrir'] = ''.__('Reabrir','delibera').''; + } + + } + + //print_r(_get_cron_array()); + return $actions; +} + +add_filter('post_row_actions','delibera_admin_list_options', 10, 2); + +function delibera_restrict_listings() +{ + global $typenow; + global $wp_query; + if ($typenow=='pauta') + { + $taxonomy = 'situacao'; + $situacao_taxonomy = get_taxonomy($taxonomy); + wp_dropdown_categories(array( + 'show_option_all' => sprintf(__('Mostrar todas as %s','delibera'),$situacao_taxonomy->label), + 'taxonomy' => $taxonomy, + 'name' => 'situacao', + 'orderby' => 'id', + 'selected' => isset($_REQUEST['situacao']) ? $_REQUEST['situacao'] : '', + 'hierarchical' => false, + 'depth' => 1, + 'show_count' => true, // This will give a view + 'hide_empty' => true, // This will give false positives, i.e. one's not empty related to the other terms. + )); + } +} +add_action('restrict_manage_posts','delibera_restrict_listings'); \ No newline at end of file diff --git a/delibera_comments.php b/delibera_comments.php index f5c15eb..3248c80 100644 --- a/delibera_comments.php +++ b/delibera_comments.php @@ -1,8 +1,4 @@ = $min_validacoes) + { + wp_set_object_terms($post, 'discussao', 'situacao', false); //Mudar situação para Discussão + if(has_action('delibera_validacao_concluida')) + { + do_action('delibera_validacao_concluida', $post); + } + } + else + { + if(has_action('delibera_validacao')) + { + do_action('delibera_validacao', $post); + } + } +} + +/* Faz os testes de permissões para garantir que nenhum engraçadinho + * está injetando variáveis maliciosas. + * TODO: Incluir todas as variaveis a serem verificadas aqui + */ +function delibera_valida_permissoes($comment_ID) +{ + if (get_post_type() == 'pauta' && !delibera_current_user_can_participate()) + { + if (array_key_exists('delibera_validacao', $_REQUEST) || array_key_exists('delibera_encaminha', $_REQUEST) ) + wp_die("Nananina não! Você não tem que ter permissão pra votar.","Tocooo!!"); + } +} +add_action( 'wp_blacklist_check', 'delibera_valida_permissoes' ); + +/** + * + * Verifica se o número de votos é igual ao número de representantes para deflagar fim da votação + * @param integer $postID + */ +function delibera_valida_votos($postID) +{ + global $wp_roles,$wpdb; + $users_count = 0; + foreach ($wp_roles->roles as $nome => $role) + { + if(is_array($role['capabilities']) && array_key_exists('votar', $role['capabilities']) && $role['capabilities']['votar'] == 1 ? "SSSSSim" : "NNNnnnnnnnao") + { + $result = $wpdb->get_results("SELECT count(*) as n FROM $wpdb->usermeta WHERE meta_key = 'wp_capabilities' AND meta_value LIKE '%$nome%' "); + $users_count += $result[0]->n; + } + } + + $votos = delibera_get_comments_votacoes($postID); + + $votos_count = count($votos); + + if($votos_count >= $users_count) + { + delibera_computa_votos($postID, $votos); + } +} + +/** + * + * Faz a apuração dos votos e toma as devidas ações: + * Empate: Mais prazo; + * Vencedor: Marco com resolucao e marca o encaminhamento. + * @param interger $postID + * @param array $votos + */ +function delibera_computa_votos($postID, $votos = null) +{ + if(is_null($votos)) // Ocorre no fim do prazo de votação + { + $votos = delibera_get_comments_votacoes($postID); + } + $encaminhamentos = delibera_get_comments_encaminhamentos($postID); + $encaminhamentos_votos = array(); + foreach ($encaminhamentos as $encaminhamento) + { + $encaminhamentos_votos[$encaminhamento->comment_ID] = 0; + } + + foreach ($votos as $voto_comment) + { + $voto = get_comment_meta($voto_comment->comment_ID, 'delibera_votos', true); + foreach ($voto as $voto_para) + { + if (isset($encaminhamentos_votos[$voto_para])) + { + $encaminhamentos_votos[$voto_para]++; + } else { + $encaminhamentos_votos[$voto_para] = 1; + } + } + } + $maisvotado = array(-1, -1); + $iguais = array(); + + foreach ($encaminhamentos_votos as $encaminhamentos_voto_key => $encaminhamentos_voto_valor) + { + if($encaminhamentos_voto_valor > $maisvotado[1]) + { + $maisvotado[0] = $encaminhamentos_voto_key; + $maisvotado[1] = $encaminhamentos_voto_valor; + $iguais = array(); + } + elseif($encaminhamentos_voto_valor == $maisvotado[1]) + { + $iguais[] = $encaminhamentos_voto_key; + } + delete_comment_meta($encaminhamentos_voto_key, 'delibera_comment_numero_votos'); + add_comment_meta($encaminhamentos_voto_key, 'delibera_comment_numero_votos', $encaminhamentos_voto_valor, true); + } + + // nao finaliza a votacao caso haja um empate, exceto quando o administrador clicar no botão "Forçar fim do prazo" + if(count($iguais) > 0 && !(isset($_REQUEST['action']) && $_REQUEST['action'] == 'delibera_forca_fim_prazo_action')) // Empato + { + delibera_novo_prazo($postID); + } + else + { + wp_set_object_terms($postID, 'comresolucao', 'situacao', false); + update_comment_meta($maisvotado[0], 'delibera_comment_tipo', 'resolucao'); + add_post_meta($postID, 'data_resolucao', date('d/m/Y H:i:s'), true); + ////delibera_notificar_situacao($postID); + if(has_action('votacao_concluida')) + { + do_action('votacao_concluida', $post); + } + } +} \ No newline at end of file diff --git a/delibera_init.php b/delibera_init.php index 00a5b0e..db7dcac 100644 --- a/delibera_init.php +++ b/delibera_init.php @@ -400,4 +400,54 @@ function delibera_config_menu() add_submenu_page($base_page, __('Configurações do Plugin','delibera'),__('Configurações do Plugin','delibera'), 'manage_options', 'delibera-config', 'delibera_conf_page'); do_action('delibera_menu_itens', $base_page); } -} \ No newline at end of file +} + +/** + * + * Insere term no banco e atualizar línguas do qtranslate + * @param string $label + * @param string $tax Taxonomy + * @param array $term EX: array('description'=> __('Español'),'slug' => 'espanol', 'slug' => 'espanol') + * @param array $idiomas EX: array('qtrans_term_en' => 'United States of America', 'qtrans_term_pt' => 'Estados Unidos da América', 'qtrans_term_es' => 'Estados Unidos de América' + */ +function delibera_insert_term($label, $tax, $term, $idiomas = array()) +{ + if(term_exists($term['slug'], $tax, null) == false) + { + wp_insert_term($label, $tax, $term); + global $q_config; + if(count($idiomas) > 0 && function_exists('qtrans_stripSlashesIfNecessary')) + { + if(isset($idiomas['qtrans_term_'.$q_config['default_language']]) && $idiomas['qtrans_term_'.$q_config['default_language']]!='') + { + $default = htmlspecialchars(qtrans_stripSlashesIfNecessary($idiomas['qtrans_term_'.$q_config['default_language']]), ENT_NOQUOTES); + if(!isset($q_config['term_name'][$default]) || !is_array($q_config['term_name'][$default])) $q_config['term_name'][$default] = array(); + foreach($q_config['enabled_languages'] as $lang) { + $idiomas['qtrans_term_'.$lang] = qtrans_stripSlashesIfNecessary($idiomas['qtrans_term_'.$lang]); + if($idiomas['qtrans_term_'.$lang]!='') { + $q_config['term_name'][$default][$lang] = htmlspecialchars($idiomas['qtrans_term_'.$lang], ENT_NOQUOTES); + } else { + $q_config['term_name'][$default][$lang] = $default; + } + } + update_option('qtranslate_term_name',$q_config['term_name']); + } + } + } +} + +function delibera_convert_situacao_id_to_taxonomy_term_in_query(&$query) +{ + global $pagenow; + $qv = &$query->query_vars; + if (isset($qv['post_type']) && + $qv['post_type'] == 'pauta' && + $pagenow=='edit.php' && + isset($qv['situacao']) + ) + { + $situacao = get_term_by('id', $_REQUEST['situacao'], 'situacao'); + $qv['situacao'] = $situacao->slug; + } +} +add_filter('parse_query','delibera_convert_situacao_id_to_taxonomy_term_in_query'); diff --git a/delibera_topic.php b/delibera_topic.php index ac4e6d2..c4a9f84 100644 --- a/delibera_topic.php +++ b/delibera_topic.php @@ -1,5 +1,4 @@ 0){ + + /* Os valores adicionados ao array $_POST são baseados no if da função delibera_save_post(), + * comentado abaixo + if( + ( // Se tem validação, tem que ter o prazo + $opt['validacao'] == 'N' || + (array_key_exists('prazo_validacao', $_POST) && array_key_exists('min_validacoes', $_POST) ) + ) && + ( // Se tem relatoria, tem que ter o prazo + $opt['relatoria'] == 'N' || + array_key_exists('prazo_relatoria', $_POST) + ) && + ( // Se tem relatoria, e é preciso eleger o relator, tem que ter o prazo para eleição + $opt['relatoria'] == 'N' || + ( + $opt['eleicao_relator'] == 'N' || + array_key_exists('prazo_eleicao_relator', $_POST) + ) + ) && + array_key_exists('prazo_discussao', $_POST) && + array_key_exists('prazo_votacao', $_POST) + ) + */ + + if($opt['validacao'] == 'S'){ + $_POST['prazo_validacao'] = date('d/m/Y', strtotime ('+'.$opt['dias_validacao'].' DAYS')); + $_POST['min_validacoes'] = $opt['minimo_validacao']; + } + + if($opt['relatoria'] == 'S'){ + $_POST['prazo_relatoria'] = date('d/m/Y', strtotime ('+'.$opt['dias_relatoria'].' DAYS')); + if($opt['eleicao_relator'] == 'S'){ + $_POST['prazo_eleicao_relator'] = date('d/m/Y', strtotime ('+'.$opt['dias_votacao_relator'].' DAYS')); + } + } + + if (trim($opt['data_fixa_nova_pauta_externa']) != '') { + $prazo_discussao = DateTime::createFromFormat('d/m/Y', $opt['data_fixa_nova_pauta_externa']); + $_POST['prazo_discussao'] = $prazo_discussao->format('d/m/Y'); + $_POST['prazo_votacao'] = date('d/m/Y', strtotime ('+'.$opt['dias_votacao'].' DAYS', $prazo_discussao->getTimestamp())); + } else { + $_POST['prazo_discussao'] = date('d/m/Y', strtotime ('+'.$opt['dias_discussao'].' DAYS')); + $_POST['prazo_votacao'] = date('d/m/Y', strtotime ('+'.$opt['dias_votacao'].' DAYS')); + } + + // isto é necessário por causa do if da função delibera_publish_pauta() + $_POST['publish'] = 'Publicar'; + $_POST['prev_status'] = 'draft'; + + // verifica se todos os temas enviados por post são válidos + $temas = get_terms('tema', array('hide_empty' => true)); + $temas_ids = array(); + + if(isset($_POST['tema']) && is_array($_POST['tema'])) + foreach($temas as $tema) + if(in_array ($tema->term_id, $_POST['tema'])) + $temas_ids[] = $tema->term_id; + + // coloca o s termos de temas no post + wp_set_post_terms($pauta_id, $temas_ids, 'tema'); + + // publica o post + wp_publish_post($pauta_id); + + // isto serve para criar o slug corretamente, + // já que no wp _ insert_post não cria o slug quando o status é draft e o wp_publish_post tb não cria o slug + unset($pauta['post_status']); + $pauta['ID'] = $pauta_id; + $pauta['post_name'] = sanitize_post_field('post_name', $title, $pauta_id, 'save'); + wp_update_post($pauta); + + // redireciona para a pauta criada + $permalink = get_post_permalink($pauta_id); + wp_safe_redirect($permalink); + die; + } + } + } diff --git a/timeline/delibera_timeline.php b/timeline/delibera_timeline.php index 5e97da4..13b2b08 100644 --- a/timeline/delibera_timeline.php +++ b/timeline/delibera_timeline.php @@ -224,4 +224,39 @@ function delibera_timeline_template_redirect() } } -add_action('template_redirect', 'delibera_timeline_template_redirect', 5); \ No newline at end of file +add_action('template_redirect', 'delibera_timeline_template_redirect', 5); + +function delibera_the_posts($posts) +{ + if (empty($posts)) return $posts; + + $timeline_found = false; // use this flag to see if styles and scripts need to be enqueued + $relatoria = false; + foreach ($posts as $post) + { + if (stripos($post->post_content, '[delibera_timeline') !== false) + { + $timeline_found = true; // bingo! + } + if(get_post_type($post) == 'pauta') + { + $situacao = delibera_get_situacao($post->ID); + if($situacao->slug == 'relatoria') + { + $relatoria = true; + } + } + } + + if ( ($timeline_found) && (!is_admin()) ) + { + // enqueue here + wp_enqueue_style('delibera_timeline_css', WP_CONTENT_URL.'/plugins/delibera/timeline/delibera_timeline.css'); + wp_enqueue_script( 'delibera_timeline_js', WP_CONTENT_URL.'/plugins/delibera/timeline/js/delibera_timeline.js', array( 'jquery' )); + wp_enqueue_script( 'jquery-ui-draggable'); + } + + return $posts; +} + +add_filter('the_posts', 'delibera_the_posts'); // the_posts gets triggered before wp_head \ No newline at end of file From acb8b79799b735d66f7c6926c2b70bc4ea1a0e19 Mon Sep 17 00:00:00 2001 From: Lucas Pirola Date: Tue, 19 Jan 2016 12:20:29 -0200 Subject: [PATCH 017/435] =?UTF-8?q?Corrige=20bug=20quando=20coment=C3=A1ri?= =?UTF-8?q?o=20=C3=A9=20feito=20em=20post=20comum?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- delibera_comments.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/delibera_comments.php b/delibera_comments.php index 3248c80..74ab1f0 100644 --- a/delibera_comments.php +++ b/delibera_comments.php @@ -126,8 +126,11 @@ function delibera_get_comment_link($comment_pass = false) function delibera_comment_post_redirect( $location ) { global $post, $comment_id; - - return ( $post->post_type == 'pauta' ) ? preg_replace("/#comment-([\d]+)/", "#delibera-comment-" . $comment_id, $location) : $location; + if (empty($global)) { + return $location; + } else { + return ( $post->post_type == 'pauta' ) ? preg_replace("/#comment-([\d]+)/", "#delibera-comment-" . $comment_id, $location) : $location; + } } add_filter( 'comment_post_redirect', 'delibera_comment_post_redirect' ); From dd866cc828f97fcdc3c0f977bc2b035b99e39783 Mon Sep 17 00:00:00 2001 From: Lucas Pirola Date: Tue, 19 Jan 2016 13:21:08 -0200 Subject: [PATCH 018/435] =?UTF-8?q?Adiciona=20documenta=C3=A7=C3=A3o=20par?= =?UTF-8?q?a=20template?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- delibera-edit-form-comment.php | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/delibera-edit-form-comment.php b/delibera-edit-form-comment.php index 096d167..e874fb2 100644 --- a/delibera-edit-form-comment.php +++ b/delibera-edit-form-comment.php @@ -1,17 +1,28 @@ + + '; - $post = $old; - - return ''; // Retornar código da representação -} -add_shortcode( 'delibera_lista_de_pautas', 'delibera_replace_pautas' ); - function delibera_replace_resolucoes($matches) { $temp = explode(',', $matches[1]); // configurações da shorttag diff --git a/delibera_topic.php b/delibera_topic.php index c32e354..c06843e 100644 --- a/delibera_topic.php +++ b/delibera_topic.php @@ -62,8 +62,6 @@ function delibera_get_situation_button($postId) switch($situacao->slug) { case 'emvotacao': return 'Votar'; - case 'discussao': - return 'Discutir'; default: return apply_filters('delibera_situation_button_text', $situacao); } @@ -84,7 +82,6 @@ function delibera_pauta_meta() if(!is_array($custom)) $custom = array(); $situacao = delibera_get_situacao($post->ID); - $dias_discussao = intval(htmlentities($options_plugin_delibera['dias_discussao'])); $dias_relatoria = intval(htmlentities($options_plugin_delibera['dias_relatoria'])); $dias_votacao_relator = intval(htmlentities($options_plugin_delibera['dias_votacao_relator'])); @@ -119,13 +116,10 @@ function delibera_pauta_meta() $now = strtotime(date('Y/m/d')." 11:59:59"); - $prazo_discussao_sugerido = strtotime("+$dias_discussao days", $now); $prazo_eleicao_relator_sugerido = strtotime("+$dias_votacao_relator days", $now); $prazo_relatoria_sugerido = strtotime("+$dias_relatoria days", $now); $prazo_votacao_sugerido = strtotime("+$dias_votacao days", $now); - - $prazo_discussao = date('d/m/Y', $prazo_discussao_sugerido); $prazo_eleicao_relator = date('d/m/Y', $prazo_eleicao_relator_sugerido); $prazo_relatoria = date('d/m/Y', $prazo_relatoria_sugerido); $prazo_votacao = date('d/m/Y', $prazo_votacao_sugerido); @@ -146,7 +140,6 @@ function delibera_pauta_meta() $post->post_status == 'auto-draft' || $post->post_status == 'pending')) { - $prazo_discussao = array_key_exists("prazo_discussao", $custom) ? $custom["prazo_discussao"][0] : $prazo_discussao; $prazo_eleicao_relator = array_key_exists("prazo_eleicao_relator", $custom) ? $custom["prazo_eleicao_relator"][0] : $prazo_eleicao_relator; $prazo_relatoria = array_key_exists("prazo_relatoria", $custom) ? $custom["prazo_relatoria"][0] : $prazo_relatoria; $prazo_votacao = array_key_exists("prazo_votacao", $custom) ? $custom["prazo_votacao"][0] : $prazo_votacao; @@ -154,12 +147,6 @@ function delibera_pauta_meta() do_action('delibera_topic_meta', $post, $custom, $options_plugin_delibera, $situacao, $disable_edicao); - ?> -

- - id="prazo_discussao" name="prazo_discussao" class="prazo_discussao widefat hasdatepicker" value=""/> -

- format('d/m/Y'); $_POST['prazo_votacao'] = date('d/m/Y', strtotime ('+'.$opt['dias_votacao'].' DAYS', $prazo_discussao->getTimestamp())); } else { - $_POST['prazo_discussao'] = date('d/m/Y', strtotime ('+'.$opt['dias_discussao'].' DAYS')); $_POST['prazo_votacao'] = date('d/m/Y', strtotime ('+'.$opt['dias_votacao'].' DAYS')); } diff --git a/modules/discussion/discussion.php b/modules/discussion/discussion.php new file mode 100644 index 0000000..c18525f --- /dev/null +++ b/modules/discussion/discussion.php @@ -0,0 +1,209 @@ + 'Pauta em Discussão', + 'slug' => 'discussao', + ), + array( + 'qtrans_term_pt' => 'Pauta em discussão', + 'qtrans_term_en' => 'Agenda en discusión', + 'qtrans_term_es' => 'Topic under discussion', + ) + ); + } + } + + /** + * Append configurations + * @param array $opts + */ + public function getMainConfig($opts) + { + $opt['dias_discussao'] = '5'; + return $opts; + } + + /** + * Array to show on config page + * @param array $rows + */ + public function configPageRows($rows, $opt) + { + $rows[] = array( + "id" => "dias_discussao", + "label" => __('Dias para discussão da pauta:', 'delibera'), + "content" => '' + ); + return $rows; + } + + /** + * Label to apply to button + * @param unknown $situation + */ + public function situationButtonText($situation) + { + if($situation == 'discussao') + { + return __('Discutir', 'delibera'); + } + + return $situation; + } + + /** + * + * Post Meta Fields display + * + * @param \WP_Post $post + * @param array $custom post custom fields + * @param array $options_plugin_delibera Delibera options array + * @param WP_Term $situacao + * @param bool $disable_edicao + * + */ + public function topicMeta($post, $custom, $options_plugin_delibera, $situacao, $disable_edicao) + { + $dias_discussao = intval(htmlentities($options_plugin_delibera['dias_discussao'])); + + $prazo_discussao_sugerido = strtotime("+$dias_discussao days", $now); + $prazo_discussao = date('d/m/Y', $prazo_discussao_sugerido); + + if(!($post->post_status == 'draft' || + $post->post_status == 'auto-draft' || + $post->post_status == 'pending')) + { + $prazo_discussao = array_key_exists("prazo_discussao", $custom) ? $custom["prazo_discussao"][0] : $prazo_discussao; + } + + ?> +

+ + id="prazo_discussao" name="prazo_discussao" class="prazo_discussao widefat hasdatepicker" value=""/> +

+ $value) // Buscar dados + { + if(get_post_meta($postID, $key, true)) // Se já existe + { + update_post_meta($postID, $key, $value); // Atualiza + } + else + { + add_post_meta($postID, $key, $value, true); // Senão, cria + } + } + } + + function checkPostData($erros, $opt, $autosave) + { + $value = $_POST['prazo_discussao']; + $valida = delibera_tratar_data($value); + if(!$autosave && ($valida === false || $valida < 1)) + { + $erros[] = __("É necessário definir corretamente o prazo de discussão", "delibera"); + } + return $erros; + } + + /** + * + * Retorna pautas em Validação + * @param array $filtro + */ + public static function getPautas($filtro = array()) + { + return delibera_get_pautas_em($filtro, 'discussao'); + } + + public function replacePautas($matches) + { + $temp = explode(',', $matches[1]); // configurações da shorttag + $count = count($temp); + + $param = array(); // TODO Tratar Parametros + + $html = self::getPautas($param); + $wp_posts = $html; + global $post; + $old = $post; + echo '
'; + foreach ( $wp_posts as $wp_post ) + { + $post = $wp_post; + include 'delibera_loop_pauta.php'; + } + echo '
'; + $post = $old; + + return ''; // Retornar código da representação + + } + + public function savePostMetas($events_meta, $opt) + { + $events_meta['prazo_discussao'] = $_POST['prazo_discussao']; + + return $events_meta; + } + + public function createPautaAtFront($opt) + { + if (trim($opt['data_fixa_nova_pauta_externa']) != '') { + $prazo_discussao = DateTime::createFromFormat('d/m/Y', $opt['data_fixa_nova_pauta_externa']); + $_POST['prazo_discussao'] = $prazo_discussao->format('d/m/Y'); + } else { + $_POST['prazo_discussao'] = date('d/m/Y', strtotime ('+'.$opt['dias_discussao'].' DAYS')); + } + } + +} +$DeliberaDiscussion = new DeliberaDiscussion(); + + diff --git a/modules/validation/validation.php b/modules/validation/validation.php index 313c8fb..4db2b7e 100644 --- a/modules/validation/validation.php +++ b/modules/validation/validation.php @@ -14,7 +14,7 @@ public function __construct() add_filter('delibera_situation_button_text', array($this, 'situationButtonText')); add_action('delibera_topic_meta', array($this, 'topicMeta'), 10, 5); add_action('delibera_publish_pauta', array($this, 'publishPauta'), 10, 3); - add_filter('delibera_check_post_data', array($this, 'checkPostData'), 10, 2); + add_filter('delibera_check_post_data', array($this, 'checkPostData'), 10, 3); //add_action('delibera_save_post', array($this, 'savePost'), 10, 3); add_filter('delibera_save_post_metas', array($this, 'savePostMetas'), 10, 2); add_action('delibera_create_pauta_frontend', array($this, 'createPautaAtFront')); @@ -183,7 +183,7 @@ public function publishPauta($postID, $opt, $alterar) } } - function checkPostData($erros, $opt) + function checkPostData($erros, $opt, $autosave) { if($opt['validacao'] == 'S') { From 722f99a3fa68076d9d1f63f6098422da506a8946 Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Fri, 19 Feb 2016 02:01:22 -0200 Subject: [PATCH 030/435] fix erros when var migration --- delibera_topic.php | 169 ++++++++++++++++-------------- modules/discussion/discussion.php | 8 +- modules/validation/validation.php | 11 +- 3 files changed, 106 insertions(+), 82 deletions(-) diff --git a/delibera_topic.php b/delibera_topic.php index c06843e..65e07cd 100644 --- a/delibera_topic.php +++ b/delibera_topic.php @@ -100,7 +100,7 @@ function delibera_pauta_meta() //TODO adicionar modulo anterior ao prazo $dias_discussao += $dias_validacao; } - $dias_votacao = $dias_discussao + intval(htmlentities($options_plugin_delibera['dias_votacao'])); + $dias_votacao = /*$dias_discussao +*/ intval(htmlentities($options_plugin_delibera['dias_votacao'])); if($options_plugin_delibera['relatoria'] == "S") // Adiciona prazo de relatoria se for necessário { @@ -359,89 +359,104 @@ function delibera_save_post($post_id, $post) } $opt = delibera_get_config(); $autosave = ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ); - - $events_meta = array(); - - $validacoes = get_post_meta($post_id, 'numero_validacoes', true); - if($validacoes == "" || $validacoes === false || is_null($validacoes)) + if( + ( // Se tem relatoria, tem que ter o prazo + $opt['relatoria'] == 'N' || + array_key_exists('prazo_relatoria', $_POST) + ) && + ( // Se tem relatoria, e é preciso eleger o relator, tem que ter o prazo para eleição + $opt['relatoria'] == 'N' || + ( + $opt['eleicao_relator'] == 'N' || + array_key_exists('prazo_eleicao_relator', $_POST) + ) + ) && + array_key_exists('prazo_votacao', $_POST) + ) { - $events_meta['delibera_numero_comments_votos'] = 0; - $events_meta['delibera_numero_comments_padroes'] = 0; - $events_meta['delibera_numero_curtir'] = 0; - $events_meta['delibera_curtiram'] = array(); - $events_meta['delibera_numero_discordar'] = 0; - $events_meta['delibera_discordaram'] = array(); - $events_meta['delibera_numero_seguir'] = 0; - $events_meta['delibera_seguiram'] = array(); - } - - $events_meta['prazo_relatoria'] = $opt['relatoria'] == 'S' ? $_POST['prazo_relatoria'] : date('d/m/Y'); - $events_meta['prazo_eleicao_relator'] = $opt['relatoria'] == 'S' && $opt['eleicao_relator'] == 'S' ? $_POST['prazo_eleicao_relator'] : date('d/m/Y'); - $events_meta['prazo_votacao'] = $_POST['prazo_votacao']; + $events_meta = array(); - - /* ######### START ######### */ - /* ######### FOR PDF UPLOAD FILE ######### */ - // Setup the array of supported file types. In this case, it's just PDF. - $supported_types = array('application/pdf'); - - // Get the file type of the upload - $arr_uploaded_file_type = wp_check_filetype(basename($_FILES['pauta_pdf_contribution']['name'])); - $uploaded_file_type = $arr_uploaded_file_type['type']; - - if (isset ($_FILES['pauta_pdf_contribution']['name']) && $_FILES['pauta_pdf_contribution']['name'] != '') { - if (!in_array($uploaded_file_type, $supported_types)) { - //TODO: Improve this message and avoid wp_die - wp_die("O arquivo para web não é um PDF (formato permitido)."); - } - - - // Use the WordPress API to upload the file - $upload_pauta_pdf = wp_upload_bits($_FILES['pauta_pdf_contribution']['name'], null, file_get_contents($_FILES['pauta_pdf_contribution']['tmp_name'])); - - if (isset($upload_pauta_pdf['error']) && $upload_pauta_pdf['error'] != 0) { - $events_meta['pauta_pdf_contribution'] = none; - wp_die('Erro ao salvar arquivo para Web. O erro foi: ' . $upload_pauta_pdf['error']); - } else { - $events_meta['pauta_pdf_contribution'] = $upload_pauta_pdf['url']; - - global $wpdb; - - $wpdb->query($wpdb->prepare("UPDATE " . $wpdb->prefix . "posts SET post_content=%s WHERE ID=%d", '', $post->ID)); - } - } - /* ######### FOR PDF UPLOAD FILE ######### */ - /* ######### END ######### */ - - $events_meta = apply_filters('delibera_save_post_metas', $events_meta); - - foreach ($events_meta as $key => $value) // Buscar dados - { - if(get_post_meta($post->ID, $key, true)) // Se já existe + $validacoes = get_post_meta($post_id, 'numero_validacoes', true); + if($validacoes == "" || $validacoes === false || is_null($validacoes)) { - update_post_meta($post->ID, $key, $value); // Atualiza + $events_meta['delibera_numero_comments_votos'] = 0; + $events_meta['delibera_numero_comments_padroes'] = 0; + $events_meta['delibera_numero_curtir'] = 0; + $events_meta['delibera_curtiram'] = array(); + $events_meta['delibera_numero_discordar'] = 0; + $events_meta['delibera_discordaram'] = array(); + $events_meta['delibera_numero_seguir'] = 0; + $events_meta['delibera_seguiram'] = array(); } - else + + $events_meta['prazo_relatoria'] = $opt['relatoria'] == 'S' ? $_POST['prazo_relatoria'] : date('d/m/Y'); + $events_meta['prazo_eleicao_relator'] = $opt['relatoria'] == 'S' && $opt['eleicao_relator'] == 'S' ? $_POST['prazo_eleicao_relator'] : date('d/m/Y'); + $events_meta['prazo_votacao'] = $_POST['prazo_votacao']; + + + /* ######### START ######### */ + /* ######### FOR PDF UPLOAD FILE ######### */ + // Setup the array of supported file types. In this case, it's just PDF. + $supported_types = array('application/pdf'); + + // Get the file type of the upload + $arr_uploaded_file_type = wp_check_filetype(basename($_FILES['pauta_pdf_contribution']['name'])); + $uploaded_file_type = $arr_uploaded_file_type['type']; + + if (isset ($_FILES['pauta_pdf_contribution']['name']) && $_FILES['pauta_pdf_contribution']['name'] != '') { + if (!in_array($uploaded_file_type, $supported_types)) { + //TODO: Improve this message and avoid wp_die + wp_die("O arquivo para web não é um PDF (formato permitido)."); + } + + + // Use the WordPress API to upload the file + $upload_pauta_pdf = wp_upload_bits($_FILES['pauta_pdf_contribution']['name'], null, file_get_contents($_FILES['pauta_pdf_contribution']['tmp_name'])); + + if (isset($upload_pauta_pdf['error']) && $upload_pauta_pdf['error'] != 0) { + $events_meta['pauta_pdf_contribution'] = none; + wp_die('Erro ao salvar arquivo para Web. O erro foi: ' . $upload_pauta_pdf['error']); + } else { + $events_meta['pauta_pdf_contribution'] = $upload_pauta_pdf['url']; + + global $wpdb; + + $wpdb->query($wpdb->prepare("UPDATE " . $wpdb->prefix . "posts SET post_content=%s WHERE ID=%d", '', $post->ID)); + } + } + /* ######### FOR PDF UPLOAD FILE ######### */ + /* ######### END ######### */ + + $events_meta = apply_filters('delibera_save_post_metas', $events_meta, $opt); + + foreach ($events_meta as $key => $value) // Buscar dados { - add_post_meta($post->ID, $key, $value, true); // Senão, cria + if(get_post_meta($post->ID, $key, true)) // Se já existe + { + update_post_meta($post->ID, $key, $value); // Atualiza + } + else + { + add_post_meta($post->ID, $key, $value, true); // Senão, cria + } } - } - - do_action('delibera_save_post', $post_id, $post, $opt); - if( - array_key_exists('delibera_fim_prazo', $_POST) && - $_POST['delibera_fim_prazo'] == 'S' && - current_user_can('forcar_prazo') - ) - { - delibera_forca_fim_prazo($post->ID); - } - - if($post->post_status == 'publish' && !$autosave) - { - delibera_del_cron($post->ID); - delibera_publish_pauta($post->ID, $post, true); + do_action('delibera_save_post', $post_id, $post, $opt); + + if( + array_key_exists('delibera_fim_prazo', $_POST) && + $_POST['delibera_fim_prazo'] == 'S' && + current_user_can('forcar_prazo') + ) + { + delibera_forca_fim_prazo($post->ID); + } + + if($post->post_status == 'publish' && !$autosave) + { + delibera_del_cron($post->ID); + delibera_publish_pauta($post->ID, $post, true); + } } } diff --git a/modules/discussion/discussion.php b/modules/discussion/discussion.php index c18525f..f01704d 100644 --- a/modules/discussion/discussion.php +++ b/modules/discussion/discussion.php @@ -15,7 +15,6 @@ public function __construct() add_action('delibera_topic_meta', array($this, 'topicMeta'), 10, 5); add_action('delibera_publish_pauta', array($this, 'publishPauta'), 10, 3); add_filter('delibera_check_post_data', array($this, 'checkPostData'), 10, 3); - //add_action('delibera_save_post', array($this, 'savePost'), 10, 3); add_filter('delibera_save_post_metas', array($this, 'savePostMetas'), 10, 2); add_action('delibera_create_pauta_frontend', array($this, 'createPautaAtFront')); @@ -95,6 +94,8 @@ public function topicMeta($post, $custom, $options_plugin_delibera, $situacao, $ { $dias_discussao = intval(htmlentities($options_plugin_delibera['dias_discussao'])); + $now = strtotime(date('Y/m/d')." 11:59:59"); + $prazo_discussao_sugerido = strtotime("+$dias_discussao days", $now); $prazo_discussao = date('d/m/Y', $prazo_discussao_sugerido); @@ -188,7 +189,10 @@ public function replacePautas($matches) public function savePostMetas($events_meta, $opt) { - $events_meta['prazo_discussao'] = $_POST['prazo_discussao']; + if(array_key_exists('prazo_discussao', $_POST)) + { + $events_meta['prazo_discussao'] = $_POST['prazo_discussao']; + } return $events_meta; } diff --git a/modules/validation/validation.php b/modules/validation/validation.php index 4db2b7e..9a7f368 100644 --- a/modules/validation/validation.php +++ b/modules/validation/validation.php @@ -15,7 +15,6 @@ public function __construct() add_action('delibera_topic_meta', array($this, 'topicMeta'), 10, 5); add_action('delibera_publish_pauta', array($this, 'publishPauta'), 10, 3); add_filter('delibera_check_post_data', array($this, 'checkPostData'), 10, 3); - //add_action('delibera_save_post', array($this, 'savePost'), 10, 3); add_filter('delibera_save_post_metas', array($this, 'savePostMetas'), 10, 2); add_action('delibera_create_pauta_frontend', array($this, 'createPautaAtFront')); @@ -251,8 +250,14 @@ public function replacePropostas($matches) public function savePostMetas($events_meta, $opt) { - $events_meta['prazo_validacao'] = $opt['validacao'] == 'S' ? $_POST['prazo_validacao'] : date('d/m/Y'); - $events_meta['min_validacoes'] = $opt['validacao'] == 'S' ? $_POST['min_validacoes'] : 10; + if( // Se tem validação, tem que ter o prazo + $opt['validacao'] == 'N' || + (array_key_exists('prazo_validacao', $_POST) && array_key_exists('min_validacoes', $_POST) ) + ) + { + $events_meta['prazo_validacao'] = $opt['validacao'] == 'S' ? $_POST['prazo_validacao'] : date('d/m/Y'); + $events_meta['min_validacoes'] = $opt['validacao'] == 'S' ? $_POST['min_validacoes'] : 10; + } return $events_meta; } From 9dc64853b3b61f47498ef52a274a01fa058cda15 Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Fri, 19 Feb 2016 02:51:12 -0200 Subject: [PATCH 031/435] some bug fixes and extract situacao relatoria from topic --- delibera_conf.php | 34 +--- delibera_flow.php | 2 +- delibera_init.php | 33 ---- delibera_topic.php | 81 +-------- modules/discussion/discussion.php | 8 +- modules/rapporteur/rapporteur.php | 276 ++++++++++++++++++++++++++++++ 6 files changed, 287 insertions(+), 147 deletions(-) create mode 100644 modules/rapporteur/rapporteur.php diff --git a/delibera_conf.php b/delibera_conf.php index 61ca1fa..dfdbe9c 100644 --- a/delibera_conf.php +++ b/delibera_conf.php @@ -58,12 +58,7 @@ function delibera_get_main_config($config = array()) { $opt['dias_votacao'] = '5'; $opt['criar_pauta_pelo_front_end'] = 'N'; $opt['representante_define_prazos'] = 'N'; - $opt['pauta_suporta_encaminhamento'] = 'S'; $opt['dias_novo_prazo'] = '2'; - $opt['dias_relatoria'] = '2'; - $opt['relatoria'] = 'N'; - $opt['eleicao_relator'] = 'N'; - $opt['dias_votacao_relator'] = '2'; $opt['limitar_tamanho_comentario'] = 'N'; $opt['numero_max_palavras_comentario'] = '50'; $opt['plan_restriction'] = 'N'; @@ -117,8 +112,8 @@ function delibera_conf_page() // atualiza os permalinks por conta da opção "criar_pauta_pelo_front_end" flush_rewrite_rules(); - - if (update_option('delibera-config', apply_filters('delibera-pre-main-config-save', $opt)) || (isset($_POST["delibera_reinstall"]) && $_POST['delibera_reinstall'] == 'S')) + $opt = apply_filters('delibera-pre-main-config-save', $opt); + if (update_option('delibera-config', $opt) || (isset($_POST["delibera_reinstall"]) && $_POST['delibera_reinstall'] == 'S')) $mensagem = __('Configurações salvas!','delibera'); else $mensagem = __('Erro ao salvar as configurações. Verifique os valores inseridos e tente novamente!','delibera'); @@ -165,11 +160,6 @@ function delibera_conf_page() "label" => __('Representante define prazos?', 'delibera'), "content" => '', ); - $rows[] = array( - "id" => "pauta_suporta_encaminhamento", - "label" => __('Pautas suportam sugestão de encaminhamento?', 'delibera'), - "content" => '', - ); $rows = apply_filters('delivera_config_page_rows', $rows, $opt); @@ -184,26 +174,6 @@ function delibera_conf_page() "label" => __('Dias para novo prazo:', 'delibera'), "content" => '

' . __('Utilizado para as pautas em discussão, em relatoria e em votação para dar mais alguns dias quando uma condição mínima não é atingida até o fim do prazo. Por exemplo, quando acaba o prazo de uma pauta em discussão ou relatoria e ela não tem nenhuma proposta de encaminhamento. Utilizado também quando uma pauta não validada é reaberta.', 'delibera'). '

' ); - $rows[] = array( - "id" => "relatoria", - "label" => __('Necessário relatoria da discussão das pautas?', 'delibera'), - "content" => '' - ); - $rows[] = array( - "id" => "dias_relatoria", - "label" => __('Prazo para relatoria:', 'delibera'), - "content" => '' - ); - /*$rows[] = array( - "id" => "eleicao_relator", - "label" => __('Necessário eleição de relator?', 'delibera'), - "content" => '' - ); - $rows[] = array( - "id" => "dias_votacao_relator", - "label" => __('Prazo para eleição de relator:', 'delibera'), - "content" => '' - );*/ $rows[] = array( "id" => "limitar_tamanho_comentario", "label" => __('Limitar o tamanho do comentário visível?', 'delibera'), diff --git a/delibera_flow.php b/delibera_flow.php index e72b879..07d6793 100644 --- a/delibera_flow.php +++ b/delibera_flow.php @@ -50,7 +50,7 @@ public function preMainConfigSave($opts) { if(array_key_exists('flow', $opts) && !is_array($opts['flow'])) { - $opts['flow'] = explode(',', trim($opts['flow'])); + $opts['flow'] = array('validacao', 'discussao', 'elegerelator', 'relatoria', 'emvotacao', 'comresolucao');//explode(',', trim($opts['flow'])); } return $opts; } diff --git a/delibera_init.php b/delibera_init.php index 39215e6..a25879d 100644 --- a/delibera_init.php +++ b/delibera_init.php @@ -169,39 +169,6 @@ function delibera_Add_custom_taxonomy() ) ); } - if(isset($opt['relatoria']) && $opt['relatoria'] == 'S') - { - if($opt['eleicao_relator'] == 'S') - { - if(term_exists('eleicaoredator', 'situacao', null) == false) - { - delibera_insert_term('Regime de Votação de Relator', 'situacao', array( - 'description'=> 'Pauta em Eleição de Relator', - 'slug' => 'eleicaoredator', - ), - array( - 'qtrans_term_pt' => 'Regime de Votação de Relator', - 'qtrans_term_en' => 'Election of Rapporteur', - 'qtrans_term_es' => 'Elección del Relator', - ) - ); - } - } - - if(term_exists('relatoria', 'situacao', null) == false) - { - delibera_insert_term('Relatoria', 'situacao', array( - 'description'=> 'Pauta com encaminhamentos em Relatoria', - 'slug' => 'relatoria', - ), - array( - 'qtrans_term_pt' => 'Relatoria', - 'qtrans_term_en' => 'Rapporteur', - 'qtrans_term_es' => 'Relator', - ) - ); - } - } do_action('delibera_situacao_register'); } diff --git a/delibera_topic.php b/delibera_topic.php index 65e07cd..23474ca 100644 --- a/delibera_topic.php +++ b/delibera_topic.php @@ -82,9 +82,6 @@ function delibera_pauta_meta() if(!is_array($custom)) $custom = array(); $situacao = delibera_get_situacao($post->ID); - $dias_relatoria = intval(htmlentities($options_plugin_delibera['dias_relatoria'])); - $dias_votacao_relator = intval(htmlentities($options_plugin_delibera['dias_votacao_relator'])); - $pauta_pdf_file = get_post_meta($post->ID, 'pauta_pdf_contribution', true); // Recupera arquivo caso já tenha sido adicionados @@ -102,26 +99,10 @@ function delibera_pauta_meta() $dias_votacao = /*$dias_discussao +*/ intval(htmlentities($options_plugin_delibera['dias_votacao'])); - if($options_plugin_delibera['relatoria'] == "S") // Adiciona prazo de relatoria se for necessário - { - $dias_votacao += $dias_relatoria; - $dias_relatoria += $dias_discussao; - if($options_plugin_delibera['eleicao_relator'] == "S") // Adiciona prazo de vatacao relator se for necessário - { - $dias_votacao += $dias_votacao_relator; - $dias_relatoria += $dias_votacao_relator; - $dias_votacao_relator += $dias_discussao; - } - } - $now = strtotime(date('Y/m/d')." 11:59:59"); - $prazo_eleicao_relator_sugerido = strtotime("+$dias_votacao_relator days", $now); - $prazo_relatoria_sugerido = strtotime("+$dias_relatoria days", $now); $prazo_votacao_sugerido = strtotime("+$dias_votacao days", $now); - $prazo_eleicao_relator = date('d/m/Y', $prazo_eleicao_relator_sugerido); - $prazo_relatoria = date('d/m/Y', $prazo_relatoria_sugerido); $prazo_votacao = date('d/m/Y', $prazo_votacao_sugerido); if ( @@ -140,31 +121,12 @@ function delibera_pauta_meta() $post->post_status == 'auto-draft' || $post->post_status == 'pending')) { - $prazo_eleicao_relator = array_key_exists("prazo_eleicao_relator", $custom) ? $custom["prazo_eleicao_relator"][0] : $prazo_eleicao_relator; - $prazo_relatoria = array_key_exists("prazo_relatoria", $custom) ? $custom["prazo_relatoria"][0] : $prazo_relatoria; + $prazo_votacao = array_key_exists("prazo_votacao", $custom) ? $custom["prazo_votacao"][0] : $prazo_votacao; } do_action('delibera_topic_meta', $post, $custom, $options_plugin_delibera, $situacao, $disable_edicao); - if($options_plugin_delibera['relatoria'] == "S") - { - if($options_plugin_delibera['eleicao_relator'] == "S") - { - ?> -

- - id="prazo_eleicao_relator" name="prazo_eleicao_relator" class="prazo_eleicao_relator widefat hasdatepicker" value=""/> -

- -

- - id="prazo_relatoria" name="prazo_relatoria" class="prazo_relatoria widefat hasdatepicker" value=""/> -

-

@@ -234,27 +196,6 @@ function delibera_check_post_data($data, $postarr) $erros == apply_filters('delibera_check_post_data', $erros, $opt, $autosave); - if($opt['relatoria'] == 'S') - { - $value = $_POST['prazo_relatoria']; - $valida = delibera_tratar_data($value); - if(!$autosave && ($valida === false || $valida < 1)) - { - $erros[] = __("É necessário definir corretamente o prazo para relatoria", "Delibera"); - } - - if($opt['eleicao_relator'] == 'S') - { - $value = $_POST['prazo__leicao_relator']; - $valida = delibera_tratar_data($value); - if(!$autosave && ($valida === false || $valida < 1)) - { - $erros[] = __("É necessário definir corretamente o prazo para eleição de um relator", "delibera"); - } - } - - } - $value = $_POST['prazo_votacao']; $valida = delibera_tratar_data($value); if(!$autosave && ($valida === false || $valida < 1)) @@ -360,17 +301,6 @@ function delibera_save_post($post_id, $post) $opt = delibera_get_config(); $autosave = ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ); if( - ( // Se tem relatoria, tem que ter o prazo - $opt['relatoria'] == 'N' || - array_key_exists('prazo_relatoria', $_POST) - ) && - ( // Se tem relatoria, e é preciso eleger o relator, tem que ter o prazo para eleição - $opt['relatoria'] == 'N' || - ( - $opt['eleicao_relator'] == 'N' || - array_key_exists('prazo_eleicao_relator', $_POST) - ) - ) && array_key_exists('prazo_votacao', $_POST) ) { @@ -389,8 +319,6 @@ function delibera_save_post($post_id, $post) $events_meta['delibera_seguiram'] = array(); } - $events_meta['prazo_relatoria'] = $opt['relatoria'] == 'S' ? $_POST['prazo_relatoria'] : date('d/m/Y'); - $events_meta['prazo_eleicao_relator'] = $opt['relatoria'] == 'S' && $opt['eleicao_relator'] == 'S' ? $_POST['prazo_eleicao_relator'] : date('d/m/Y'); $events_meta['prazo_votacao'] = $_POST['prazo_votacao']; @@ -549,13 +477,6 @@ function delibera_nova_pauta_create_action(){ do_action('delibera_create_pauta_frontend', $opt); - if($opt['relatoria'] == 'S'){ - $_POST['prazo_relatoria'] = date('d/m/Y', strtotime ('+'.$opt['dias_relatoria'].' DAYS')); - if($opt['eleicao_relator'] == 'S'){ - $_POST['prazo_eleicao_relator'] = date('d/m/Y', strtotime ('+'.$opt['dias_votacao_relator'].' DAYS')); - } - } - if (trim($opt['data_fixa_nova_pauta_externa']) != '') { $prazo_discussao = DateTime::createFromFormat('d/m/Y', $opt['data_fixa_nova_pauta_externa']); $_POST['prazo_votacao'] = date('d/m/Y', strtotime ('+'.$opt['dias_votacao'].' DAYS', $prazo_discussao->getTimestamp())); diff --git a/modules/discussion/discussion.php b/modules/discussion/discussion.php index f01704d..96df622 100644 --- a/modules/discussion/discussion.php +++ b/modules/discussion/discussion.php @@ -47,7 +47,8 @@ public function registerTax() */ public function getMainConfig($opts) { - $opt['dias_discussao'] = '5'; + $opts['pauta_suporta_encaminhamento'] = 'S'; + $opts['dias_discussao'] = '5'; return $opts; } @@ -62,6 +63,11 @@ public function configPageRows($rows, $opt) "label" => __('Dias para discussão da pauta:', 'delibera'), "content" => '' ); + $rows[] = array( + "id" => "pauta_suporta_encaminhamento", + "label" => __('Pautas suportam sugestão de encaminhamento?', 'delibera'), + "content" => '', + ); return $rows; } diff --git a/modules/rapporteur/rapporteur.php b/modules/rapporteur/rapporteur.php new file mode 100644 index 0000000..3b06b4d --- /dev/null +++ b/modules/rapporteur/rapporteur.php @@ -0,0 +1,276 @@ + 'Pauta em Eleição de Relator', + 'slug' => 'eleicaoredator', + ), + array( + 'qtrans_term_pt' => 'Regime de Votação de Relator', + 'qtrans_term_en' => 'Election of Rapporteur', + 'qtrans_term_es' => 'Elección del Relator', + ) + ); + } + } + + if(term_exists('relatoria', 'situacao', null) == false) + { + delibera_insert_term('Relatoria', 'situacao', array( + 'description'=> 'Pauta com encaminhamentos em Relatoria', + 'slug' => 'relatoria', + ), + array( + 'qtrans_term_pt' => 'Relatoria', + 'qtrans_term_en' => 'Rapporteur', + 'qtrans_term_es' => 'Relator', + ) + ); + } + } + } + + /** + * Append configurations + * @param array $opts + */ + public function getMainConfig($opts) + { + $opts['dias_relatoria'] = '2'; + $opts['relatoria'] = 'N'; + $opts['eleicao_relator'] = 'N'; + $opts['dias_votacao_relator'] = '2'; + return $opts; + } + + /** + * Array to show on config page + * @param array $rows + */ + public function configPageRows($rows, $opt) + { + $rows[] = array( + "id" => "relatoria", + "label" => __('Necessário relatoria da discussão das pautas?', 'delibera'), + "content" => '' + ); + $rows[] = array( + "id" => "dias_relatoria", + "label" => __('Prazo para relatoria:', 'delibera'), + "content" => '' + ); + /*$rows[] = array( + "id" => "eleicao_relator", + "label" => __('Necessário eleição de relator?', 'delibera'), + "content" => '' + ); + $rows[] = array( + "id" => "dias_votacao_relator", + "label" => __('Prazo para eleição de relator:', 'delibera'), + "content" => '' + );*/ + return $rows; + } + + /** + * Label to apply to button + * @param unknown $situation + */ + public function situationButtonText($situation) + { + if($situation == 'relatoria') + { + return __('Relatar', 'delibera'); + } + + return $situation; + } + + /** + * + * Post Meta Fields display + * + * @param \WP_Post $post + * @param array $custom post custom fields + * @param array $options_plugin_delibera Delibera options array + * @param WP_Term $situacao + * @param bool $disable_edicao + * + */ + public function topicMeta($post, $custom, $options_plugin_delibera, $situacao, $disable_edicao) + { + $now = strtotime(date('Y/m/d')." 11:59:59"); + + $dias_relatoria = intval(htmlentities($options_plugin_delibera['dias_relatoria'])); + $dias_votacao_relator = intval(htmlentities($options_plugin_delibera['dias_votacao_relator'])); + + if($options_plugin_delibera['relatoria'] == "S") // Adiciona prazo de relatoria se for necessário + { + //$dias_relatoria += $dias_discussao; // TODO issue #50 + if($options_plugin_delibera['eleicao_relator'] == "S") // Adiciona prazo de vatacao relator se for necessário + { + $dias_relatoria += $dias_votacao_relator; + $dias_votacao_relator += $dias_discussao; + } + } + + $now = strtotime(date('Y/m/d')." 11:59:59"); + + $prazo_eleicao_relator_sugerido = strtotime("+$dias_votacao_relator days", $now); + $prazo_relatoria_sugerido = strtotime("+$dias_relatoria days", $now); + + $prazo_eleicao_relator = date('d/m/Y', $prazo_eleicao_relator_sugerido); + $prazo_relatoria = date('d/m/Y', $prazo_relatoria_sugerido); + + if(!($post->post_status == 'draft' || + $post->post_status == 'auto-draft' || + $post->post_status == 'pending')) + { + $prazo_eleicao_relator = array_key_exists("prazo_eleicao_relator", $custom) ? $custom["prazo_eleicao_relator"][0] : $prazo_eleicao_relator; + $prazo_relatoria = array_key_exists("prazo_relatoria", $custom) ? $custom["prazo_relatoria"][0] : $prazo_relatoria; + } + + if($options_plugin_delibera['relatoria'] == "S") + { + if($options_plugin_delibera['eleicao_relator'] == "S") + { + ?> +

+ + id="prazo_eleicao_relator" name="prazo_eleicao_relator" class="prazo_eleicao_relator widefat hasdatepicker" value=""/> +

+ +

+ + id="prazo_relatoria" name="prazo_relatoria" class="prazo_relatoria widefat hasdatepicker" value=""/> +

+ Date: Fri, 19 Feb 2016 03:14:32 -0200 Subject: [PATCH 032/435] some bug fixes and extract situacao votacao from topic --- delibera_conf.php | 7 - delibera_init.php | 13 -- delibera_topic.php | 109 +++------------- modules/rapporteur/rapporteur.php | 5 +- modules/vote/vote.php | 208 ++++++++++++++++++++++++++++++ 5 files changed, 226 insertions(+), 116 deletions(-) create mode 100644 modules/vote/vote.php diff --git a/delibera_conf.php b/delibera_conf.php index dfdbe9c..4120564 100644 --- a/delibera_conf.php +++ b/delibera_conf.php @@ -55,7 +55,6 @@ function delibera_get_main_config($config = array()) { $opt = array(); $opt['theme'] = $deliberaThemes->getThemeDir('creta'); - $opt['dias_votacao'] = '5'; $opt['criar_pauta_pelo_front_end'] = 'N'; $opt['representante_define_prazos'] = 'N'; $opt['dias_novo_prazo'] = '2'; @@ -163,12 +162,6 @@ function delibera_conf_page() $rows = apply_filters('delivera_config_page_rows', $rows, $opt); - $rows[] = array( - "id" => "dias_votacao", - "label" => __('Dias para votação de encaminhamentos:', 'delibera'), - "content" => '' - ); - $rows[] = array( "id" => "dias_novo_prazo", "label" => __('Dias para novo prazo:', 'delibera'), diff --git a/delibera_init.php b/delibera_init.php index a25879d..aac97db 100644 --- a/delibera_init.php +++ b/delibera_init.php @@ -156,19 +156,6 @@ function delibera_Add_custom_taxonomy() ) ); } - if(term_exists('emvotacao', 'situacao', null) == false) - { - delibera_insert_term('Regime de Votação', 'situacao', array( - 'description'=> 'Pauta com encaminhamentos em Votacao', - 'slug' => 'emvotacao', - ), - array( - 'qtrans_term_pt' => 'Regime de Votação', - 'qtrans_term_en' => 'Voting', - 'qtrans_term_es' => 'Sistema de Votación', - ) - ); - } do_action('delibera_situacao_register'); } diff --git a/delibera_topic.php b/delibera_topic.php index 23474ca..cb51ba6 100644 --- a/delibera_topic.php +++ b/delibera_topic.php @@ -55,16 +55,11 @@ function delibera_get_situation_button($postId) { $situacao = get_the_terms($postId, 'situacao'); - if (is_array($situacao) && !empty($situacao)) { + if (is_array($situacao) && !empty($situacao)) + { $situacao = array_pop($situacao); } - - switch($situacao->slug) { - case 'emvotacao': - return 'Votar'; - default: - return apply_filters('delibera_situation_button_text', $situacao); - } + return apply_filters('delibera_situation_button_text', $situacao->slug); } function delibera_update_edit_form() { @@ -97,14 +92,8 @@ function delibera_pauta_meta() //TODO adicionar modulo anterior ao prazo $dias_discussao += $dias_validacao; } - $dias_votacao = /*$dias_discussao +*/ intval(htmlentities($options_plugin_delibera['dias_votacao'])); - $now = strtotime(date('Y/m/d')." 11:59:59"); - $prazo_votacao_sugerido = strtotime("+$dias_votacao days", $now); - - $prazo_votacao = date('d/m/Y', $prazo_votacao_sugerido); - if ( $options_plugin_delibera['representante_define_prazos'] == "N" && !($post->post_status == 'draft' || @@ -117,22 +106,8 @@ function delibera_pauta_meta() $disable_edicao = ''; } - if(!($post->post_status == 'draft' || - $post->post_status == 'auto-draft' || - $post->post_status == 'pending')) - { - - $prazo_votacao = array_key_exists("prazo_votacao", $custom) ? $custom["prazo_votacao"][0] : $prazo_votacao; - } - do_action('delibera_topic_meta', $post, $custom, $options_plugin_delibera, $situacao, $disable_edicao); - ?> -

- - id="prazo_votacao" name="prazo_votacao" class="prazo_votacao widefat hasdatepicker" value=""/> -

- 0){ - /* Os valores adicionados ao array $_POST são baseados no if da função delibera_save_post(), - * comentado abaixo - if( - ( // Se tem validação, tem que ter o prazo - $opt['validacao'] == 'N' || - (array_key_exists('prazo_validacao', $_POST) && array_key_exists('min_validacoes', $_POST) ) - ) && - ( // Se tem relatoria, tem que ter o prazo - $opt['relatoria'] == 'N' || - array_key_exists('prazo_relatoria', $_POST) - ) && - ( // Se tem relatoria, e é preciso eleger o relator, tem que ter o prazo para eleição - $opt['relatoria'] == 'N' || - ( - $opt['eleicao_relator'] == 'N' || - array_key_exists('prazo_eleicao_relator', $_POST) - ) - ) && - array_key_exists('prazo_discussao', $_POST) && - array_key_exists('prazo_votacao', $_POST) - ) - */ - do_action('delibera_create_pauta_frontend', $opt); - if (trim($opt['data_fixa_nova_pauta_externa']) != '') { - $prazo_discussao = DateTime::createFromFormat('d/m/Y', $opt['data_fixa_nova_pauta_externa']); - $_POST['prazo_votacao'] = date('d/m/Y', strtotime ('+'.$opt['dias_votacao'].' DAYS', $prazo_discussao->getTimestamp())); - } else { - $_POST['prazo_votacao'] = date('d/m/Y', strtotime ('+'.$opt['dias_votacao'].' DAYS')); - } - // isto é necessário por causa do if da função delibera_publish_pauta() $_POST['publish'] = 'Publicar'; $_POST['prev_status'] = 'draft'; diff --git a/modules/rapporteur/rapporteur.php b/modules/rapporteur/rapporteur.php index 3b06b4d..3870bed 100644 --- a/modules/rapporteur/rapporteur.php +++ b/modules/rapporteur/rapporteur.php @@ -144,8 +144,6 @@ public function topicMeta($post, $custom, $options_plugin_delibera, $situacao, $ } } - $now = strtotime(date('Y/m/d')." 11:59:59"); - $prazo_eleicao_relator_sugerido = strtotime("+$dias_votacao_relator days", $now); $prazo_relatoria_sugerido = strtotime("+$dias_relatoria days", $now); @@ -227,7 +225,8 @@ function checkPostData($erros, $opt, $autosave) /** * - * Retorna pautas em Validação + * Retorna pautas em Relatoria ou Eleição para relator + * * @param array $filtro */ public static function getPautas($filtro = array()) diff --git a/modules/vote/vote.php b/modules/vote/vote.php new file mode 100644 index 0000000..6605522 --- /dev/null +++ b/modules/vote/vote.php @@ -0,0 +1,208 @@ + 'Pauta com encaminhamentos em Votacao', + 'slug' => 'emvotacao', + ), + array( + 'qtrans_term_pt' => 'Regime de Votação', + 'qtrans_term_en' => 'Voting', + 'qtrans_term_es' => 'Sistema de Votación', + ) + ); + } + } + + /** + * Append configurations + * @param array $opts + */ + public function getMainConfig($opts) + { + $opt['dias_votacao'] = '5'; + return $opts; + } + + /** + * Array to show on config page + * @param array $rows + */ + public function configPageRows($rows, $opt) + { + $rows[] = array( + "id" => "dias_votacao", + "label" => __('Dias para votação de encaminhamentos:', 'delibera'), + "content" => '' + ); + return $rows; + } + + /** + * Label to apply to button + * @param unknown $situation + */ + public function situationButtonText($situation) + { + if($situation == 'emvotacao') + { + return __('Votar', 'delibera'); + } + + return $situation; + } + + /** + * + * Post Meta Fields display + * + * @param \WP_Post $post + * @param array $custom post custom fields + * @param array $options_plugin_delibera Delibera options array + * @param WP_Term $situacao + * @param bool $disable_edicao + * + */ + public function topicMeta($post, $custom, $options_plugin_delibera, $situacao, $disable_edicao) + { + $now = strtotime(date('Y/m/d')." 11:59:59"); + + $dias_votacao = /*$dias_discussao +*/ intval(htmlentities($options_plugin_delibera['dias_votacao'])); + + $prazo_votacao_sugerido = strtotime("+$dias_votacao days", $now); + + $prazo_votacao = date('d/m/Y', $prazo_votacao_sugerido); + + if(!($post->post_status == 'draft' || + $post->post_status == 'auto-draft' || + $post->post_status == 'pending')) + { + + $prazo_votacao = array_key_exists("prazo_votacao", $custom) ? $custom["prazo_votacao"][0] : $prazo_votacao; + } + + ?> +

+ + id="prazo_votacao" name="prazo_votacao" class="prazo_votacao widefat hasdatepicker" value=""/> +

+ $value) // Buscar dados + { + if(get_post_meta($postID, $key, true)) // Se já existe + { + update_post_meta($postID, $key, $value); // Atualiza + } + else + { + add_post_meta($postID, $key, $value, true); // Senão, cria + } + } + + } + + function checkPostData($erros, $opt, $autosave) + { + $value = $_POST['prazo_votacao']; + $valida = delibera_tratar_data($value); + if(!$autosave && ($valida === false || $valida < 1)) + { + $erros[] = __("É necessário definir corretamente o prazo para votação", "delibera"); + } + return $erros; + } + + /** + * + * Retorna pautas em Validação + * @param array $filtro + */ + public static function getEmvotacao($filtro = array()) + { + return self::getPautas($filtro); + } + + /** + * + * Retorna pautas em Votação + * @param array $filtro + */ + public static function getPautas($filtro = array()) + { + return delibera_get_pautas_em($filtro, 'emvotacao'); + } + + public function savePostMetas($events_meta, $opt) + { + if(array_key_exists('prazo_votacao', $_POST)) + { + $events_meta['prazo_votacao'] = $_POST['prazo_votacao']; + } + + return $events_meta; + } + + public function createPautaAtFront($opt) + { + if (trim($opt['data_fixa_nova_pauta_externa']) != '') { + $prazo_discussao = DateTime::createFromFormat('d/m/Y', $opt['data_fixa_nova_pauta_externa']); + $_POST['prazo_votacao'] = date('d/m/Y', strtotime ('+'.$opt['dias_votacao'].' DAYS', $prazo_discussao->getTimestamp())); + } else { + $_POST['prazo_votacao'] = date('d/m/Y', strtotime ('+'.$opt['dias_votacao'].' DAYS')); + } + } + +} +$DeliberaVote = new DeliberaVote(); + + From f47fd5431499bd8ee0729da0b14a6e21008bfc2b Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Fri, 19 Feb 2016 03:16:58 -0200 Subject: [PATCH 033/435] fix missing } --- delibera_topic.php | 115 ++++++++++++++++++++++----------------------- 1 file changed, 57 insertions(+), 58 deletions(-) diff --git a/delibera_topic.php b/delibera_topic.php index cb51ba6..e9f80a0 100644 --- a/delibera_topic.php +++ b/delibera_topic.php @@ -275,70 +275,69 @@ function delibera_save_post($post_id, $post) - /* ######### START ######### */ - /* ######### FOR PDF UPLOAD FILE ######### */ - // Setup the array of supported file types. In this case, it's just PDF. - $supported_types = array('application/pdf'); - - // Get the file type of the upload - $arr_uploaded_file_type = wp_check_filetype(basename($_FILES['pauta_pdf_contribution']['name'])); - $uploaded_file_type = $arr_uploaded_file_type['type']; - - if (isset ($_FILES['pauta_pdf_contribution']['name']) && $_FILES['pauta_pdf_contribution']['name'] != '') { - if (!in_array($uploaded_file_type, $supported_types)) { - //TODO: Improve this message and avoid wp_die - wp_die("O arquivo para web não é um PDF (formato permitido)."); - } - - - // Use the WordPress API to upload the file - $upload_pauta_pdf = wp_upload_bits($_FILES['pauta_pdf_contribution']['name'], null, file_get_contents($_FILES['pauta_pdf_contribution']['tmp_name'])); - - if (isset($upload_pauta_pdf['error']) && $upload_pauta_pdf['error'] != 0) { - $events_meta['pauta_pdf_contribution'] = none; - wp_die('Erro ao salvar arquivo para Web. O erro foi: ' . $upload_pauta_pdf['error']); - } else { - $events_meta['pauta_pdf_contribution'] = $upload_pauta_pdf['url']; - - global $wpdb; - - $wpdb->query($wpdb->prepare("UPDATE " . $wpdb->prefix . "posts SET post_content=%s WHERE ID=%d", '', $post->ID)); - } - } - /* ######### FOR PDF UPLOAD FILE ######### */ - /* ######### END ######### */ + /* ######### START ######### */ + /* ######### FOR PDF UPLOAD FILE ######### */ + // Setup the array of supported file types. In this case, it's just PDF. + $supported_types = array('application/pdf'); + + // Get the file type of the upload + $arr_uploaded_file_type = wp_check_filetype(basename($_FILES['pauta_pdf_contribution']['name'])); + $uploaded_file_type = $arr_uploaded_file_type['type']; + + if (isset ($_FILES['pauta_pdf_contribution']['name']) && $_FILES['pauta_pdf_contribution']['name'] != '') { + if (!in_array($uploaded_file_type, $supported_types)) { + //TODO: Improve this message and avoid wp_die + wp_die("O arquivo para web não é um PDF (formato permitido)."); + } + + + // Use the WordPress API to upload the file + $upload_pauta_pdf = wp_upload_bits($_FILES['pauta_pdf_contribution']['name'], null, file_get_contents($_FILES['pauta_pdf_contribution']['tmp_name'])); + + if (isset($upload_pauta_pdf['error']) && $upload_pauta_pdf['error'] != 0) { + $events_meta['pauta_pdf_contribution'] = none; + wp_die('Erro ao salvar arquivo para Web. O erro foi: ' . $upload_pauta_pdf['error']); + } else { + $events_meta['pauta_pdf_contribution'] = $upload_pauta_pdf['url']; + + global $wpdb; + + $wpdb->query($wpdb->prepare("UPDATE " . $wpdb->prefix . "posts SET post_content=%s WHERE ID=%d", '', $post->ID)); + } + } + /* ######### FOR PDF UPLOAD FILE ######### */ + /* ######### END ######### */ - $events_meta = apply_filters('delibera_save_post_metas', $events_meta, $opt); - - foreach ($events_meta as $key => $value) // Buscar dados + $events_meta = apply_filters('delibera_save_post_metas', $events_meta, $opt); + + foreach ($events_meta as $key => $value) // Buscar dados + { + if(get_post_meta($post->ID, $key, true)) // Se já existe { - if(get_post_meta($post->ID, $key, true)) // Se já existe - { - update_post_meta($post->ID, $key, $value); // Atualiza - } - else - { - add_post_meta($post->ID, $key, $value, true); // Senão, cria - } + update_post_meta($post->ID, $key, $value); // Atualiza } - - do_action('delibera_save_post', $post_id, $post, $opt); - - if( - array_key_exists('delibera_fim_prazo', $_POST) && - $_POST['delibera_fim_prazo'] == 'S' && - current_user_can('forcar_prazo') - ) - { - delibera_forca_fim_prazo($post->ID); - } - - if($post->post_status == 'publish' && !$autosave) + else { - delibera_del_cron($post->ID); - delibera_publish_pauta($post->ID, $post, true); + add_post_meta($post->ID, $key, $value, true); // Senão, cria } } + + do_action('delibera_save_post', $post_id, $post, $opt); + + if( + array_key_exists('delibera_fim_prazo', $_POST) && + $_POST['delibera_fim_prazo'] == 'S' && + current_user_can('forcar_prazo') + ) + { + delibera_forca_fim_prazo($post->ID); + } + + if($post->post_status == 'publish' && !$autosave) + { + delibera_del_cron($post->ID); + delibera_publish_pauta($post->ID, $post, true); + } } add_action ('save_post', 'delibera_save_post', 1, 2); From b96a83abbe9b7009416acd293aa8d742d5757504 Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Fri, 19 Feb 2016 03:54:35 -0200 Subject: [PATCH 034/435] fix missing s, opt -> opts --- modules/vote/vote.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/vote/vote.php b/modules/vote/vote.php index 6605522..a57f63a 100644 --- a/modules/vote/vote.php +++ b/modules/vote/vote.php @@ -46,7 +46,7 @@ public function registerTax() */ public function getMainConfig($opts) { - $opt['dias_votacao'] = '5'; + $opts['dias_votacao'] = '5'; return $opts; } From 6cacae327dcebf4fdd59d9c426a36e173c3296e0 Mon Sep 17 00:00:00 2001 From: Lucas Pirola Date: Fri, 19 Feb 2016 09:54:11 -0200 Subject: [PATCH 035/435] Add required plugins to enable attchment to comments --- delibera_init.php | 51 +- includes/class-tgm-plugin-activation.php | 3618 ++++++++++++++++++++++ {lang => languages}/delibera-en_US.mo | Bin {lang => languages}/delibera-en_US.po | 0 {lang => languages}/delibera-es_ES.mo | Bin {lang => languages}/delibera-es_ES.po | 0 {lang => languages}/delibera.pot | 0 languages/tgmpa.pot | 458 +++ 8 files changed, 4126 insertions(+), 1 deletion(-) create mode 100755 includes/class-tgm-plugin-activation.php rename {lang => languages}/delibera-en_US.mo (100%) rename {lang => languages}/delibera-en_US.po (100%) rename {lang => languages}/delibera-es_ES.mo (100%) rename {lang => languages}/delibera-es_ES.po (100%) rename {lang => languages}/delibera.pot (100%) create mode 100755 languages/tgmpa.pot diff --git a/delibera_init.php b/delibera_init.php index d2c166c..184f5ea 100644 --- a/delibera_init.php +++ b/delibera_init.php @@ -333,7 +333,7 @@ function delibera_footer() { function delibera_loaded() { // load plugin translations - load_plugin_textdomain('delibera', false, dirname(plugin_basename( __FILE__ )).'/lang'); + load_plugin_textdomain('delibera', false, dirname(plugin_basename( __FILE__ )).'/languages'); } add_action('plugins_loaded','delibera_loaded'); @@ -440,3 +440,52 @@ function delibera_convert_situacao_id_to_taxonomy_term_in_query(&$query) } } add_filter('parse_query','delibera_convert_situacao_id_to_taxonomy_term_in_query'); + +/** + * Include the TGM_Plugin_Activation class. + */ +require_once dirname( __FILE__ ) . '/includes/class-tgm-plugin-activation.php'; + +add_action( 'tgmpa_register', 'delibera_register_required_plugins' ); +/** + * Register the required plugins for this theme. + * + * In this example, we register five plugins: + * - one included with the TGMPA library + * - two from an external source, one from an arbitrary source, one from a GitHub repository + * - two from the .org repo, where one demonstrates the use of the `is_callable` argument + * + * The variable passed to tgmpa_register_plugins() should be an array of plugin + * arrays. + * + * This function is hooked into tgmpa_init, which is fired within the + * TGM_Plugin_Activation class constructor. + */ +function delibera_register_required_plugins() { + /* + * Array of plugin arrays. Required keys are name and slug. + * If the source is NOT from the .org repo, then source is also required. + */ + $plugins = array( + array( + 'name' => 'comment-attachment', + 'slug' => 'comment-attachment', + 'required' => true + ), + ); + + $config = array( + 'id' => 'delibera', // Unique ID for hashing notices for multiple instances of TGMPA. + 'default_path' => '', // Default absolute path to bundled plugins. + 'menu' => 'tgmpa-install-plugins', // Menu slug. + 'parent_slug' => 'plugins.php', // Parent menu slug. + 'capability' => 'manage_options', // Capability needed to view plugin install page, should be a capability associated with the parent menu used. + 'has_notices' => true, // Show admin notices or not. + 'dismissable' => true, // If false, a user cannot dismiss the nag message. + 'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag. + 'is_automatic' => false, // Automatically activate plugins after installation or not. + 'message' => '', // Message to output right before the plugins table. + ); + + tgmpa( $plugins, $config ); +} \ No newline at end of file diff --git a/includes/class-tgm-plugin-activation.php b/includes/class-tgm-plugin-activation.php new file mode 100755 index 0000000..ee6eb73 --- /dev/null +++ b/includes/class-tgm-plugin-activation.php @@ -0,0 +1,3618 @@ +wp_version = $GLOBALS['wp_version']; + + // Announce that the class is ready, and pass the object (for advanced use). + do_action_ref_array( 'tgmpa_init', array( $this ) ); + + // When the rest of WP has loaded, kick-start the rest of the class. + add_action( 'init', array( $this, 'init' ) ); + } + + /** + * Magic method to (not) set protected properties from outside of this class. + * + * @internal hackedihack... There is a serious bug in v2.3.2 - 2.3.6 where the `menu` property + * is being assigned rather than tested in a conditional, effectively rendering it useless. + * This 'hack' prevents this from happening. + * + * @see https://github.com/TGMPA/TGM-Plugin-Activation/blob/2.3.6/tgm-plugin-activation/class-tgm-plugin-activation.php#L1593 + * + * @param string $name Name of an inaccessible property. + * @param mixed $value Value to assign to the property. + * @return void Silently fail to set the property when this is tried from outside of this class context. + * (Inside this class context, the __set() method if not used as there is direct access.) + */ + public function __set( $name, $value ) { + return; + } + + /** + * Magic method to get the value of a protected property outside of this class context. + * + * @param string $name Name of an inaccessible property. + * @return mixed The property value. + */ + public function __get( $name ) { + return $this->{$name}; + } + + /** + * Initialise the interactions between this class and WordPress. + * + * Hooks in three new methods for the class: admin_menu, notices and styles. + * + * @since 2.0.0 + * + * @see TGM_Plugin_Activation::admin_menu() + * @see TGM_Plugin_Activation::notices() + * @see TGM_Plugin_Activation::styles() + */ + public function init() { + /** + * By default TGMPA only loads on the WP back-end and not in an Ajax call. Using this filter + * you can overrule that behaviour. + * + * @since 2.5.0 + * + * @param bool $load Whether or not TGMPA should load. + * Defaults to the return of `is_admin() && ! defined( 'DOING_AJAX' )`. + */ + if ( true !== apply_filters( 'tgmpa_load', ( is_admin() && ! defined( 'DOING_AJAX' ) ) ) ) { + return; + } + + // Load class strings. + $this->strings = array( + 'page_title' => __( 'Install Required Plugins', 'tgmpa' ), + 'menu_title' => __( 'Install Plugins', 'tgmpa' ), + 'installing' => __( 'Installing Plugin: %s', 'tgmpa' ), + 'oops' => __( 'Something went wrong with the plugin API.', 'tgmpa' ), + 'notice_can_install_required' => _n_noop( + 'This theme requires the following plugin: %1$s.', + 'This theme requires the following plugins: %1$s.', + 'tgmpa' + ), + 'notice_can_install_recommended' => _n_noop( + 'This theme recommends the following plugin: %1$s.', + 'This theme recommends the following plugins: %1$s.', + 'tgmpa' + ), + 'notice_cannot_install' => _n_noop( + 'Sorry, but you do not have the correct permissions to install the %1$s plugin.', + 'Sorry, but you do not have the correct permissions to install the %1$s plugins.', + 'tgmpa' + ), + 'notice_ask_to_update' => _n_noop( + 'The following plugin needs to be updated to its latest version to ensure maximum compatibility with this theme: %1$s.', + 'The following plugins need to be updated to their latest version to ensure maximum compatibility with this theme: %1$s.', + 'tgmpa' + ), + 'notice_ask_to_update_maybe' => _n_noop( + 'There is an update available for: %1$s.', + 'There are updates available for the following plugins: %1$s.', + 'tgmpa' + ), + 'notice_cannot_update' => _n_noop( + 'Sorry, but you do not have the correct permissions to update the %1$s plugin.', + 'Sorry, but you do not have the correct permissions to update the %1$s plugins.', + 'tgmpa' + ), + 'notice_can_activate_required' => _n_noop( + 'The following required plugin is currently inactive: %1$s.', + 'The following required plugins are currently inactive: %1$s.', + 'tgmpa' + ), + 'notice_can_activate_recommended' => _n_noop( + 'The following recommended plugin is currently inactive: %1$s.', + 'The following recommended plugins are currently inactive: %1$s.', + 'tgmpa' + ), + 'notice_cannot_activate' => _n_noop( + 'Sorry, but you do not have the correct permissions to activate the %1$s plugin.', + 'Sorry, but you do not have the correct permissions to activate the %1$s plugins.', + 'tgmpa' + ), + 'install_link' => _n_noop( + 'Begin installing plugin', + 'Begin installing plugins', + 'tgmpa' + ), + 'update_link' => _n_noop( + 'Begin updating plugin', + 'Begin updating plugins', + 'tgmpa' + ), + 'activate_link' => _n_noop( + 'Begin activating plugin', + 'Begin activating plugins', + 'tgmpa' + ), + 'return' => __( 'Return to Required Plugins Installer', 'tgmpa' ), + 'dashboard' => __( 'Return to the dashboard', 'tgmpa' ), + 'plugin_activated' => __( 'Plugin activated successfully.', 'tgmpa' ), + 'activated_successfully' => __( 'The following plugin was activated successfully:', 'tgmpa' ), + 'plugin_already_active' => __( 'No action taken. Plugin %1$s was already active.', 'tgmpa' ), + 'plugin_needs_higher_version' => __( 'Plugin not activated. A higher version of %s is needed for this theme. Please update the plugin.', 'tgmpa' ), + 'complete' => __( 'All plugins installed and activated successfully. %1$s', 'tgmpa' ), + 'dismiss' => __( 'Dismiss this notice', 'tgmpa' ), + 'contact_admin' => __( 'Please contact the administrator of this site for help.', 'tgmpa' ), + ); + + do_action( 'tgmpa_register' ); + + /* After this point, the plugins should be registered and the configuration set. */ + + // Proceed only if we have plugins to handle. + if ( empty( $this->plugins ) || ! is_array( $this->plugins ) ) { + return; + } + + // Set up the menu and notices if we still have outstanding actions. + if ( true !== $this->is_tgmpa_complete() ) { + // Sort the plugins. + array_multisort( $this->sort_order, SORT_ASC, $this->plugins ); + + add_action( 'admin_menu', array( $this, 'admin_menu' ) ); + add_action( 'admin_head', array( $this, 'dismiss' ) ); + + // Prevent the normal links from showing underneath a single install/update page. + add_filter( 'install_plugin_complete_actions', array( $this, 'actions' ) ); + add_filter( 'update_plugin_complete_actions', array( $this, 'actions' ) ); + + if ( $this->has_notices ) { + add_action( 'admin_notices', array( $this, 'notices' ) ); + add_action( 'admin_init', array( $this, 'admin_init' ), 1 ); + add_action( 'admin_enqueue_scripts', array( $this, 'thickbox' ) ); + } + + add_action( 'load-plugins.php', array( $this, 'add_plugin_action_link_filters' ), 1 ); + } + + // Make sure things get reset on switch theme. + add_action( 'switch_theme', array( $this, 'flush_plugins_cache' ) ); + + if ( $this->has_notices ) { + add_action( 'switch_theme', array( $this, 'update_dismiss' ) ); + } + + // Setup the force activation hook. + if ( true === $this->has_forced_activation ) { + add_action( 'admin_init', array( $this, 'force_activation' ) ); + } + + // Setup the force deactivation hook. + if ( true === $this->has_forced_deactivation ) { + add_action( 'switch_theme', array( $this, 'force_deactivation' ) ); + } + } + + /** + * Prevent activation of plugins which don't meet the minimum version requirement from the + * WP native plugins page. + * + * @since 2.5.0 + */ + public function add_plugin_action_link_filters() { + foreach ( $this->plugins as $slug => $plugin ) { + if ( false === $this->can_plugin_activate( $slug ) ) { + add_filter( 'plugin_action_links_' . $plugin['file_path'], array( $this, 'filter_plugin_action_links_activate' ), 20 ); + } + + if ( true === $plugin['force_activation'] ) { + add_filter( 'plugin_action_links_' . $plugin['file_path'], array( $this, 'filter_plugin_action_links_deactivate' ), 20 ); + } + + if ( false !== $this->does_plugin_require_update( $slug ) ) { + add_filter( 'plugin_action_links_' . $plugin['file_path'], array( $this, 'filter_plugin_action_links_update' ), 20 ); + } + } + } + + /** + * Remove the 'Activate' link on the WP native plugins page if the plugin does not meet the + * minimum version requirements. + * + * @since 2.5.0 + * + * @param array $actions Action links. + * @return array + */ + public function filter_plugin_action_links_activate( $actions ) { + unset( $actions['activate'] ); + + return $actions; + } + + /** + * Remove the 'Deactivate' link on the WP native plugins page if the plugin has been set to force activate. + * + * @since 2.5.0 + * + * @param array $actions Action links. + * @return array + */ + public function filter_plugin_action_links_deactivate( $actions ) { + unset( $actions['deactivate'] ); + + return $actions; + } + + /** + * Add a 'Requires update' link on the WP native plugins page if the plugin does not meet the + * minimum version requirements. + * + * @since 2.5.0 + * + * @param array $actions Action links. + * @return array + */ + public function filter_plugin_action_links_update( $actions ) { + $actions['update'] = sprintf( + '%3$s', + esc_url( $this->get_tgmpa_status_url( 'update' ) ), + esc_attr__( 'This plugin needs to be updated to be compatible with your theme.', 'tgmpa' ), + esc_html__( 'Update Required', 'tgmpa' ) + ); + + return $actions; + } + + /** + * Handles calls to show plugin information via links in the notices. + * + * We get the links in the admin notices to point to the TGMPA page, rather + * than the typical plugin-install.php file, so we can prepare everything + * beforehand. + * + * WP does not make it easy to show the plugin information in the thickbox - + * here we have to require a file that includes a function that does the + * main work of displaying it, enqueue some styles, set up some globals and + * finally call that function before exiting. + * + * Down right easy once you know how... + * + * Returns early if not the TGMPA page. + * + * @since 2.1.0 + * + * @global string $tab Used as iframe div class names, helps with styling + * @global string $body_id Used as the iframe body ID, helps with styling + * + * @return null Returns early if not the TGMPA page. + */ + public function admin_init() { + if ( ! $this->is_tgmpa_page() ) { + return; + } + + if ( isset( $_REQUEST['tab'] ) && 'plugin-information' === $_REQUEST['tab'] ) { + // Needed for install_plugin_information(). + require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; + + wp_enqueue_style( 'plugin-install' ); + + global $tab, $body_id; + $body_id = 'plugin-information'; + // @codingStandardsIgnoreStart + $tab = 'plugin-information'; + // @codingStandardsIgnoreEnd + + install_plugin_information(); + + exit; + } + } + + /** + * Enqueue thickbox scripts/styles for plugin info. + * + * Thickbox is not automatically included on all admin pages, so we must + * manually enqueue it for those pages. + * + * Thickbox is only loaded if the user has not dismissed the admin + * notice or if there are any plugins left to install and activate. + * + * @since 2.1.0 + */ + public function thickbox() { + if ( ! get_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_' . $this->id, true ) ) { + add_thickbox(); + } + } + + /** + * Adds submenu page if there are plugin actions to take. + * + * This method adds the submenu page letting users know that a required + * plugin needs to be installed. + * + * This page disappears once the plugin has been installed and activated. + * + * @since 1.0.0 + * + * @see TGM_Plugin_Activation::init() + * @see TGM_Plugin_Activation::install_plugins_page() + * + * @return null Return early if user lacks capability to install a plugin. + */ + public function admin_menu() { + // Make sure privileges are correct to see the page. + if ( ! current_user_can( 'install_plugins' ) ) { + return; + } + + $args = apply_filters( + 'tgmpa_admin_menu_args', + array( + 'parent_slug' => $this->parent_slug, // Parent Menu slug. + 'page_title' => $this->strings['page_title'], // Page title. + 'menu_title' => $this->strings['menu_title'], // Menu title. + 'capability' => $this->capability, // Capability. + 'menu_slug' => $this->menu, // Menu slug. + 'function' => array( $this, 'install_plugins_page' ), // Callback. + ) + ); + + $this->add_admin_menu( $args ); + } + + /** + * Add the menu item. + * + * @since 2.5.0 + * + * @param array $args Menu item configuration. + */ + protected function add_admin_menu( array $args ) { + if ( has_filter( 'tgmpa_admin_menu_use_add_theme_page' ) ) { + _deprecated_function( 'The "tgmpa_admin_menu_use_add_theme_page" filter', '2.5.0', esc_html__( 'Set the parent_slug config variable instead.', 'tgmpa' ) ); + } + + if ( 'themes.php' === $this->parent_slug ) { + $this->page_hook = call_user_func( 'add_theme_page', $args['page_title'], $args['menu_title'], $args['capability'], $args['menu_slug'], $args['function'] ); + } else { + $this->page_hook = call_user_func( 'add_submenu_page', $args['parent_slug'], $args['page_title'], $args['menu_title'], $args['capability'], $args['menu_slug'], $args['function'] ); + } + } + + /** + * Echoes plugin installation form. + * + * This method is the callback for the admin_menu method function. + * This displays the admin page and form area where the user can select to install and activate the plugin. + * Aborts early if we're processing a plugin installation action. + * + * @since 1.0.0 + * + * @return null Aborts early if we're processing a plugin installation action. + */ + public function install_plugins_page() { + // Store new instance of plugin table in object. + $plugin_table = new TGMPA_List_Table; + + // Return early if processing a plugin installation action. + if ( ( ( 'tgmpa-bulk-install' === $plugin_table->current_action() || 'tgmpa-bulk-update' === $plugin_table->current_action() ) && $plugin_table->process_bulk_actions() ) || $this->do_plugin_install() ) { + return; + } + + // Force refresh of available plugin information so we'll know about manual updates/deletes. + wp_clean_plugins_cache( false ); + + ?> +
+

+ prepare_items(); ?> + + message ) && is_string( $this->message ) ) { + echo wp_kses_post( $this->message ); + } + ?> + views(); ?> + +
+ + + display(); ?> +
+
+ sanitize_key( urldecode( $_GET['plugin'] ) ); + + if ( ! isset( $this->plugins[ $slug ] ) ) { + return false; + } + + // Was an install or upgrade action link clicked? + if ( ( isset( $_GET['tgmpa-install'] ) && 'install-plugin' === $_GET['tgmpa-install'] ) || ( isset( $_GET['tgmpa-update'] ) && 'update-plugin' === $_GET['tgmpa-update'] ) ) { + + $install_type = 'install'; + if ( isset( $_GET['tgmpa-update'] ) && 'update-plugin' === $_GET['tgmpa-update'] ) { + $install_type = 'update'; + } + + check_admin_referer( 'tgmpa-' . $install_type, 'tgmpa-nonce' ); + + // Pass necessary information via URL if WP_Filesystem is needed. + $url = wp_nonce_url( + add_query_arg( + array( + 'plugin' => urlencode( $slug ), + 'tgmpa-' . $install_type => $install_type . '-plugin', + ), + $this->get_tgmpa_url() + ), + 'tgmpa-' . $install_type, + 'tgmpa-nonce' + ); + + $method = ''; // Leave blank so WP_Filesystem can populate it as necessary. + + if ( false === ( $creds = request_filesystem_credentials( esc_url_raw( $url ), $method, false, false, array() ) ) ) { + return true; + } + + if ( ! WP_Filesystem( $creds ) ) { + request_filesystem_credentials( esc_url_raw( $url ), $method, true, false, array() ); // Setup WP_Filesystem. + return true; + } + + /* If we arrive here, we have the filesystem. */ + + // Prep variables for Plugin_Installer_Skin class. + $extra = array(); + $extra['slug'] = $slug; // Needed for potentially renaming of directory name. + $source = $this->get_download_url( $slug ); + $api = ( 'repo' === $this->plugins[ $slug ]['source_type'] ) ? $this->get_plugins_api( $slug ) : null; + $api = ( false !== $api ) ? $api : null; + + $url = add_query_arg( + array( + 'action' => $install_type . '-plugin', + 'plugin' => urlencode( $slug ), + ), + 'update.php' + ); + + if ( ! class_exists( 'Plugin_Upgrader', false ) ) { + require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; + } + + $skin_args = array( + 'type' => ( 'bundled' !== $this->plugins[ $slug ]['source_type'] ) ? 'web' : 'upload', + 'title' => sprintf( $this->strings['installing'], $this->plugins[ $slug ]['name'] ), + 'url' => esc_url_raw( $url ), + 'nonce' => $install_type . '-plugin_' . $slug, + 'plugin' => '', + 'api' => $api, + 'extra' => $extra, + ); + + if ( 'update' === $install_type ) { + $skin_args['plugin'] = $this->plugins[ $slug ]['file_path']; + $skin = new Plugin_Upgrader_Skin( $skin_args ); + } else { + $skin = new Plugin_Installer_Skin( $skin_args ); + } + + // Create a new instance of Plugin_Upgrader. + $upgrader = new Plugin_Upgrader( $skin ); + + // Perform the action and install the plugin from the $source urldecode(). + add_filter( 'upgrader_source_selection', array( $this, 'maybe_adjust_source_dir' ), 1, 3 ); + + if ( 'update' === $install_type ) { + // Inject our info into the update transient. + $to_inject = array( $slug => $this->plugins[ $slug ] ); + $to_inject[ $slug ]['source'] = $source; + $this->inject_update_info( $to_inject ); + + $upgrader->upgrade( $this->plugins[ $slug ]['file_path'] ); + } else { + $upgrader->install( $source ); + } + + remove_filter( 'upgrader_source_selection', array( $this, 'maybe_adjust_source_dir' ), 1, 3 ); + + // Make sure we have the correct file path now the plugin is installed/updated. + $this->populate_file_path( $slug ); + + // Only activate plugins if the config option is set to true and the plugin isn't + // already active (upgrade). + if ( $this->is_automatic && ! $this->is_plugin_active( $slug ) ) { + $plugin_activate = $upgrader->plugin_info(); // Grab the plugin info from the Plugin_Upgrader method. + if ( false === $this->activate_single_plugin( $plugin_activate, $slug, true ) ) { + return true; // Finish execution of the function early as we encountered an error. + } + } + + $this->show_tgmpa_version(); + + // Display message based on if all plugins are now active or not. + if ( $this->is_tgmpa_complete() ) { + echo '

', sprintf( esc_html( $this->strings['complete'] ), '' . esc_html__( 'Return to the Dashboard', 'tgmpa' ) . '' ), '

'; + echo ''; + } else { + echo '

', esc_html( $this->strings['return'] ), '

'; + } + + return true; + } elseif ( isset( $this->plugins[ $slug ]['file_path'], $_GET['tgmpa-activate'] ) && 'activate-plugin' === $_GET['tgmpa-activate'] ) { + // Activate action link was clicked. + check_admin_referer( 'tgmpa-activate', 'tgmpa-nonce' ); + + if ( false === $this->activate_single_plugin( $this->plugins[ $slug ]['file_path'], $slug ) ) { + return true; // Finish execution of the function early as we encountered an error. + } + } + + return false; + } + + /** + * Inject information into the 'update_plugins' site transient as WP checks that before running an update. + * + * @since 2.5.0 + * + * @param array $plugins The plugin information for the plugins which are to be updated. + */ + public function inject_update_info( $plugins ) { + $repo_updates = get_site_transient( 'update_plugins' ); + + if ( ! is_object( $repo_updates ) ) { + $repo_updates = new stdClass; + } + + foreach ( $plugins as $slug => $plugin ) { + $file_path = $plugin['file_path']; + + if ( empty( $repo_updates->response[ $file_path ] ) ) { + $repo_updates->response[ $file_path ] = new stdClass; + } + + // We only really need to set package, but let's do all we can in case WP changes something. + $repo_updates->response[ $file_path ]->slug = $slug; + $repo_updates->response[ $file_path ]->plugin = $file_path; + $repo_updates->response[ $file_path ]->new_version = $plugin['version']; + $repo_updates->response[ $file_path ]->package = $plugin['source']; + if ( empty( $repo_updates->response[ $file_path ]->url ) && ! empty( $plugin['external_url'] ) ) { + $repo_updates->response[ $file_path ]->url = $plugin['external_url']; + } + } + + set_site_transient( 'update_plugins', $repo_updates ); + } + + /** + * Adjust the plugin directory name if necessary. + * + * The final destination directory of a plugin is based on the subdirectory name found in the + * (un)zipped source. In some cases - most notably GitHub repository plugin downloads -, this + * subdirectory name is not the same as the expected slug and the plugin will not be recognized + * as installed. This is fixed by adjusting the temporary unzipped source subdirectory name to + * the expected plugin slug. + * + * @since 2.5.0 + * + * @param string $source Path to upgrade/zip-file-name.tmp/subdirectory/. + * @param string $remote_source Path to upgrade/zip-file-name.tmp. + * @param \WP_Upgrader $upgrader Instance of the upgrader which installs the plugin. + * @return string $source + */ + public function maybe_adjust_source_dir( $source, $remote_source, $upgrader ) { + if ( ! $this->is_tgmpa_page() || ! is_object( $GLOBALS['wp_filesystem'] ) ) { + return $source; + } + + // Check for single file plugins. + $source_files = array_keys( $GLOBALS['wp_filesystem']->dirlist( $remote_source ) ); + if ( 1 === count( $source_files ) && false === $GLOBALS['wp_filesystem']->is_dir( $source ) ) { + return $source; + } + + // Multi-file plugin, let's see if the directory is correctly named. + $desired_slug = ''; + + // Figure out what the slug is supposed to be. + if ( false === $upgrader->bulk && ! empty( $upgrader->skin->options['extra']['slug'] ) ) { + $desired_slug = $upgrader->skin->options['extra']['slug']; + } else { + // Bulk installer contains less info, so fall back on the info registered here. + foreach ( $this->plugins as $slug => $plugin ) { + if ( ! empty( $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) && $plugin['name'] === $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) { + $desired_slug = $slug; + break; + } + } + unset( $slug, $plugin ); + } + + if ( ! empty( $desired_slug ) ) { + $subdir_name = untrailingslashit( str_replace( trailingslashit( $remote_source ), '', $source ) ); + + if ( ! empty( $subdir_name ) && $subdir_name !== $desired_slug ) { + $from = untrailingslashit( $source ); + $to = trailingslashit( $remote_source ) . $desired_slug; + + if ( true === $GLOBALS['wp_filesystem']->move( $from, $to ) ) { + return trailingslashit( $to ); + } else { + return new WP_Error( 'rename_failed', esc_html__( 'The remote plugin package does not contain a folder with the desired slug and renaming did not work.', 'tgmpa' ) . ' ' . esc_html__( 'Please contact the plugin provider and ask them to package their plugin according to the WordPress guidelines.', 'tgmpa' ), array( 'found' => $subdir_name, 'expected' => $desired_slug ) ); + } + } elseif ( empty( $subdir_name ) ) { + return new WP_Error( 'packaged_wrong', esc_html__( 'The remote plugin package consists of more than one file, but the files are not packaged in a folder.', 'tgmpa' ) . ' ' . esc_html__( 'Please contact the plugin provider and ask them to package their plugin according to the WordPress guidelines.', 'tgmpa' ), array( 'found' => $subdir_name, 'expected' => $desired_slug ) ); + } + } + + return $source; + } + + /** + * Activate a single plugin and send feedback about the result to the screen. + * + * @since 2.5.0 + * + * @param string $file_path Path within wp-plugins/ to main plugin file. + * @param string $slug Plugin slug. + * @param bool $automatic Whether this is an automatic activation after an install. Defaults to false. + * This determines the styling of the output messages. + * @return bool False if an error was encountered, true otherwise. + */ + protected function activate_single_plugin( $file_path, $slug, $automatic = false ) { + if ( $this->can_plugin_activate( $slug ) ) { + $activate = activate_plugin( $file_path ); + + if ( is_wp_error( $activate ) ) { + echo '

', wp_kses_post( $activate->get_error_message() ), '

', + '

', esc_html( $this->strings['return'] ), '

'; + + return false; // End it here if there is an error with activation. + } else { + if ( ! $automatic ) { + // Make sure message doesn't display again if bulk activation is performed + // immediately after a single activation. + if ( ! isset( $_POST['action'] ) ) { // WPCS: CSRF OK. + echo '

', esc_html( $this->strings['activated_successfully'] ), ' ', esc_html( $this->plugins[ $slug ]['name'] ), '.

'; + } + } else { + // Simpler message layout for use on the plugin install page. + echo '

', esc_html( $this->strings['plugin_activated'] ), '

'; + } + } + } elseif ( $this->is_plugin_active( $slug ) ) { + // No simpler message format provided as this message should never be encountered + // on the plugin install page. + echo '

', + sprintf( + esc_html( $this->strings['plugin_already_active'] ), + '' . esc_html( $this->plugins[ $slug ]['name'] ) . '' + ), + '

'; + } elseif ( $this->does_plugin_require_update( $slug ) ) { + if ( ! $automatic ) { + // Make sure message doesn't display again if bulk activation is performed + // immediately after a single activation. + if ( ! isset( $_POST['action'] ) ) { // WPCS: CSRF OK. + echo '

', + sprintf( + esc_html( $this->strings['plugin_needs_higher_version'] ), + '' . esc_html( $this->plugins[ $slug ]['name'] ) . '' + ), + '

'; + } + } else { + // Simpler message layout for use on the plugin install page. + echo '

', sprintf( esc_html( $this->strings['plugin_needs_higher_version'] ), esc_html( $this->plugins[ $slug ]['name'] ) ), '

'; + } + } + + return true; + } + + /** + * Echoes required plugin notice. + * + * Outputs a message telling users that a specific plugin is required for + * their theme. If appropriate, it includes a link to the form page where + * users can install and activate the plugin. + * + * Returns early if we're on the Install page. + * + * @since 1.0.0 + * + * @global object $current_screen + * + * @return null Returns early if we're on the Install page. + */ + public function notices() { + // Remove nag on the install page / Return early if the nag message has been dismissed. + if ( $this->is_tgmpa_page() || get_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_' . $this->id, true ) ) { + return; + } + + // Store for the plugin slugs by message type. + $message = array(); + + // Initialize counters used to determine plurality of action link texts. + $install_link_count = 0; + $update_link_count = 0; + $activate_link_count = 0; + + foreach ( $this->plugins as $slug => $plugin ) { + if ( $this->is_plugin_active( $slug ) && false === $this->does_plugin_have_update( $slug ) ) { + continue; + } + + if ( ! $this->is_plugin_installed( $slug ) ) { + if ( current_user_can( 'install_plugins' ) ) { + $install_link_count++; + + if ( true === $plugin['required'] ) { + $message['notice_can_install_required'][] = $slug; + } else { + $message['notice_can_install_recommended'][] = $slug; + } + } else { + // Need higher privileges to install the plugin. + $message['notice_cannot_install'][] = $slug; + } + } else { + if ( ! $this->is_plugin_active( $slug ) && $this->can_plugin_activate( $slug ) ) { + if ( current_user_can( 'activate_plugins' ) ) { + $activate_link_count++; + + if ( true === $plugin['required'] ) { + $message['notice_can_activate_required'][] = $slug; + } else { + $message['notice_can_activate_recommended'][] = $slug; + } + } else { + // Need higher privileges to activate the plugin. + $message['notice_cannot_activate'][] = $slug; + } + } + + if ( $this->does_plugin_require_update( $slug ) || false !== $this->does_plugin_have_update( $slug ) ) { + + if ( current_user_can( 'install_plugins' ) ) { + $update_link_count++; + + if ( $this->does_plugin_require_update( $slug ) ) { + $message['notice_ask_to_update'][] = $slug; + } elseif ( false !== $this->does_plugin_have_update( $slug ) ) { + $message['notice_ask_to_update_maybe'][] = $slug; + } + } else { + // Need higher privileges to update the plugin. + $message['notice_cannot_update'][] = $slug; + } + } + } + } + unset( $slug, $plugin ); + + // If we have notices to display, we move forward. + if ( ! empty( $message ) ) { + krsort( $message ); // Sort messages. + $rendered = ''; + + // As add_settings_error() wraps the final message in a

and as the final message can't be + // filtered, using

's in our html would render invalid html output. + $line_template = '%s' . "\n"; + + // If dismissable is false and a message is set, output it now. + if ( ! $this->dismissable && ! empty( $this->dismiss_msg ) ) { + $rendered .= sprintf( $line_template, wp_kses_post( $this->dismiss_msg ) ); + } + + // Render the individual message lines for the notice. + foreach ( $message as $type => $plugin_group ) { + $linked_plugins = array(); + + // Get the external info link for a plugin if one is available. + foreach ( $plugin_group as $plugin_slug ) { + $linked_plugins[] = $this->get_info_link( $plugin_slug ); + } + unset( $plugin_slug ); + + $count = count( $plugin_group ); + $linked_plugins = array_map( array( 'TGMPA_Utils', 'wrap_in_em' ), $linked_plugins ); + $last_plugin = array_pop( $linked_plugins ); // Pop off last name to prep for readability. + $imploded = empty( $linked_plugins ) ? $last_plugin : ( implode( ', ', $linked_plugins ) . ' ' . esc_html_x( 'and', 'plugin A *and* plugin B', 'tgmpa' ) . ' ' . $last_plugin ); + + $rendered .= sprintf( + $line_template, + sprintf( + translate_nooped_plural( $this->strings[ $type ], $count, 'tgmpa' ), + $imploded, + $count + ) + ); + + if ( 0 === strpos( $type, 'notice_cannot' ) ) { + $rendered .= $this->strings['contact_admin']; + } + } + unset( $type, $plugin_group, $linked_plugins, $count, $last_plugin, $imploded ); + + // Setup action links. + $action_links = array( + 'install' => '', + 'update' => '', + 'activate' => '', + 'dismiss' => $this->dismissable ? '' . esc_html( $this->strings['dismiss'] ) . '' : '', + ); + + $link_template = '%1$s'; + + if ( current_user_can( 'install_plugins' ) ) { + if ( $install_link_count > 0 ) { + $action_links['install'] = sprintf( + $link_template, + translate_nooped_plural( $this->strings['install_link'], $install_link_count, 'tgmpa' ), + esc_url( $this->get_tgmpa_status_url( 'install' ) ) + ); + } + if ( $update_link_count > 0 ) { + $action_links['update'] = sprintf( + $link_template, + translate_nooped_plural( $this->strings['update_link'], $update_link_count, 'tgmpa' ), + esc_url( $this->get_tgmpa_status_url( 'update' ) ) + ); + } + } + + if ( current_user_can( 'activate_plugins' ) && $activate_link_count > 0 ) { + $action_links['activate'] = sprintf( + $link_template, + translate_nooped_plural( $this->strings['activate_link'], $activate_link_count, 'tgmpa' ), + esc_url( $this->get_tgmpa_status_url( 'activate' ) ) + ); + } + + $action_links = apply_filters( 'tgmpa_notice_action_links', $action_links ); + + $action_links = array_filter( (array) $action_links ); // Remove any empty array items. + + if ( ! empty( $action_links ) && is_array( $action_links ) ) { + $action_links = sprintf( $line_template, implode( ' | ', $action_links ) ); + $rendered .= apply_filters( 'tgmpa_notice_rendered_action_links', $action_links ); + } + + // Register the nag messages and prepare them to be processed. + if ( ! empty( $this->strings['nag_type'] ) ) { + add_settings_error( 'tgmpa', 'tgmpa', $rendered, sanitize_html_class( strtolower( $this->strings['nag_type'] ) ) ); + } else { + $nag_class = version_compare( $this->wp_version, '3.8', '<' ) ? 'updated' : 'update-nag'; + add_settings_error( 'tgmpa', 'tgmpa', $rendered, $nag_class ); + } + } + + // Admin options pages already output settings_errors, so this is to avoid duplication. + if ( 'options-general' !== $GLOBALS['current_screen']->parent_base ) { + $this->display_settings_errors(); + } + } + + /** + * Display settings errors and remove those which have been displayed to avoid duplicate messages showing + * + * @since 2.5.0 + */ + protected function display_settings_errors() { + global $wp_settings_errors; + + settings_errors( 'tgmpa' ); + + foreach ( (array) $wp_settings_errors as $key => $details ) { + if ( 'tgmpa' === $details['setting'] ) { + unset( $wp_settings_errors[ $key ] ); + break; + } + } + } + + /** + * Add dismissable admin notices. + * + * Appends a link to the admin nag messages. If clicked, the admin notice disappears and no longer is visible to users. + * + * @since 2.1.0 + */ + public function dismiss() { + if ( isset( $_GET['tgmpa-dismiss'] ) ) { + update_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_' . $this->id, 1 ); + } + } + + /** + * Add individual plugin to our collection of plugins. + * + * If the required keys are not set or the plugin has already + * been registered, the plugin is not added. + * + * @since 2.0.0 + * + * @param array|null $plugin Array of plugin arguments or null if invalid argument. + * @return null Return early if incorrect argument. + */ + public function register( $plugin ) { + if ( empty( $plugin['slug'] ) || empty( $plugin['name'] ) ) { + return; + } + + if ( empty( $plugin['slug'] ) || ! is_string( $plugin['slug'] ) || isset( $this->plugins[ $plugin['slug'] ] ) ) { + return; + } + + $defaults = array( + 'name' => '', // String + 'slug' => '', // String + 'source' => 'repo', // String + 'required' => false, // Boolean + 'version' => '', // String + 'force_activation' => false, // Boolean + 'force_deactivation' => false, // Boolean + 'external_url' => '', // String + 'is_callable' => '', // String|Array. + ); + + // Prepare the received data. + $plugin = wp_parse_args( $plugin, $defaults ); + + // Standardize the received slug. + $plugin['slug'] = $this->sanitize_key( $plugin['slug'] ); + + // Forgive users for using string versions of booleans or floats for version number. + $plugin['version'] = (string) $plugin['version']; + $plugin['source'] = empty( $plugin['source'] ) ? 'repo' : $plugin['source']; + $plugin['required'] = TGMPA_Utils::validate_bool( $plugin['required'] ); + $plugin['force_activation'] = TGMPA_Utils::validate_bool( $plugin['force_activation'] ); + $plugin['force_deactivation'] = TGMPA_Utils::validate_bool( $plugin['force_deactivation'] ); + + // Enrich the received data. + $plugin['file_path'] = $this->_get_plugin_basename_from_slug( $plugin['slug'] ); + $plugin['source_type'] = $this->get_plugin_source_type( $plugin['source'] ); + + // Set the class properties. + $this->plugins[ $plugin['slug'] ] = $plugin; + $this->sort_order[ $plugin['slug'] ] = $plugin['name']; + + // Should we add the force activation hook ? + if ( true === $plugin['force_activation'] ) { + $this->has_forced_activation = true; + } + + // Should we add the force deactivation hook ? + if ( true === $plugin['force_deactivation'] ) { + $this->has_forced_deactivation = true; + } + } + + /** + * Determine what type of source the plugin comes from. + * + * @since 2.5.0 + * + * @param string $source The source of the plugin as provided, either empty (= WP repo), a file path + * (= bundled) or an external URL. + * @return string 'repo', 'external', or 'bundled' + */ + protected function get_plugin_source_type( $source ) { + if ( 'repo' === $source || preg_match( self::WP_REPO_REGEX, $source ) ) { + return 'repo'; + } elseif ( preg_match( self::IS_URL_REGEX, $source ) ) { + return 'external'; + } else { + return 'bundled'; + } + } + + /** + * Sanitizes a string key. + * + * Near duplicate of WP Core `sanitize_key()`. The difference is that uppercase characters *are* + * allowed, so as not to break upgrade paths from non-standard bundled plugins using uppercase + * characters in the plugin directory path/slug. Silly them. + * + * @see https://developer.wordpress.org/reference/hooks/sanitize_key/ + * + * @since 2.5.0 + * + * @param string $key String key. + * @return string Sanitized key + */ + public function sanitize_key( $key ) { + $raw_key = $key; + $key = preg_replace( '`[^A-Za-z0-9_-]`', '', $key ); + + /** + * Filter a sanitized key string. + * + * @since 3.0.0 + * + * @param string $key Sanitized key. + * @param string $raw_key The key prior to sanitization. + */ + return apply_filters( 'tgmpa_sanitize_key', $key, $raw_key ); + } + + /** + * Amend default configuration settings. + * + * @since 2.0.0 + * + * @param array $config Array of config options to pass as class properties. + */ + public function config( $config ) { + $keys = array( + 'id', + 'default_path', + 'has_notices', + 'dismissable', + 'dismiss_msg', + 'menu', + 'parent_slug', + 'capability', + 'is_automatic', + 'message', + 'strings', + ); + + foreach ( $keys as $key ) { + if ( isset( $config[ $key ] ) ) { + if ( is_array( $config[ $key ] ) ) { + $this->$key = array_merge( $this->$key, $config[ $key ] ); + } else { + $this->$key = $config[ $key ]; + } + } + } + } + + /** + * Amend action link after plugin installation. + * + * @since 2.0.0 + * + * @param array $install_actions Existing array of actions. + * @return array Amended array of actions. + */ + public function actions( $install_actions ) { + // Remove action links on the TGMPA install page. + if ( $this->is_tgmpa_page() ) { + return false; + } + + return $install_actions; + } + + /** + * Flushes the plugins cache on theme switch to prevent stale entries + * from remaining in the plugin table. + * + * @since 2.4.0 + * + * @param bool $clear_update_cache Optional. Whether to clear the Plugin updates cache. + * Parameter added in v2.5.0. + */ + public function flush_plugins_cache( $clear_update_cache = true ) { + wp_clean_plugins_cache( $clear_update_cache ); + } + + /** + * Set file_path key for each installed plugin. + * + * @since 2.1.0 + * + * @param string $plugin_slug Optional. If set, only (re-)populates the file path for that specific plugin. + * Parameter added in v2.5.0. + */ + public function populate_file_path( $plugin_slug = '' ) { + if ( ! empty( $plugin_slug ) && is_string( $plugin_slug ) && isset( $this->plugins[ $plugin_slug ] ) ) { + $this->plugins[ $plugin_slug ]['file_path'] = $this->_get_plugin_basename_from_slug( $plugin_slug ); + } else { + // Add file_path key for all plugins. + foreach ( $this->plugins as $slug => $values ) { + $this->plugins[ $slug ]['file_path'] = $this->_get_plugin_basename_from_slug( $slug ); + } + } + } + + /** + * Helper function to extract the file path of the plugin file from the + * plugin slug, if the plugin is installed. + * + * @since 2.0.0 + * + * @param string $slug Plugin slug (typically folder name) as provided by the developer. + * @return string Either file path for plugin if installed, or just the plugin slug. + */ + protected function _get_plugin_basename_from_slug( $slug ) { + $keys = array_keys( $this->get_plugins() ); + + foreach ( $keys as $key ) { + if ( preg_match( '|^' . $slug . '/|', $key ) ) { + return $key; + } + } + + return $slug; + } + + /** + * Retrieve plugin data, given the plugin name. + * + * Loops through the registered plugins looking for $name. If it finds it, + * it returns the $data from that plugin. Otherwise, returns false. + * + * @since 2.1.0 + * + * @param string $name Name of the plugin, as it was registered. + * @param string $data Optional. Array key of plugin data to return. Default is slug. + * @return string|boolean Plugin slug if found, false otherwise. + */ + public function _get_plugin_data_from_name( $name, $data = 'slug' ) { + foreach ( $this->plugins as $values ) { + if ( $name === $values['name'] && isset( $values[ $data ] ) ) { + return $values[ $data ]; + } + } + + return false; + } + + /** + * Retrieve the download URL for a package. + * + * @since 2.5.0 + * + * @param string $slug Plugin slug. + * @return string Plugin download URL or path to local file or empty string if undetermined. + */ + public function get_download_url( $slug ) { + $dl_source = ''; + + switch ( $this->plugins[ $slug ]['source_type'] ) { + case 'repo': + return $this->get_wp_repo_download_url( $slug ); + case 'external': + return $this->plugins[ $slug ]['source']; + case 'bundled': + return $this->default_path . $this->plugins[ $slug ]['source']; + } + + return $dl_source; // Should never happen. + } + + /** + * Retrieve the download URL for a WP repo package. + * + * @since 2.5.0 + * + * @param string $slug Plugin slug. + * @return string Plugin download URL. + */ + protected function get_wp_repo_download_url( $slug ) { + $source = ''; + $api = $this->get_plugins_api( $slug ); + + if ( false !== $api && isset( $api->download_link ) ) { + $source = $api->download_link; + } + + return $source; + } + + /** + * Try to grab information from WordPress API. + * + * @since 2.5.0 + * + * @param string $slug Plugin slug. + * @return object Plugins_api response object on success, WP_Error on failure. + */ + protected function get_plugins_api( $slug ) { + static $api = array(); // Cache received responses. + + if ( ! isset( $api[ $slug ] ) ) { + if ( ! function_exists( 'plugins_api' ) ) { + require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; + } + + $response = plugins_api( 'plugin_information', array( 'slug' => $slug, 'fields' => array( 'sections' => false ) ) ); + + $api[ $slug ] = false; + + if ( is_wp_error( $response ) ) { + wp_die( esc_html( $this->strings['oops'] ) ); + } else { + $api[ $slug ] = $response; + } + } + + return $api[ $slug ]; + } + + /** + * Retrieve a link to a plugin information page. + * + * @since 2.5.0 + * + * @param string $slug Plugin slug. + * @return string Fully formed html link to a plugin information page if available + * or the plugin name if not. + */ + public function get_info_link( $slug ) { + if ( ! empty( $this->plugins[ $slug ]['external_url'] ) && preg_match( self::IS_URL_REGEX, $this->plugins[ $slug ]['external_url'] ) ) { + $link = sprintf( + '%2$s', + esc_url( $this->plugins[ $slug ]['external_url'] ), + esc_html( $this->plugins[ $slug ]['name'] ) + ); + } elseif ( 'repo' === $this->plugins[ $slug ]['source_type'] ) { + $url = add_query_arg( + array( + 'tab' => 'plugin-information', + 'plugin' => urlencode( $slug ), + 'TB_iframe' => 'true', + 'width' => '640', + 'height' => '500', + ), + self_admin_url( 'plugin-install.php' ) + ); + + $link = sprintf( + '%2$s', + esc_url( $url ), + esc_html( $this->plugins[ $slug ]['name'] ) + ); + } else { + $link = esc_html( $this->plugins[ $slug ]['name'] ); // No hyperlink. + } + + return $link; + } + + /** + * Determine if we're on the TGMPA Install page. + * + * @since 2.1.0 + * + * @return boolean True when on the TGMPA page, false otherwise. + */ + protected function is_tgmpa_page() { + return isset( $_GET['page'] ) && $this->menu === $_GET['page']; + } + + /** + * Retrieve the URL to the TGMPA Install page. + * + * I.e. depending on the config settings passed something along the lines of: + * http://example.com/wp-admin/themes.php?page=tgmpa-install-plugins + * + * @since 2.5.0 + * + * @return string Properly encoded URL (not escaped). + */ + public function get_tgmpa_url() { + static $url; + + if ( ! isset( $url ) ) { + $parent = $this->parent_slug; + if ( false === strpos( $parent, '.php' ) ) { + $parent = 'admin.php'; + } + $url = add_query_arg( + array( + 'page' => urlencode( $this->menu ), + ), + self_admin_url( $parent ) + ); + } + + return $url; + } + + /** + * Retrieve the URL to the TGMPA Install page for a specific plugin status (view). + * + * I.e. depending on the config settings passed something along the lines of: + * http://example.com/wp-admin/themes.php?page=tgmpa-install-plugins&plugin_status=install + * + * @since 2.5.0 + * + * @param string $status Plugin status - either 'install', 'update' or 'activate'. + * @return string Properly encoded URL (not escaped). + */ + public function get_tgmpa_status_url( $status ) { + return add_query_arg( + array( + 'plugin_status' => urlencode( $status ), + ), + $this->get_tgmpa_url() + ); + } + + /** + * Determine whether there are open actions for plugins registered with TGMPA. + * + * @since 2.5.0 + * + * @return bool True if complete, i.e. no outstanding actions. False otherwise. + */ + public function is_tgmpa_complete() { + $complete = true; + foreach ( $this->plugins as $slug => $plugin ) { + if ( ! $this->is_plugin_active( $slug ) || false !== $this->does_plugin_have_update( $slug ) ) { + $complete = false; + break; + } + } + + return $complete; + } + + /** + * Check if a plugin is installed. Does not take must-use plugins into account. + * + * @since 2.5.0 + * + * @param string $slug Plugin slug. + * @return bool True if installed, false otherwise. + */ + public function is_plugin_installed( $slug ) { + $installed_plugins = $this->get_plugins(); // Retrieve a list of all installed plugins (WP cached). + + return ( ! empty( $installed_plugins[ $this->plugins[ $slug ]['file_path'] ] ) ); + } + + /** + * Check if a plugin is active. + * + * @since 2.5.0 + * + * @param string $slug Plugin slug. + * @return bool True if active, false otherwise. + */ + public function is_plugin_active( $slug ) { + return ( ( ! empty( $this->plugins[ $slug ]['is_callable'] ) && is_callable( $this->plugins[ $slug ]['is_callable'] ) ) || is_plugin_active( $this->plugins[ $slug ]['file_path'] ) ); + } + + /** + * Check if a plugin can be updated, i.e. if we have information on the minimum WP version required + * available, check whether the current install meets them. + * + * @since 2.5.0 + * + * @param string $slug Plugin slug. + * @return bool True if OK to update, false otherwise. + */ + public function can_plugin_update( $slug ) { + // We currently can't get reliable info on non-WP-repo plugins - issue #380. + if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) { + return true; + } + + $api = $this->get_plugins_api( $slug ); + + if ( false !== $api && isset( $api->requires ) ) { + return version_compare( $GLOBALS['wp_version'], $api->requires, '>=' ); + } + + // No usable info received from the plugins API, presume we can update. + return true; + } + + /** + * Check if a plugin can be activated, i.e. is not currently active and meets the minimum + * plugin version requirements set in TGMPA (if any). + * + * @since 2.5.0 + * + * @param string $slug Plugin slug. + * @return bool True if OK to activate, false otherwise. + */ + public function can_plugin_activate( $slug ) { + return ( ! $this->is_plugin_active( $slug ) && ! $this->does_plugin_require_update( $slug ) ); + } + + /** + * Retrieve the version number of an installed plugin. + * + * @since 2.5.0 + * + * @param string $slug Plugin slug. + * @return string Version number as string or an empty string if the plugin is not installed + * or version unknown (plugins which don't comply with the plugin header standard). + */ + public function get_installed_version( $slug ) { + $installed_plugins = $this->get_plugins(); // Retrieve a list of all installed plugins (WP cached). + + if ( ! empty( $installed_plugins[ $this->plugins[ $slug ]['file_path'] ]['Version'] ) ) { + return $installed_plugins[ $this->plugins[ $slug ]['file_path'] ]['Version']; + } + + return ''; + } + + /** + * Check whether a plugin complies with the minimum version requirements. + * + * @since 2.5.0 + * + * @param string $slug Plugin slug. + * @return bool True when a plugin needs to be updated, otherwise false. + */ + public function does_plugin_require_update( $slug ) { + $installed_version = $this->get_installed_version( $slug ); + $minimum_version = $this->plugins[ $slug ]['version']; + + return version_compare( $minimum_version, $installed_version, '>' ); + } + + /** + * Check whether there is an update available for a plugin. + * + * @since 2.5.0 + * + * @param string $slug Plugin slug. + * @return false|string Version number string of the available update or false if no update available. + */ + public function does_plugin_have_update( $slug ) { + // Presume bundled and external plugins will point to a package which meets the minimum required version. + if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) { + if ( $this->does_plugin_require_update( $slug ) ) { + return $this->plugins[ $slug ]['version']; + } + + return false; + } + + $repo_updates = get_site_transient( 'update_plugins' ); + + if ( isset( $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->new_version ) ) { + return $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->new_version; + } + + return false; + } + + /** + * Retrieve potential upgrade notice for a plugin. + * + * @since 2.5.0 + * + * @param string $slug Plugin slug. + * @return string The upgrade notice or an empty string if no message was available or provided. + */ + public function get_upgrade_notice( $slug ) { + // We currently can't get reliable info on non-WP-repo plugins - issue #380. + if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) { + return ''; + } + + $repo_updates = get_site_transient( 'update_plugins' ); + + if ( ! empty( $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->upgrade_notice ) ) { + return $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->upgrade_notice; + } + + return ''; + } + + /** + * Wrapper around the core WP get_plugins function, making sure it's actually available. + * + * @since 2.5.0 + * + * @param string $plugin_folder Optional. Relative path to single plugin folder. + * @return array Array of installed plugins with plugin information. + */ + public function get_plugins( $plugin_folder = '' ) { + if ( ! function_exists( 'get_plugins' ) ) { + require_once ABSPATH . 'wp-admin/includes/plugin.php'; + } + + return get_plugins( $plugin_folder ); + } + + /** + * Delete dismissable nag option when theme is switched. + * + * This ensures that the user(s) is/are again reminded via nag of required + * and/or recommended plugins if they re-activate the theme. + * + * @since 2.1.1 + */ + public function update_dismiss() { + delete_metadata( 'user', null, 'tgmpa_dismissed_notice_' . $this->id, null, true ); + } + + /** + * Forces plugin activation if the parameter 'force_activation' is + * set to true. + * + * This allows theme authors to specify certain plugins that must be + * active at all times while using the current theme. + * + * Please take special care when using this parameter as it has the + * potential to be harmful if not used correctly. Setting this parameter + * to true will not allow the specified plugin to be deactivated unless + * the user switches themes. + * + * @since 2.2.0 + */ + public function force_activation() { + foreach ( $this->plugins as $slug => $plugin ) { + if ( true === $plugin['force_activation'] ) { + if ( ! $this->is_plugin_installed( $slug ) ) { + // Oops, plugin isn't there so iterate to next condition. + continue; + } elseif ( $this->can_plugin_activate( $slug ) ) { + // There we go, activate the plugin. + activate_plugin( $plugin['file_path'] ); + } + } + } + } + + /** + * Forces plugin deactivation if the parameter 'force_deactivation' + * is set to true. + * + * This allows theme authors to specify certain plugins that must be + * deactivated upon switching from the current theme to another. + * + * Please take special care when using this parameter as it has the + * potential to be harmful if not used correctly. + * + * @since 2.2.0 + */ + public function force_deactivation() { + foreach ( $this->plugins as $slug => $plugin ) { + // Only proceed forward if the parameter is set to true and plugin is active. + if ( true === $plugin['force_deactivation'] && $this->is_plugin_active( $slug ) ) { + deactivate_plugins( $plugin['file_path'] ); + } + } + } + + /** + * Echo the current TGMPA version number to the page. + */ + public function show_tgmpa_version() { + echo '

', + esc_html( sprintf( _x( 'TGMPA v%s', '%s = version number', 'tgmpa' ), self::TGMPA_VERSION ) ), + '

'; + } + + /** + * Returns the singleton instance of the class. + * + * @since 2.4.0 + * + * @return object The TGM_Plugin_Activation object. + */ + public static function get_instance() { + if ( ! isset( self::$instance ) && ! ( self::$instance instanceof self ) ) { + self::$instance = new self(); + } + + return self::$instance; + } + } + + if ( ! function_exists( 'load_tgm_plugin_activation' ) ) { + /** + * Ensure only one instance of the class is ever invoked. + */ + function load_tgm_plugin_activation() { + $GLOBALS['tgmpa'] = TGM_Plugin_Activation::get_instance(); + } + } + + if ( did_action( 'plugins_loaded' ) ) { + load_tgm_plugin_activation(); + } else { + add_action( 'plugins_loaded', 'load_tgm_plugin_activation' ); + } +} + +if ( ! function_exists( 'tgmpa' ) ) { + /** + * Helper function to register a collection of required plugins. + * + * @since 2.0.0 + * @api + * + * @param array $plugins An array of plugin arrays. + * @param array $config Optional. An array of configuration values. + */ + function tgmpa( $plugins, $config = array() ) { + $instance = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); + + foreach ( $plugins as $plugin ) { + call_user_func( array( $instance, 'register' ), $plugin ); + } + + if ( ! empty( $config ) && is_array( $config ) ) { + // Send out notices for deprecated arguments passed. + if ( isset( $config['notices'] ) ) { + _deprecated_argument( __FUNCTION__, '2.2.0', 'The `notices` config parameter was renamed to `has_notices` in TGMPA 2.2.0. Please adjust your configuration.' ); + if ( ! isset( $config['has_notices'] ) ) { + $config['has_notices'] = $config['notices']; + } + } + + if ( isset( $config['parent_menu_slug'] ) ) { + _deprecated_argument( __FUNCTION__, '2.4.0', 'The `parent_menu_slug` config parameter was removed in TGMPA 2.4.0. In TGMPA 2.5.0 an alternative was (re-)introduced. Please adjust your configuration. For more information visit the website: http://tgmpluginactivation.com/configuration/#h-configuration-options.' ); + } + if ( isset( $config['parent_url_slug'] ) ) { + _deprecated_argument( __FUNCTION__, '2.4.0', 'The `parent_url_slug` config parameter was removed in TGMPA 2.4.0. In TGMPA 2.5.0 an alternative was (re-)introduced. Please adjust your configuration. For more information visit the website: http://tgmpluginactivation.com/configuration/#h-configuration-options.' ); + } + + call_user_func( array( $instance, 'config' ), $config ); + } + } +} + +/** + * WP_List_Table isn't always available. If it isn't available, + * we load it here. + * + * @since 2.2.0 + */ +if ( ! class_exists( 'WP_List_Table' ) ) { + require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; +} + +if ( ! class_exists( 'TGMPA_List_Table' ) ) { + + /** + * List table class for handling plugins. + * + * Extends the WP_List_Table class to provide a future-compatible + * way of listing out all required/recommended plugins. + * + * Gives users an interface similar to the Plugin Administration + * area with similar (albeit stripped down) capabilities. + * + * This class also allows for the bulk install of plugins. + * + * @since 2.2.0 + * + * @package TGM-Plugin-Activation + * @author Thomas Griffin + * @author Gary Jones + */ + class TGMPA_List_Table extends WP_List_Table { + /** + * TGMPA instance. + * + * @since 2.5.0 + * + * @var object + */ + protected $tgmpa; + + /** + * The currently chosen view. + * + * @since 2.5.0 + * + * @var string One of: 'all', 'install', 'update', 'activate' + */ + public $view_context = 'all'; + + /** + * The plugin counts for the various views. + * + * @since 2.5.0 + * + * @var array + */ + protected $view_totals = array( + 'all' => 0, + 'install' => 0, + 'update' => 0, + 'activate' => 0, + ); + + /** + * References parent constructor and sets defaults for class. + * + * @since 2.2.0 + */ + public function __construct() { + $this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); + + parent::__construct( + array( + 'singular' => 'plugin', + 'plural' => 'plugins', + 'ajax' => false, + ) + ); + + if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], array( 'install', 'update', 'activate' ), true ) ) { + $this->view_context = sanitize_key( $_REQUEST['plugin_status'] ); + } + + add_filter( 'tgmpa_table_data_items', array( $this, 'sort_table_items' ) ); + } + + /** + * Get a list of CSS classes for the tag. + * + * Overruled to prevent the 'plural' argument from being added. + * + * @since 2.5.0 + * + * @return array CSS classnames. + */ + public function get_table_classes() { + return array( 'widefat', 'fixed' ); + } + + /** + * Gathers and renames all of our plugin information to be used by WP_List_Table to create our table. + * + * @since 2.2.0 + * + * @return array $table_data Information for use in table. + */ + protected function _gather_plugin_data() { + // Load thickbox for plugin links. + $this->tgmpa->admin_init(); + $this->tgmpa->thickbox(); + + // Categorize the plugins which have open actions. + $plugins = $this->categorize_plugins_to_views(); + + // Set the counts for the view links. + $this->set_view_totals( $plugins ); + + // Prep variables for use and grab list of all installed plugins. + $table_data = array(); + $i = 0; + + // Redirect to the 'all' view if no plugins were found for the selected view context. + if ( empty( $plugins[ $this->view_context ] ) ) { + $this->view_context = 'all'; + } + + foreach ( $plugins[ $this->view_context ] as $slug => $plugin ) { + $table_data[ $i ]['sanitized_plugin'] = $plugin['name']; + $table_data[ $i ]['slug'] = $slug; + $table_data[ $i ]['plugin'] = '' . $this->tgmpa->get_info_link( $slug ) . ''; + $table_data[ $i ]['source'] = $this->get_plugin_source_type_text( $plugin['source_type'] ); + $table_data[ $i ]['type'] = $this->get_plugin_advise_type_text( $plugin['required'] ); + $table_data[ $i ]['status'] = $this->get_plugin_status_text( $slug ); + $table_data[ $i ]['installed_version'] = $this->tgmpa->get_installed_version( $slug ); + $table_data[ $i ]['minimum_version'] = $plugin['version']; + $table_data[ $i ]['available_version'] = $this->tgmpa->does_plugin_have_update( $slug ); + + // Prep the upgrade notice info. + $upgrade_notice = $this->tgmpa->get_upgrade_notice( $slug ); + if ( ! empty( $upgrade_notice ) ) { + $table_data[ $i ]['upgrade_notice'] = $upgrade_notice; + + add_action( "tgmpa_after_plugin_row_$slug", array( $this, 'wp_plugin_update_row' ), 10, 2 ); + } + + $table_data[ $i ] = apply_filters( 'tgmpa_table_data_item', $table_data[ $i ], $plugin ); + + $i++; + } + + return $table_data; + } + + /** + * Categorize the plugins which have open actions into views for the TGMPA page. + * + * @since 2.5.0 + */ + protected function categorize_plugins_to_views() { + $plugins = array( + 'all' => array(), // Meaning: all plugins which still have open actions. + 'install' => array(), + 'update' => array(), + 'activate' => array(), + ); + + foreach ( $this->tgmpa->plugins as $slug => $plugin ) { + if ( $this->tgmpa->is_plugin_active( $slug ) && false === $this->tgmpa->does_plugin_have_update( $slug ) ) { + // No need to display plugins if they are installed, up-to-date and active. + continue; + } else { + $plugins['all'][ $slug ] = $plugin; + + if ( ! $this->tgmpa->is_plugin_installed( $slug ) ) { + $plugins['install'][ $slug ] = $plugin; + } else { + if ( false !== $this->tgmpa->does_plugin_have_update( $slug ) ) { + $plugins['update'][ $slug ] = $plugin; + } + + if ( $this->tgmpa->can_plugin_activate( $slug ) ) { + $plugins['activate'][ $slug ] = $plugin; + } + } + } + } + + return $plugins; + } + + /** + * Set the counts for the view links. + * + * @since 2.5.0 + * + * @param array $plugins Plugins order by view. + */ + protected function set_view_totals( $plugins ) { + foreach ( $plugins as $type => $list ) { + $this->view_totals[ $type ] = count( $list ); + } + } + + /** + * Get the plugin required/recommended text string. + * + * @since 2.5.0 + * + * @param string $required Plugin required setting. + * @return string + */ + protected function get_plugin_advise_type_text( $required ) { + if ( true === $required ) { + return __( 'Required', 'tgmpa' ); + } + + return __( 'Recommended', 'tgmpa' ); + } + + /** + * Get the plugin source type text string. + * + * @since 2.5.0 + * + * @param string $type Plugin type. + * @return string + */ + protected function get_plugin_source_type_text( $type ) { + $string = ''; + + switch ( $type ) { + case 'repo': + $string = __( 'WordPress Repository', 'tgmpa' ); + break; + case 'external': + $string = __( 'External Source', 'tgmpa' ); + break; + case 'bundled': + $string = __( 'Pre-Packaged', 'tgmpa' ); + break; + } + + return $string; + } + + /** + * Determine the plugin status message. + * + * @since 2.5.0 + * + * @param string $slug Plugin slug. + * @return string + */ + protected function get_plugin_status_text( $slug ) { + if ( ! $this->tgmpa->is_plugin_installed( $slug ) ) { + return __( 'Not Installed', 'tgmpa' ); + } + + if ( ! $this->tgmpa->is_plugin_active( $slug ) ) { + $install_status = __( 'Installed But Not Activated', 'tgmpa' ); + } else { + $install_status = __( 'Active', 'tgmpa' ); + } + + $update_status = ''; + + if ( $this->tgmpa->does_plugin_require_update( $slug ) && false === $this->tgmpa->does_plugin_have_update( $slug ) ) { + $update_status = __( 'Required Update not Available', 'tgmpa' ); + + } elseif ( $this->tgmpa->does_plugin_require_update( $slug ) ) { + $update_status = __( 'Requires Update', 'tgmpa' ); + + } elseif ( false !== $this->tgmpa->does_plugin_have_update( $slug ) ) { + $update_status = __( 'Update recommended', 'tgmpa' ); + } + + if ( '' === $update_status ) { + return $install_status; + } + + return sprintf( + _x( '%1$s, %2$s', '%1$s = install status, %2$s = update status', 'tgmpa' ), + $install_status, + $update_status + ); + } + + /** + * Sort plugins by Required/Recommended type and by alphabetical plugin name within each type. + * + * @since 2.5.0 + * + * @param array $items Prepared table items. + * @return array Sorted table items. + */ + public function sort_table_items( $items ) { + $type = array(); + $name = array(); + + foreach ( $items as $i => $plugin ) { + $type[ $i ] = $plugin['type']; // Required / recommended. + $name[ $i ] = $plugin['sanitized_plugin']; + } + + array_multisort( $type, SORT_DESC, $name, SORT_ASC, $items ); + + return $items; + } + + /** + * Get an associative array ( id => link ) of the views available on this table. + * + * @since 2.5.0 + * + * @return array + */ + public function get_views() { + $status_links = array(); + + foreach ( $this->view_totals as $type => $count ) { + if ( $count < 1 ) { + continue; + } + + switch ( $type ) { + case 'all': + $text = _nx( 'All (%s)', 'All (%s)', $count, 'plugins', 'tgmpa' ); + break; + case 'install': + $text = _n( 'To Install (%s)', 'To Install (%s)', $count, 'tgmpa' ); + break; + case 'update': + $text = _n( 'Update Available (%s)', 'Update Available (%s)', $count, 'tgmpa' ); + break; + case 'activate': + $text = _n( 'To Activate (%s)', 'To Activate (%s)', $count, 'tgmpa' ); + break; + default: + $text = ''; + break; + } + + if ( ! empty( $text ) ) { + + $status_links[ $type ] = sprintf( + '%s', + esc_url( $this->tgmpa->get_tgmpa_status_url( $type ) ), + ( $type === $this->view_context ) ? ' class="current"' : '', + sprintf( $text, number_format_i18n( $count ) ) + ); + } + } + + return $status_links; + } + + /** + * Create default columns to display important plugin information + * like type, action and status. + * + * @since 2.2.0 + * + * @param array $item Array of item data. + * @param string $column_name The name of the column. + * @return string + */ + public function column_default( $item, $column_name ) { + return $item[ $column_name ]; + } + + /** + * Required for bulk installing. + * + * Adds a checkbox for each plugin. + * + * @since 2.2.0 + * + * @param array $item Array of item data. + * @return string The input checkbox with all necessary info. + */ + public function column_cb( $item ) { + return sprintf( + '', + esc_attr( $this->_args['singular'] ), + esc_attr( $item['slug'] ), + esc_attr( $item['sanitized_plugin'] ) + ); + } + + /** + * Create default title column along with the action links. + * + * @since 2.2.0 + * + * @param array $item Array of item data. + * @return string The plugin name and action links. + */ + public function column_plugin( $item ) { + return sprintf( + '%1$s %2$s', + $item['plugin'], + $this->row_actions( $this->get_row_actions( $item ), true ) + ); + } + + /** + * Create version information column. + * + * @since 2.5.0 + * + * @param array $item Array of item data. + * @return string HTML-formatted version information. + */ + public function column_version( $item ) { + $output = array(); + + if ( $this->tgmpa->is_plugin_installed( $item['slug'] ) ) { + $installed = ! empty( $item['installed_version'] ) ? $item['installed_version'] : _x( 'unknown', 'as in: "version nr unknown"', 'tgmpa' ); + + $color = ''; + if ( ! empty( $item['minimum_version'] ) && $this->tgmpa->does_plugin_require_update( $item['slug'] ) ) { + $color = ' color: #ff0000; font-weight: bold;'; + } + + $output[] = sprintf( + '

%2$s' . __( 'Installed version:', 'tgmpa' ) . '

', + $color, + $installed + ); + } + + if ( ! empty( $item['minimum_version'] ) ) { + $output[] = sprintf( + '

%1$s' . __( 'Minimum required version:', 'tgmpa' ) . '

', + $item['minimum_version'] + ); + } + + if ( ! empty( $item['available_version'] ) ) { + $color = ''; + if ( ! empty( $item['minimum_version'] ) && version_compare( $item['available_version'], $item['minimum_version'], '>=' ) ) { + $color = ' color: #71C671; font-weight: bold;'; + } + + $output[] = sprintf( + '

%2$s' . __( 'Available version:', 'tgmpa' ) . '

', + $color, + $item['available_version'] + ); + } + + if ( empty( $output ) ) { + return ' '; // Let's not break the table layout. + } else { + return implode( "\n", $output ); + } + } + + /** + * Sets default message within the plugins table if no plugins + * are left for interaction. + * + * Hides the menu item to prevent the user from clicking and + * getting a permissions error. + * + * @since 2.2.0 + */ + public function no_items() { + printf( wp_kses_post( __( 'No plugins to install, update or activate. Return to the Dashboard', 'tgmpa' ) ), esc_url( self_admin_url() ) ); + echo ''; + } + + /** + * Output all the column information within the table. + * + * @since 2.2.0 + * + * @return array $columns The column names. + */ + public function get_columns() { + $columns = array( + 'cb' => '', + 'plugin' => __( 'Plugin', 'tgmpa' ), + 'source' => __( 'Source', 'tgmpa' ), + 'type' => __( 'Type', 'tgmpa' ), + ); + + if ( 'all' === $this->view_context || 'update' === $this->view_context ) { + $columns['version'] = __( 'Version', 'tgmpa' ); + $columns['status'] = __( 'Status', 'tgmpa' ); + } + + return apply_filters( 'tgmpa_table_columns', $columns ); + } + + /** + * Get name of default primary column + * + * @since 2.5.0 / WP 4.3+ compatibility + * @access protected + * + * @return string + */ + protected function get_default_primary_column_name() { + return 'plugin'; + } + + /** + * Get the name of the primary column. + * + * @since 2.5.0 / WP 4.3+ compatibility + * @access protected + * + * @return string The name of the primary column. + */ + protected function get_primary_column_name() { + if ( method_exists( 'WP_List_Table', 'get_primary_column_name' ) ) { + return parent::get_primary_column_name(); + } else { + return $this->get_default_primary_column_name(); + } + } + + /** + * Get the actions which are relevant for a specific plugin row. + * + * @since 2.5.0 + * + * @param array $item Array of item data. + * @return array Array with relevant action links. + */ + protected function get_row_actions( $item ) { + $actions = array(); + $action_links = array(); + + // Display the 'Install' action link if the plugin is not yet available. + if ( ! $this->tgmpa->is_plugin_installed( $item['slug'] ) ) { + $actions['install'] = _x( 'Install %2$s', '%2$s = plugin name in screen reader markup', 'tgmpa' ); + } else { + // Display the 'Update' action link if an update is available and WP complies with plugin minimum. + if ( false !== $this->tgmpa->does_plugin_have_update( $item['slug'] ) && $this->tgmpa->can_plugin_update( $item['slug'] ) ) { + $actions['update'] = _x( 'Update %2$s', '%2$s = plugin name in screen reader markup', 'tgmpa' ); + } + + // Display the 'Activate' action link, but only if the plugin meets the minimum version. + if ( $this->tgmpa->can_plugin_activate( $item['slug'] ) ) { + $actions['activate'] = _x( 'Activate %2$s', '%2$s = plugin name in screen reader markup', 'tgmpa' ); + } + } + + // Create the actual links. + foreach ( $actions as $action => $text ) { + $nonce_url = wp_nonce_url( + add_query_arg( + array( + 'plugin' => urlencode( $item['slug'] ), + 'tgmpa-' . $action => $action . '-plugin', + ), + $this->tgmpa->get_tgmpa_url() + ), + 'tgmpa-' . $action, + 'tgmpa-nonce' + ); + + $action_links[ $action ] = sprintf( + '' . esc_html( $text ) . '', + esc_url( $nonce_url ), + '' . esc_html( $item['sanitized_plugin'] ) . '' + ); + } + + $prefix = ( defined( 'WP_NETWORK_ADMIN' ) && WP_NETWORK_ADMIN ) ? 'network_admin_' : ''; + return apply_filters( "tgmpa_{$prefix}plugin_action_links", array_filter( $action_links ), $item['slug'], $item, $this->view_context ); + } + + /** + * Generates content for a single row of the table. + * + * @since 2.5.0 + * + * @param object $item The current item. + */ + public function single_row( $item ) { + parent::single_row( $item ); + + /** + * Fires after each specific row in the TGMPA Plugins list table. + * + * The dynamic portion of the hook name, `$item['slug']`, refers to the slug + * for the plugin. + * + * @since 2.5.0 + */ + do_action( "tgmpa_after_plugin_row_{$item['slug']}", $item['slug'], $item, $this->view_context ); + } + + /** + * Show the upgrade notice below a plugin row if there is one. + * + * @since 2.5.0 + * + * @see /wp-admin/includes/update.php + * + * @param string $slug Plugin slug. + * @param array $item The information available in this table row. + * @return null Return early if upgrade notice is empty. + */ + public function wp_plugin_update_row( $slug, $item ) { + if ( empty( $item['upgrade_notice'] ) ) { + return; + } + + echo ' + + + '; + } + + /** + * Extra controls to be displayed between bulk actions and pagination. + * + * @since 2.5.0 + * + * @param string $which 'top' or 'bottom' table navigation. + */ + public function extra_tablenav( $which ) { + if ( 'bottom' === $which ) { + $this->tgmpa->show_tgmpa_version(); + } + } + + /** + * Defines the bulk actions for handling registered plugins. + * + * @since 2.2.0 + * + * @return array $actions The bulk actions for the plugin install table. + */ + public function get_bulk_actions() { + + $actions = array(); + + if ( 'update' !== $this->view_context && 'activate' !== $this->view_context ) { + if ( current_user_can( 'install_plugins' ) ) { + $actions['tgmpa-bulk-install'] = __( 'Install', 'tgmpa' ); + } + } + + if ( 'install' !== $this->view_context ) { + if ( current_user_can( 'update_plugins' ) ) { + $actions['tgmpa-bulk-update'] = __( 'Update', 'tgmpa' ); + } + if ( current_user_can( 'activate_plugins' ) ) { + $actions['tgmpa-bulk-activate'] = __( 'Activate', 'tgmpa' ); + } + } + + return $actions; + } + + /** + * Processes bulk installation and activation actions. + * + * The bulk installation process looks for the $_POST information and passes that + * through if a user has to use WP_Filesystem to enter their credentials. + * + * @since 2.2.0 + */ + public function process_bulk_actions() { + // Bulk installation process. + if ( 'tgmpa-bulk-install' === $this->current_action() || 'tgmpa-bulk-update' === $this->current_action() ) { + + check_admin_referer( 'bulk-' . $this->_args['plural'] ); + + $install_type = 'install'; + if ( 'tgmpa-bulk-update' === $this->current_action() ) { + $install_type = 'update'; + } + + $plugins_to_install = array(); + + // Did user actually select any plugins to install/update ? + if ( empty( $_POST['plugin'] ) ) { + if ( 'install' === $install_type ) { + $message = __( 'No plugins were selected to be installed. No action taken.', 'tgmpa' ); + } else { + $message = __( 'No plugins were selected to be updated. No action taken.', 'tgmpa' ); + } + + echo '

', esc_html( $message ), '

'; + + return false; + } + + if ( is_array( $_POST['plugin'] ) ) { + $plugins_to_install = (array) $_POST['plugin']; + } elseif ( is_string( $_POST['plugin'] ) ) { + // Received via Filesystem page - un-flatten array (WP bug #19643). + $plugins_to_install = explode( ',', $_POST['plugin'] ); + } + + // Sanitize the received input. + $plugins_to_install = array_map( 'urldecode', $plugins_to_install ); + $plugins_to_install = array_map( array( $this->tgmpa, 'sanitize_key' ), $plugins_to_install ); + + // Validate the received input. + foreach ( $plugins_to_install as $key => $slug ) { + // Check if the plugin was registered with TGMPA and remove if not. + if ( ! isset( $this->tgmpa->plugins[ $slug ] ) ) { + unset( $plugins_to_install[ $key ] ); + continue; + } + + // For updates: make sure this is a plugin we *can* update (update available and WP version ok). + if ( 'update' === $install_type && ( $this->tgmpa->is_plugin_installed( $slug ) && ( false === $this->tgmpa->does_plugin_have_update( $slug ) || ! $this->tgmpa->can_plugin_update( $slug ) ) ) ) { + unset( $plugins_to_install[ $key ] ); + } + } + + // No need to proceed further if we have no plugins to handle. + if ( empty( $plugins_to_install ) ) { + if ( 'install' === $install_type ) { + $message = __( 'No plugins are available to be installed at this time.', 'tgmpa' ); + } else { + $message = __( 'No plugins are available to be updated at this time.', 'tgmpa' ); + } + + echo '

', esc_html( $message ), '

'; + + return false; + } + + // Pass all necessary information if WP_Filesystem is needed. + $url = wp_nonce_url( + $this->tgmpa->get_tgmpa_url(), + 'bulk-' . $this->_args['plural'] + ); + + // Give validated data back to $_POST which is the only place the filesystem looks for extra fields. + $_POST['plugin'] = implode( ',', $plugins_to_install ); // Work around for WP bug #19643. + + $method = ''; // Leave blank so WP_Filesystem can populate it as necessary. + $fields = array_keys( $_POST ); // Extra fields to pass to WP_Filesystem. + + if ( false === ( $creds = request_filesystem_credentials( esc_url_raw( $url ), $method, false, false, $fields ) ) ) { + return true; // Stop the normal page form from displaying, credential request form will be shown. + } + + // Now we have some credentials, setup WP_Filesystem. + if ( ! WP_Filesystem( $creds ) ) { + // Our credentials were no good, ask the user for them again. + request_filesystem_credentials( esc_url_raw( $url ), $method, true, false, $fields ); + + return true; + } + + /* If we arrive here, we have the filesystem */ + + // Store all information in arrays since we are processing a bulk installation. + $names = array(); + $sources = array(); // Needed for installs. + $file_paths = array(); // Needed for upgrades. + $to_inject = array(); // Information to inject into the update_plugins transient. + + // Prepare the data for validated plugins for the install/upgrade. + foreach ( $plugins_to_install as $slug ) { + $name = $this->tgmpa->plugins[ $slug ]['name']; + $source = $this->tgmpa->get_download_url( $slug ); + + if ( ! empty( $name ) && ! empty( $source ) ) { + $names[] = $name; + + switch ( $install_type ) { + + case 'install': + $sources[] = $source; + break; + + case 'update': + $file_paths[] = $this->tgmpa->plugins[ $slug ]['file_path']; + $to_inject[ $slug ] = $this->tgmpa->plugins[ $slug ]; + $to_inject[ $slug ]['source'] = $source; + break; + } + } + } + unset( $slug, $name, $source ); + + // Create a new instance of TGMPA_Bulk_Installer. + $installer = new TGMPA_Bulk_Installer( + new TGMPA_Bulk_Installer_Skin( + array( + 'url' => esc_url_raw( $this->tgmpa->get_tgmpa_url() ), + 'nonce' => 'bulk-' . $this->_args['plural'], + 'names' => $names, + 'install_type' => $install_type, + ) + ) + ); + + // Wrap the install process with the appropriate HTML. + echo '
', + '

', esc_html( get_admin_page_title() ), '

'; + + // Process the bulk installation submissions. + add_filter( 'upgrader_source_selection', array( $this->tgmpa, 'maybe_adjust_source_dir' ), 1, 3 ); + + if ( 'tgmpa-bulk-update' === $this->current_action() ) { + // Inject our info into the update transient. + $this->tgmpa->inject_update_info( $to_inject ); + + $installer->bulk_upgrade( $file_paths ); + } else { + $installer->bulk_install( $sources ); + } + + remove_filter( 'upgrader_source_selection', array( $this->tgmpa, 'maybe_adjust_source_dir' ), 1, 3 ); + + echo '
'; + + return true; + } + + // Bulk activation process. + if ( 'tgmpa-bulk-activate' === $this->current_action() ) { + check_admin_referer( 'bulk-' . $this->_args['plural'] ); + + // Did user actually select any plugins to activate ? + if ( empty( $_POST['plugin'] ) ) { + echo '

', esc_html__( 'No plugins were selected to be activated. No action taken.', 'tgmpa' ), '

'; + + return false; + } + + // Grab plugin data from $_POST. + $plugins = array(); + if ( isset( $_POST['plugin'] ) ) { + $plugins = array_map( 'urldecode', (array) $_POST['plugin'] ); + $plugins = array_map( array( $this->tgmpa, 'sanitize_key' ), $plugins ); + } + + $plugins_to_activate = array(); + $plugin_names = array(); + + // Grab the file paths for the selected & inactive plugins from the registration array. + foreach ( $plugins as $slug ) { + if ( $this->tgmpa->can_plugin_activate( $slug ) ) { + $plugins_to_activate[] = $this->tgmpa->plugins[ $slug ]['file_path']; + $plugin_names[] = $this->tgmpa->plugins[ $slug ]['name']; + } + } + unset( $slug ); + + // Return early if there are no plugins to activate. + if ( empty( $plugins_to_activate ) ) { + echo '

', esc_html__( 'No plugins are available to be activated at this time.', 'tgmpa' ), '

'; + + return false; + } + + // Now we are good to go - let's start activating plugins. + $activate = activate_plugins( $plugins_to_activate ); + + if ( is_wp_error( $activate ) ) { + echo '

', wp_kses_post( $activate->get_error_message() ), '

'; + } else { + $count = count( $plugin_names ); // Count so we can use _n function. + $plugin_names = array_map( array( 'TGMPA_Utils', 'wrap_in_strong' ), $plugin_names ); + $last_plugin = array_pop( $plugin_names ); // Pop off last name to prep for readability. + $imploded = empty( $plugin_names ) ? $last_plugin : ( implode( ', ', $plugin_names ) . ' ' . esc_html_x( 'and', 'plugin A *and* plugin B', 'tgmpa' ) . ' ' . $last_plugin ); + + printf( // WPCS: xss ok. + '

%1$s %2$s.

', + esc_html( _n( 'The following plugin was activated successfully:', 'The following plugins were activated successfully:', $count, 'tgmpa' ) ), + $imploded + ); + + // Update recently activated plugins option. + $recent = (array) get_option( 'recently_activated' ); + foreach ( $plugins_to_activate as $plugin => $time ) { + if ( isset( $recent[ $plugin ] ) ) { + unset( $recent[ $plugin ] ); + } + } + update_option( 'recently_activated', $recent ); + } + + unset( $_POST ); // Reset the $_POST variable in case user wants to perform one action after another. + + return true; + } + + return false; + } + + /** + * Prepares all of our information to be outputted into a usable table. + * + * @since 2.2.0 + */ + public function prepare_items() { + $columns = $this->get_columns(); // Get all necessary column information. + $hidden = array(); // No columns to hide, but we must set as an array. + $sortable = array(); // No reason to make sortable columns. + $primary = $this->get_primary_column_name(); // Column which has the row actions. + $this->_column_headers = array( $columns, $hidden, $sortable, $primary ); // Get all necessary column headers. + + // Process our bulk activations here. + if ( 'tgmpa-bulk-activate' === $this->current_action() ) { + $this->process_bulk_actions(); + } + + // Store all of our plugin data into $items array so WP_List_Table can use it. + $this->items = apply_filters( 'tgmpa_table_data_items', $this->_gather_plugin_data() ); + } + + /* *********** DEPRECATED METHODS *********** */ + + /** + * Retrieve plugin data, given the plugin name. + * + * @since 2.2.0 + * @deprecated 2.5.0 use {@see TGM_Plugin_Activation::_get_plugin_data_from_name()} instead. + * @see TGM_Plugin_Activation::_get_plugin_data_from_name() + * + * @param string $name Name of the plugin, as it was registered. + * @param string $data Optional. Array key of plugin data to return. Default is slug. + * @return string|boolean Plugin slug if found, false otherwise. + */ + protected function _get_plugin_data_from_name( $name, $data = 'slug' ) { + _deprecated_function( __FUNCTION__, 'TGMPA 2.5.0', 'TGM_Plugin_Activation::_get_plugin_data_from_name()' ); + + return $this->tgmpa->_get_plugin_data_from_name( $name, $data ); + } + } +} + + +if ( ! class_exists( 'TGM_Bulk_Installer' ) ) { + + /** + * Hack: Prevent TGMPA v2.4.1- bulk installer class from being loaded if 2.4.1- is loaded after 2.5+. + */ + class TGM_Bulk_Installer { + } +} +if ( ! class_exists( 'TGM_Bulk_Installer_Skin' ) ) { + + /** + * Hack: Prevent TGMPA v2.4.1- bulk installer skin class from being loaded if 2.4.1- is loaded after 2.5+. + */ + class TGM_Bulk_Installer_Skin { + } +} + +/** + * The WP_Upgrader file isn't always available. If it isn't available, + * we load it here. + * + * We check to make sure no action or activation keys are set so that WordPress + * does not try to re-include the class when processing upgrades or installs outside + * of the class. + * + * @since 2.2.0 + */ +add_action( 'admin_init', 'tgmpa_load_bulk_installer' ); +if ( ! function_exists( 'tgmpa_load_bulk_installer' ) ) { + /** + * Load bulk installer + */ + function tgmpa_load_bulk_installer() { + // Silently fail if 2.5+ is loaded *after* an older version. + if ( ! isset( $GLOBALS['tgmpa'] ) ) { + return; + } + + // Get TGMPA class instance. + $tgmpa_instance = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); + + if ( isset( $_GET['page'] ) && $tgmpa_instance->menu === $_GET['page'] ) { + if ( ! class_exists( 'Plugin_Upgrader', false ) ) { + require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; + } + + if ( ! class_exists( 'TGMPA_Bulk_Installer' ) ) { + + /** + * Installer class to handle bulk plugin installations. + * + * Extends WP_Upgrader and customizes to suit the installation of multiple + * plugins. + * + * @since 2.2.0 + * + * @internal Since 2.5.0 the class is an extension of Plugin_Upgrader rather than WP_Upgrader + * @internal Since 2.5.2 the class has been renamed from TGM_Bulk_Installer to TGMPA_Bulk_Installer. + * This was done to prevent backward compatibility issues with v2.3.6. + * + * @package TGM-Plugin-Activation + * @author Thomas Griffin + * @author Gary Jones + */ + class TGMPA_Bulk_Installer extends Plugin_Upgrader { + /** + * Holds result of bulk plugin installation. + * + * @since 2.2.0 + * + * @var string + */ + public $result; + + /** + * Flag to check if bulk installation is occurring or not. + * + * @since 2.2.0 + * + * @var boolean + */ + public $bulk = false; + + /** + * TGMPA instance + * + * @since 2.5.0 + * + * @var object + */ + protected $tgmpa; + + /** + * Whether or not the destination directory needs to be cleared ( = on update). + * + * @since 2.5.0 + * + * @var bool + */ + protected $clear_destination = false; + + /** + * References parent constructor and sets defaults for class. + * + * @since 2.2.0 + * + * @param \Bulk_Upgrader_Skin|null $skin Installer skin. + */ + public function __construct( $skin = null ) { + // Get TGMPA class instance. + $this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); + + parent::__construct( $skin ); + + if ( isset( $this->skin->options['install_type'] ) && 'update' === $this->skin->options['install_type'] ) { + $this->clear_destination = true; + } + + if ( $this->tgmpa->is_automatic ) { + $this->activate_strings(); + } + + add_action( 'upgrader_process_complete', array( $this->tgmpa, 'populate_file_path' ) ); + } + + /** + * Sets the correct activation strings for the installer skin to use. + * + * @since 2.2.0 + */ + public function activate_strings() { + $this->strings['activation_failed'] = __( 'Plugin activation failed.', 'tgmpa' ); + $this->strings['activation_success'] = __( 'Plugin activated successfully.', 'tgmpa' ); + } + + /** + * Performs the actual installation of each plugin. + * + * @since 2.2.0 + * + * @see WP_Upgrader::run() + * + * @param array $options The installation config options. + * @return null|array Return early if error, array of installation data on success. + */ + public function run( $options ) { + $result = parent::run( $options ); + + // Reset the strings in case we changed one during automatic activation. + if ( $this->tgmpa->is_automatic ) { + if ( 'update' === $this->skin->options['install_type'] ) { + $this->upgrade_strings(); + } else { + $this->install_strings(); + } + } + + return $result; + } + + /** + * Processes the bulk installation of plugins. + * + * @since 2.2.0 + * + * @internal This is basically a near identical copy of the WP Core Plugin_Upgrader::bulk_upgrade() + * method, with minor adjustments to deal with new installs instead of upgrades. + * For ease of future synchronizations, the adjustments are clearly commented, but no other + * comments are added. Code style has been made to comply. + * + * @see Plugin_Upgrader::bulk_upgrade() + * @see https://core.trac.wordpress.org/browser/tags/4.2.1/src/wp-admin/includes/class-wp-upgrader.php#L838 + * + * @param array $plugins The plugin sources needed for installation. + * @param array $args Arbitrary passed extra arguments. + * @return string|bool Install confirmation messages on success, false on failure. + */ + public function bulk_install( $plugins, $args = array() ) { + // [TGMPA + ] Hook auto-activation in. + add_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 ); + + $defaults = array( + 'clear_update_cache' => true, + ); + $parsed_args = wp_parse_args( $args, $defaults ); + + $this->init(); + $this->bulk = true; + + $this->install_strings(); // [TGMPA + ] adjusted. + + /* [TGMPA - ] $current = get_site_transient( 'update_plugins' ); */ + + /* [TGMPA - ] add_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'), 10, 4); */ + + $this->skin->header(); + + // Connect to the Filesystem first. + $res = $this->fs_connect( array( WP_CONTENT_DIR, WP_PLUGIN_DIR ) ); + if ( ! $res ) { + $this->skin->footer(); + + return false; + } + + $this->skin->bulk_header(); + + // Only start maintenance mode if: + // - running Multisite and there are one or more plugins specified, OR + // - a plugin with an update available is currently active. + // @TODO: For multisite, maintenance mode should only kick in for individual sites if at all possible. + $maintenance = ( is_multisite() && ! empty( $plugins ) ); + + /* + [TGMPA - ] + foreach ( $plugins as $plugin ) + $maintenance = $maintenance || ( is_plugin_active( $plugin ) && isset( $current->response[ $plugin] ) ); + */ + if ( $maintenance ) { + $this->maintenance_mode( true ); + } + + $results = array(); + + $this->update_count = count( $plugins ); + $this->update_current = 0; + foreach ( $plugins as $plugin ) { + $this->update_current++; + + /* + [TGMPA - ] + $this->skin->plugin_info = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin, false, true); + + if ( !isset( $current->response[ $plugin ] ) ) { + $this->skin->set_result('up_to_date'); + $this->skin->before(); + $this->skin->feedback('up_to_date'); + $this->skin->after(); + $results[$plugin] = true; + continue; + } + + // Get the URL to the zip file + $r = $current->response[ $plugin ]; + + $this->skin->plugin_active = is_plugin_active($plugin); + */ + + $result = $this->run( array( + 'package' => $plugin, // [TGMPA + ] adjusted. + 'destination' => WP_PLUGIN_DIR, + 'clear_destination' => false, // [TGMPA + ] adjusted. + 'clear_working' => true, + 'is_multi' => true, + 'hook_extra' => array( + 'plugin' => $plugin, + ), + ) ); + + $results[ $plugin ] = $this->result; + + // Prevent credentials auth screen from displaying multiple times. + if ( false === $result ) { + break; + } + } //end foreach $plugins + + $this->maintenance_mode( false ); + + /** + * Fires when the bulk upgrader process is complete. + * + * @since WP 3.6.0 / TGMPA 2.5.0 + * + * @param Plugin_Upgrader $this Plugin_Upgrader instance. In other contexts, $this, might + * be a Theme_Upgrader or Core_Upgrade instance. + * @param array $data { + * Array of bulk item update data. + * + * @type string $action Type of action. Default 'update'. + * @type string $type Type of update process. Accepts 'plugin', 'theme', or 'core'. + * @type bool $bulk Whether the update process is a bulk update. Default true. + * @type array $packages Array of plugin, theme, or core packages to update. + * } + */ + do_action( 'upgrader_process_complete', $this, array( + 'action' => 'install', // [TGMPA + ] adjusted. + 'type' => 'plugin', + 'bulk' => true, + 'plugins' => $plugins, + ) ); + + $this->skin->bulk_footer(); + + $this->skin->footer(); + + // Cleanup our hooks, in case something else does a upgrade on this connection. + /* [TGMPA - ] remove_filter('upgrader_clear_destination', array($this, 'delete_old_plugin')); */ + + // [TGMPA + ] Remove our auto-activation hook. + remove_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 ); + + // Force refresh of plugin update information. + wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); + + return $results; + } + + /** + * Handle a bulk upgrade request. + * + * @since 2.5.0 + * + * @see Plugin_Upgrader::bulk_upgrade() + * + * @param array $plugins The local WP file_path's of the plugins which should be upgraded. + * @param array $args Arbitrary passed extra arguments. + * @return string|bool Install confirmation messages on success, false on failure. + */ + public function bulk_upgrade( $plugins, $args = array() ) { + + add_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 ); + + $result = parent::bulk_upgrade( $plugins, $args ); + + remove_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 ); + + return $result; + } + + /** + * Abuse a filter to auto-activate plugins after installation. + * + * Hooked into the 'upgrader_post_install' filter hook. + * + * @since 2.5.0 + * + * @param bool $bool The value we need to give back (true). + * @return bool + */ + public function auto_activate( $bool ) { + // Only process the activation of installed plugins if the automatic flag is set to true. + if ( $this->tgmpa->is_automatic ) { + // Flush plugins cache so the headers of the newly installed plugins will be read correctly. + wp_clean_plugins_cache(); + + // Get the installed plugin file. + $plugin_info = $this->plugin_info(); + + // Don't try to activate on upgrade of active plugin as WP will do this already. + if ( ! is_plugin_active( $plugin_info ) ) { + $activate = activate_plugin( $plugin_info ); + + // Adjust the success string based on the activation result. + $this->strings['process_success'] = $this->strings['process_success'] . "
\n"; + + if ( is_wp_error( $activate ) ) { + $this->skin->error( $activate ); + $this->strings['process_success'] .= $this->strings['activation_failed']; + } else { + $this->strings['process_success'] .= $this->strings['activation_success']; + } + } + } + + return $bool; + } + } + } + + if ( ! class_exists( 'TGMPA_Bulk_Installer_Skin' ) ) { + + /** + * Installer skin to set strings for the bulk plugin installations.. + * + * Extends Bulk_Upgrader_Skin and customizes to suit the installation of multiple + * plugins. + * + * @since 2.2.0 + * + * @internal Since 2.5.2 the class has been renamed from TGM_Bulk_Installer_Skin to + * TGMPA_Bulk_Installer_Skin. + * This was done to prevent backward compatibility issues with v2.3.6. + * + * @see https://core.trac.wordpress.org/browser/trunk/src/wp-admin/includes/class-wp-upgrader-skins.php + * + * @package TGM-Plugin-Activation + * @author Thomas Griffin + * @author Gary Jones + */ + class TGMPA_Bulk_Installer_Skin extends Bulk_Upgrader_Skin { + /** + * Holds plugin info for each individual plugin installation. + * + * @since 2.2.0 + * + * @var array + */ + public $plugin_info = array(); + + /** + * Holds names of plugins that are undergoing bulk installations. + * + * @since 2.2.0 + * + * @var array + */ + public $plugin_names = array(); + + /** + * Integer to use for iteration through each plugin installation. + * + * @since 2.2.0 + * + * @var integer + */ + public $i = 0; + + /** + * TGMPA instance + * + * @since 2.5.0 + * + * @var object + */ + protected $tgmpa; + + /** + * Constructor. Parses default args with new ones and extracts them for use. + * + * @since 2.2.0 + * + * @param array $args Arguments to pass for use within the class. + */ + public function __construct( $args = array() ) { + // Get TGMPA class instance. + $this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); + + // Parse default and new args. + $defaults = array( + 'url' => '', + 'nonce' => '', + 'names' => array(), + 'install_type' => 'install', + ); + $args = wp_parse_args( $args, $defaults ); + + // Set plugin names to $this->plugin_names property. + $this->plugin_names = $args['names']; + + // Extract the new args. + parent::__construct( $args ); + } + + /** + * Sets install skin strings for each individual plugin. + * + * Checks to see if the automatic activation flag is set and uses the + * the proper strings accordingly. + * + * @since 2.2.0 + */ + public function add_strings() { + if ( 'update' === $this->options['install_type'] ) { + parent::add_strings(); + $this->upgrader->strings['skin_before_update_header'] = __( 'Updating Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); + } else { + $this->upgrader->strings['skin_update_failed_error'] = __( 'An error occurred while installing %1$s: %2$s.', 'tgmpa' ); + $this->upgrader->strings['skin_update_failed'] = __( 'The installation of %1$s failed.', 'tgmpa' ); + + if ( $this->tgmpa->is_automatic ) { + // Automatic activation strings. + $this->upgrader->strings['skin_upgrade_start'] = __( 'The installation and activation process is starting. This process may take a while on some hosts, so please be patient.', 'tgmpa' ); + $this->upgrader->strings['skin_update_successful'] = __( '%1$s installed and activated successfully.', 'tgmpa' ) . ' ' . esc_html__( 'Show Details', 'tgmpa' ) . '.'; + $this->upgrader->strings['skin_upgrade_end'] = __( 'All installations and activations have been completed.', 'tgmpa' ); + $this->upgrader->strings['skin_before_update_header'] = __( 'Installing and Activating Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); + } else { + // Default installation strings. + $this->upgrader->strings['skin_upgrade_start'] = __( 'The installation process is starting. This process may take a while on some hosts, so please be patient.', 'tgmpa' ); + $this->upgrader->strings['skin_update_successful'] = esc_html__( '%1$s installed successfully.', 'tgmpa' ) . ' ' . esc_html__( 'Show Details', 'tgmpa' ) . '.'; + $this->upgrader->strings['skin_upgrade_end'] = __( 'All installations have been completed.', 'tgmpa' ); + $this->upgrader->strings['skin_before_update_header'] = __( 'Installing Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); + } + } + } + + /** + * Outputs the header strings and necessary JS before each plugin installation. + * + * @since 2.2.0 + * + * @param string $title Unused in this implementation. + */ + public function before( $title = '' ) { + if ( empty( $title ) ) { + $title = esc_html( $this->plugin_names[ $this->i ] ); + } + parent::before( $title ); + } + + /** + * Outputs the footer strings and necessary JS after each plugin installation. + * + * Checks for any errors and outputs them if they exist, else output + * success strings. + * + * @since 2.2.0 + * + * @param string $title Unused in this implementation. + */ + public function after( $title = '' ) { + if ( empty( $title ) ) { + $title = esc_html( $this->plugin_names[ $this->i ] ); + } + parent::after( $title ); + + $this->i++; + } + + /** + * Outputs links after bulk plugin installation is complete. + * + * @since 2.2.0 + */ + public function bulk_footer() { + // Serve up the string to say installations (and possibly activations) are complete. + parent::bulk_footer(); + + // Flush plugins cache so we can make sure that the installed plugins list is always up to date. + wp_clean_plugins_cache(); + + $this->tgmpa->show_tgmpa_version(); + + // Display message based on if all plugins are now active or not. + $update_actions = array(); + + if ( $this->tgmpa->is_tgmpa_complete() ) { + // All plugins are active, so we display the complete string and hide the menu to protect users. + echo ''; + $update_actions['dashboard'] = sprintf( + esc_html( $this->tgmpa->strings['complete'] ), + '' . esc_html__( 'Return to the Dashboard', 'tgmpa' ) . '' + ); + } else { + $update_actions['tgmpa_page'] = '' . esc_html( $this->tgmpa->strings['return'] ) . ''; + } + + /** + * Filter the list of action links available following bulk plugin installs/updates. + * + * @since 2.5.0 + * + * @param array $update_actions Array of plugin action links. + * @param array $plugin_info Array of information for the last-handled plugin. + */ + $update_actions = apply_filters( 'tgmpa_update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info ); + + if ( ! empty( $update_actions ) ) { + $this->feedback( implode( ' | ', (array) $update_actions ) ); + } + } + + /* *********** DEPRECATED METHODS *********** */ + + /** + * Flush header output buffer. + * + * @since 2.2.0 + * @deprecated 2.5.0 use {@see Bulk_Upgrader_Skin::flush_output()} instead + * @see Bulk_Upgrader_Skin::flush_output() + */ + public function before_flush_output() { + _deprecated_function( __FUNCTION__, 'TGMPA 2.5.0', 'Bulk_Upgrader_Skin::flush_output()' ); + $this->flush_output(); + } + + /** + * Flush footer output buffer and iterate $this->i to make sure the + * installation strings reference the correct plugin. + * + * @since 2.2.0 + * @deprecated 2.5.0 use {@see Bulk_Upgrader_Skin::flush_output()} instead + * @see Bulk_Upgrader_Skin::flush_output() + */ + public function after_flush_output() { + _deprecated_function( __FUNCTION__, 'TGMPA 2.5.0', 'Bulk_Upgrader_Skin::flush_output()' ); + $this->flush_output(); + $this->i++; + } + } + } + } + } +} + +if ( ! class_exists( 'TGMPA_Utils' ) ) { + + /** + * Generic utilities for TGMPA. + * + * All methods are static, poor-dev name-spacing class wrapper. + * + * Class was called TGM_Utils in 2.5.0 but renamed TGMPA_Utils in 2.5.1 as this was conflicting with Soliloquy. + * + * @since 2.5.0 + * + * @package TGM-Plugin-Activation + * @author Juliette Reinders Folmer + */ + class TGMPA_Utils { + /** + * Whether the PHP filter extension is enabled. + * + * @see http://php.net/book.filter + * + * @since 2.5.0 + * + * @static + * + * @var bool $has_filters True is the extension is enabled. + */ + public static $has_filters; + + /** + * Wrap an arbitrary string in tags. Meant to be used in combination with array_map(). + * + * @since 2.5.0 + * + * @static + * + * @param string $string Text to be wrapped. + * @return string + */ + public static function wrap_in_em( $string ) { + return '' . wp_kses_post( $string ) . ''; + } + + /** + * Wrap an arbitrary string in tags. Meant to be used in combination with array_map(). + * + * @since 2.5.0 + * + * @static + * + * @param string $string Text to be wrapped. + * @return string + */ + public static function wrap_in_strong( $string ) { + return '' . wp_kses_post( $string ) . ''; + } + + /** + * Helper function: Validate a value as boolean + * + * @since 2.5.0 + * + * @static + * + * @param mixed $value Arbitrary value. + * @return bool + */ + public static function validate_bool( $value ) { + if ( ! isset( self::$has_filters ) ) { + self::$has_filters = extension_loaded( 'filter' ); + } + + if ( self::$has_filters ) { + return filter_var( $value, FILTER_VALIDATE_BOOLEAN ); + } else { + return self::emulate_filter_bool( $value ); + } + } + + /** + * Helper function: Cast a value to bool + * + * @since 2.5.0 + * + * @static + * + * @param mixed $value Value to cast. + * @return bool + */ + protected static function emulate_filter_bool( $value ) { + // @codingStandardsIgnoreStart + static $true = array( + '1', + 'true', 'True', 'TRUE', + 'y', 'Y', + 'yes', 'Yes', 'YES', + 'on', 'On', 'ON', + ); + static $false = array( + '0', + 'false', 'False', 'FALSE', + 'n', 'N', + 'no', 'No', 'NO', + 'off', 'Off', 'OFF', + ); + // @codingStandardsIgnoreEnd + + if ( is_bool( $value ) ) { + return $value; + } else if ( is_int( $value ) && ( 0 === $value || 1 === $value ) ) { + return (bool) $value; + } else if ( ( is_float( $value ) && ! is_nan( $value ) ) && ( (float) 0 === $value || (float) 1 === $value ) ) { + return (bool) $value; + } else if ( is_string( $value ) ) { + $value = trim( $value ); + if ( in_array( $value, $true, true ) ) { + return true; + } else if ( in_array( $value, $false, true ) ) { + return false; + } else { + return false; + } + } + + return false; + } + } // End of class TGMPA_Utils +} // End of class_exists wrapper diff --git a/lang/delibera-en_US.mo b/languages/delibera-en_US.mo similarity index 100% rename from lang/delibera-en_US.mo rename to languages/delibera-en_US.mo diff --git a/lang/delibera-en_US.po b/languages/delibera-en_US.po similarity index 100% rename from lang/delibera-en_US.po rename to languages/delibera-en_US.po diff --git a/lang/delibera-es_ES.mo b/languages/delibera-es_ES.mo similarity index 100% rename from lang/delibera-es_ES.mo rename to languages/delibera-es_ES.mo diff --git a/lang/delibera-es_ES.po b/languages/delibera-es_ES.po similarity index 100% rename from lang/delibera-es_ES.po rename to languages/delibera-es_ES.po diff --git a/lang/delibera.pot b/languages/delibera.pot similarity index 100% rename from lang/delibera.pot rename to languages/delibera.pot diff --git a/languages/tgmpa.pot b/languages/tgmpa.pot new file mode 100755 index 0000000..db54b5f --- /dev/null +++ b/languages/tgmpa.pot @@ -0,0 +1,458 @@ +msgid "" +msgstr "" +"Project-Id-Version: TGM-Plugin-Activation\n" +"POT-Creation-Date: 2015-05-11 21:55+0100\n" +"PO-Revision-Date: 2015-05-11 21:56+0100\n" +"Last-Translator: Juliette Reinders Folmer \n" +"Language-Team: TGMPA\n" +"Language: en_US\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 1.7.5\n" +"X-Poedit-Basepath: ..\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;" +"esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;" +"_nx_noop:3c,1,2;__ngettext_noop:1,2\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Poedit-SearchPath-0: .\n" +"X-Poedit-SearchPathExcluded-0: *.js\n" +"X-Poedit-SearchPathExcluded-1: example.php\n" + +#: class-tgm-plugin-activation.php:303 +msgid "Install Required Plugins" +msgstr "" + +#: class-tgm-plugin-activation.php:304 +msgid "Install Plugins" +msgstr "" + +#: class-tgm-plugin-activation.php:305 +#, php-format +msgid "Installing Plugin: %s" +msgstr "" + +#: class-tgm-plugin-activation.php:306 +msgid "Something went wrong with the plugin API." +msgstr "" + +#: class-tgm-plugin-activation.php:308 +#, php-format +msgid "This theme requires the following plugin: %1$s." +msgid_plural "This theme requires the following plugins: %1$s." +msgstr[0] "" +msgstr[1] "" + +#: class-tgm-plugin-activation.php:313 +#, php-format +msgid "This theme recommends the following plugin: %1$s." +msgid_plural "This theme recommends the following plugins: %1$s." +msgstr[0] "" +msgstr[1] "" + +#: class-tgm-plugin-activation.php:318 +#, php-format +msgid "" +"Sorry, but you do not have the correct permissions to install the %1$s " +"plugin." +msgid_plural "" +"Sorry, but you do not have the correct permissions to install the %1$s " +"plugins." +msgstr[0] "" +msgstr[1] "" + +#: class-tgm-plugin-activation.php:323 +#, php-format +msgid "" +"The following plugin needs to be updated to its latest version to ensure " +"maximum compatibility with this theme: %1$s." +msgid_plural "" +"The following plugins need to be updated to their latest version to ensure " +"maximum compatibility with this theme: %1$s." +msgstr[0] "" +msgstr[1] "" + +#: class-tgm-plugin-activation.php:328 +#, php-format +msgid "There is an update available for: %1$s." +msgid_plural "There are updates available for the following plugins: %1$s." +msgstr[0] "" +msgstr[1] "" + +#: class-tgm-plugin-activation.php:333 +#, php-format +msgid "" +"Sorry, but you do not have the correct permissions to update the %1$s plugin." +msgid_plural "" +"Sorry, but you do not have the correct permissions to update the %1$s " +"plugins." +msgstr[0] "" +msgstr[1] "" + +#: class-tgm-plugin-activation.php:338 +#, php-format +msgid "The following required plugin is currently inactive: %1$s." +msgid_plural "The following required plugins are currently inactive: %1$s." +msgstr[0] "" +msgstr[1] "" + +#: class-tgm-plugin-activation.php:343 +#, php-format +msgid "The following recommended plugin is currently inactive: %1$s." +msgid_plural "The following recommended plugins are currently inactive: %1$s." +msgstr[0] "" +msgstr[1] "" + +#: class-tgm-plugin-activation.php:348 +#, php-format +msgid "" +"Sorry, but you do not have the correct permissions to activate the %1$s " +"plugin." +msgid_plural "" +"Sorry, but you do not have the correct permissions to activate the %1$s " +"plugins." +msgstr[0] "" +msgstr[1] "" + +#: class-tgm-plugin-activation.php:353 +msgid "Begin installing plugin" +msgid_plural "Begin installing plugins" +msgstr[0] "" +msgstr[1] "" + +#: class-tgm-plugin-activation.php:358 +msgid "Begin updating plugin" +msgid_plural "Begin updating plugins" +msgstr[0] "" +msgstr[1] "" + +#: class-tgm-plugin-activation.php:363 +msgid "Begin activating plugin" +msgid_plural "Begin activating plugins" +msgstr[0] "" +msgstr[1] "" + +#: class-tgm-plugin-activation.php:368 +msgid "Return to Required Plugins Installer" +msgstr "" + +#: class-tgm-plugin-activation.php:369 +msgid "Return to the dashboard" +msgstr "" + +#: class-tgm-plugin-activation.php:370 class-tgm-plugin-activation.php:3016 +msgid "Plugin activated successfully." +msgstr "" + +#: class-tgm-plugin-activation.php:371 class-tgm-plugin-activation.php:2837 +msgid "The following plugin was activated successfully:" +msgid_plural "The following plugins were activated successfully:" +msgstr[0] "" +msgstr[1] "" + +#: class-tgm-plugin-activation.php:372 +#, php-format +msgid "No action taken. Plugin %1$s was already active." +msgstr "" + +#: class-tgm-plugin-activation.php:373 +#, php-format +msgid "" +"Plugin not activated. A higher version of %s is needed for this theme. " +"Please update the plugin." +msgstr "" + +#: class-tgm-plugin-activation.php:374 +#, php-format +msgid "All plugins installed and activated successfully. %1$s" +msgstr "" + +#: class-tgm-plugin-activation.php:375 +msgid "Dismiss this notice" +msgstr "" + +#: class-tgm-plugin-activation.php:376 +msgid "Please contact the administrator of this site for help." +msgstr "" + +#: class-tgm-plugin-activation.php:494 +msgid "This plugin needs to be updated to be compatible with your theme." +msgstr "" + +#: class-tgm-plugin-activation.php:495 +msgid "Update Required" +msgstr "" + +#: class-tgm-plugin-activation.php:612 +msgid "Set the parent_slug config variable instead." +msgstr "" + +#: class-tgm-plugin-activation.php:811 class-tgm-plugin-activation.php:3434 +msgid "Return to the Dashboard" +msgstr "" + +#: class-tgm-plugin-activation.php:926 +msgid "" +"The remote plugin package does not contain a folder with the desired slug " +"and renaming did not work." +msgstr "" + +#: class-tgm-plugin-activation.php:926 class-tgm-plugin-activation.php:930 +msgid "" +"Please contact the plugin provider and ask them to package their plugin " +"according to the WordPress guidelines." +msgstr "" + +#: class-tgm-plugin-activation.php:930 +msgid "" +"The remote plugin package consists of more than one file, but the files are " +"not packaged in a folder." +msgstr "" + +#: class-tgm-plugin-activation.php:1115 class-tgm-plugin-activation.php:2833 +msgctxt "plugin A *and* plugin B" +msgid "and" +msgstr "" + +#: class-tgm-plugin-activation.php:1901 +#, php-format +msgctxt "%s = version number" +msgid "TGMPA v%s" +msgstr "" + +#: class-tgm-plugin-activation.php:2182 +msgid "Required" +msgstr "" + +#: class-tgm-plugin-activation.php:2185 +msgid "Recommended" +msgstr "" + +#: class-tgm-plugin-activation.php:2202 +msgid "WordPress Repository" +msgstr "" + +#: class-tgm-plugin-activation.php:2206 +msgid "External Source" +msgstr "" + +#: class-tgm-plugin-activation.php:2210 +msgid "Pre-Packaged" +msgstr "" + +#: class-tgm-plugin-activation.php:2229 +msgid "Not Installed" +msgstr "" + +#: class-tgm-plugin-activation.php:2233 +msgid "Installed But Not Activated" +msgstr "" + +#: class-tgm-plugin-activation.php:2235 +msgid "Active" +msgstr "" + +#: class-tgm-plugin-activation.php:2241 +msgid "Required Update not Available" +msgstr "" + +#: class-tgm-plugin-activation.php:2244 +msgid "Requires Update" +msgstr "" + +#: class-tgm-plugin-activation.php:2247 +msgid "Update recommended" +msgstr "" + +#: class-tgm-plugin-activation.php:2255 +#, php-format +msgctxt "%1$s = install status, %2$s = update status" +msgid "%1$s, %2$s" +msgstr "" + +#: class-tgm-plugin-activation.php:2304 +#, php-format +msgctxt "plugins" +msgid "All (%s)" +msgid_plural "All (%s)" +msgstr[0] "" +msgstr[1] "" + +#: class-tgm-plugin-activation.php:2308 +#, php-format +msgid "To Install (%s)" +msgid_plural "To Install (%s)" +msgstr[0] "" +msgstr[1] "" + +#: class-tgm-plugin-activation.php:2312 +#, php-format +msgid "Update Available (%s)" +msgid_plural "Update Available (%s)" +msgstr[0] "" +msgstr[1] "" + +#: class-tgm-plugin-activation.php:2316 +#, php-format +msgid "To Activate (%s)" +msgid_plural "To Activate (%s)" +msgstr[0] "" +msgstr[1] "" + +#: class-tgm-plugin-activation.php:2409 +msgctxt "as in: \"version nr unknown\"" +msgid "unknown" +msgstr "" + +#: class-tgm-plugin-activation.php:2417 +msgid "Installed version:" +msgstr "" + +#: class-tgm-plugin-activation.php:2425 +msgid "Minimum required version:" +msgstr "" + +#: class-tgm-plugin-activation.php:2437 +msgid "Available version:" +msgstr "" + +#: class-tgm-plugin-activation.php:2461 +#, php-format +msgid "" +"No plugins to install, update or activate. Return to the " +"Dashboard" +msgstr "" + +#: class-tgm-plugin-activation.php:2477 +msgid "Plugin" +msgstr "" + +#: class-tgm-plugin-activation.php:2478 +msgid "Source" +msgstr "" + +#: class-tgm-plugin-activation.php:2479 +msgid "Type" +msgstr "" + +#: class-tgm-plugin-activation.php:2483 +msgid "Version" +msgstr "" + +#: class-tgm-plugin-activation.php:2484 +msgid "Status" +msgstr "" + +#: class-tgm-plugin-activation.php:2508 +#, php-format +msgctxt "%2$s = plugin name in screen reader markup" +msgid "Install %2$s" +msgstr "" + +#: class-tgm-plugin-activation.php:2514 +#, php-format +msgctxt "%2$s = plugin name in screen reader markup" +msgid "Update %2$s" +msgstr "" + +#: class-tgm-plugin-activation.php:2520 +#, php-format +msgctxt "%2$s = plugin name in screen reader markup" +msgid "Activate %2$s" +msgstr "" + +#: class-tgm-plugin-activation.php:2591 +msgid "Upgrade message from the plugin author:" +msgstr "" + +#: class-tgm-plugin-activation.php:2624 +msgid "Install" +msgstr "" + +#: class-tgm-plugin-activation.php:2630 +msgid "Update" +msgstr "" + +#: class-tgm-plugin-activation.php:2633 +msgid "Activate" +msgstr "" + +#: class-tgm-plugin-activation.php:2694 +msgid "No plugins are available to be installed at this time." +msgstr "" + +#: class-tgm-plugin-activation.php:2696 +msgid "No plugins are available to be updated at this time." +msgstr "" + +#: class-tgm-plugin-activation.php:2819 +msgid "No plugins are available to be activated at this time." +msgstr "" + +#: class-tgm-plugin-activation.php:3015 +msgid "Plugin activation failed." +msgstr "" + +#: class-tgm-plugin-activation.php:3354 +#, php-format +msgid "Updating Plugin %1$s (%2$d/%3$d)" +msgstr "" + +#: class-tgm-plugin-activation.php:3358 +#, php-format +msgid "An error occurred while installing %1$s: %2$s." +msgstr "" + +#: class-tgm-plugin-activation.php:3359 +#, php-format +msgid "The installation of %1$s failed." +msgstr "" + +#: class-tgm-plugin-activation.php:3363 +msgid "" +"The installation and activation process is starting. This process may take a " +"while on some hosts, so please be patient." +msgstr "" + +#: class-tgm-plugin-activation.php:3364 +#, php-format +msgid "%1$s installed and activated successfully." +msgstr "" + +#: class-tgm-plugin-activation.php:3364 class-tgm-plugin-activation.php:3371 +msgid "Show Details" +msgstr "" + +#: class-tgm-plugin-activation.php:3364 class-tgm-plugin-activation.php:3371 +msgid "Hide Details" +msgstr "" + +#: class-tgm-plugin-activation.php:3365 +msgid "All installations and activations have been completed." +msgstr "" + +#: class-tgm-plugin-activation.php:3366 +#, php-format +msgid "Installing and Activating Plugin %1$s (%2$d/%3$d)" +msgstr "" + +#: class-tgm-plugin-activation.php:3370 +msgid "" +"The installation process is starting. This process may take a while on some " +"hosts, so please be patient." +msgstr "" + +#: class-tgm-plugin-activation.php:3371 +#, php-format +msgid "%1$s installed successfully." +msgstr "" + +#: class-tgm-plugin-activation.php:3372 +msgid "All installations have been completed." +msgstr "" + +#: class-tgm-plugin-activation.php:3373 +#, php-format +msgid "Installing Plugin %1$s (%2$d/%3$d)" +msgstr "" From a7b01348c8ca2067548a7c2af29b425cfb0c46dc Mon Sep 17 00:00:00 2001 From: Making GitHub Delicious Date: Fri, 19 Feb 2016 10:44:49 -0700 Subject: [PATCH 036/435] add waffle.io badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7480fec..e331559 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +[![Stories in Ready](https://badge.waffle.io/redelivre/delibera.png?label=ready&title=Ready)](https://waffle.io/redelivre/delibera) Delibera ======== From 86efdb53487946def15d319d7d8fad90bada934b Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Mon, 22 Feb 2016 23:49:41 -0300 Subject: [PATCH 037/435] using namespaces --- delibera_flow.php | 4 ++-- modules/discussion/discussion.php | 4 ++-- modules/rapporteur/rapporteur.php | 4 ++-- modules/validation/validation.php | 4 ++-- modules/vote/vote.php | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/delibera_flow.php b/delibera_flow.php index 07d6793..002a8b7 100644 --- a/delibera_flow.php +++ b/delibera_flow.php @@ -6,7 +6,7 @@ // PHP 5.3 and later: namespace Delibera; -class DeliberaFlow +class Flow { public function __construct() { @@ -107,4 +107,4 @@ public function publishPauta($postID, $opt, $alterar) } -$DeliberaFlow = new DeliberaFlow(); +$DeliberaFlow = new \Delibera\Flow(); diff --git a/modules/discussion/discussion.php b/modules/discussion/discussion.php index 96df622..06bf340 100644 --- a/modules/discussion/discussion.php +++ b/modules/discussion/discussion.php @@ -3,7 +3,7 @@ // PHP 5.3 and later: namespace Delibera\Modules; -class DeliberaDiscussion +class Discussion { public function __construct() @@ -214,6 +214,6 @@ public function createPautaAtFront($opt) } } -$DeliberaDiscussion = new DeliberaDiscussion(); +$DeliberaDiscussion = new \Delibera\Modules\Discussion(); diff --git a/modules/rapporteur/rapporteur.php b/modules/rapporteur/rapporteur.php index 3870bed..611ed32 100644 --- a/modules/rapporteur/rapporteur.php +++ b/modules/rapporteur/rapporteur.php @@ -3,7 +3,7 @@ // PHP 5.3 and later: namespace Delibera\Modules; -class DeliberaRapporteur +class Rapporteur { public function __construct() @@ -270,6 +270,6 @@ public function createPautaAtFront($opt) } } -$DeliberaRapporteur = new DeliberaRapporteur(); +$DeliberaRapporteur = new \Delibera\Modules\Rapporteur(); diff --git a/modules/validation/validation.php b/modules/validation/validation.php index 9a7f368..3941e4f 100644 --- a/modules/validation/validation.php +++ b/modules/validation/validation.php @@ -3,7 +3,7 @@ // PHP 5.3 and later: namespace Delibera\Modules; -class DeliberaValidation +class Validation { public function __construct() @@ -271,6 +271,6 @@ public function createPautaAtFront($opt) } } -$DeliberaValidation = new DeliberaValidation(); +$DeliberaValidation = new \Delibera\Modules\Validation(); diff --git a/modules/vote/vote.php b/modules/vote/vote.php index a57f63a..fa9b40d 100644 --- a/modules/vote/vote.php +++ b/modules/vote/vote.php @@ -3,7 +3,7 @@ // PHP 5.3 and later: namespace Delibera\Modules; -class DeliberaVote +class Vote { public function __construct() @@ -203,6 +203,6 @@ public function createPautaAtFront($opt) } } -$DeliberaVote = new DeliberaVote(); +$DeliberaVote = new \Delibera\Modules\Vote(); From da8015da41f95d3d5ad1497b162baa8fcdf90208 Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Wed, 24 Feb 2016 01:34:11 -0300 Subject: [PATCH 038/435] register flow modules --- delibera_flow.php | 196 ++++++++++++++++++++++++++++-- delibera_topic_deadline.php | 114 ----------------- modules/discussion/discussion.php | 22 +++- modules/rapporteur/rapporteur.php | 14 ++- modules/validation/validation.php | 22 +++- modules/vote/vote.php | 13 +- 6 files changed, 255 insertions(+), 126 deletions(-) diff --git a/delibera_flow.php b/delibera_flow.php index 002a8b7..2c106b6 100644 --- a/delibera_flow.php +++ b/delibera_flow.php @@ -14,6 +14,8 @@ public function __construct() add_filter('delivera_config_page_rows', array($this, 'configPageRows'), 10, 2); add_filter('delibera-pre-main-config-save', array($this, 'preMainConfigSave')); add_action('delibera_topic_meta', array($this, 'topicMeta'), 10, 5); + add_filter('delibera_save_post_metas', array($this, 'savePostMetas'), 10, 2); + add_action('delibera_publish_pauta', array($this, 'publishPauta'), 10, 3); } @@ -24,7 +26,7 @@ public function __construct() */ public function getMainConfig($opts) { - $opts['flow'] = array('validacao', 'discussao', 'elegerelator', 'relatoria', 'emvotacao', 'comresolucao'); + $opts['delibera_flow'] = array('validacao', 'discussao', 'elegerelator', 'relatoria', 'emvotacao', 'comresolucao'); return $opts; } @@ -35,9 +37,9 @@ public function getMainConfig($opts) public function configPageRows($rows, $opt) { $rows[] = array( - "id" => "flow", + "id" => "delibera_flow", "label" => __('Fluxo padrão de uma pauta?', 'delibera'), - "content" => '' + "content" => '' ); return $rows; } @@ -48,9 +50,9 @@ public function configPageRows($rows, $opt) */ public function preMainConfigSave($opts) { - if(array_key_exists('flow', $opts) && !is_array($opts['flow'])) + if(array_key_exists('delibera_flow', $opts) && !is_array($opts['delibera_flow'])) { - $opts['flow'] = array('validacao', 'discussao', 'elegerelator', 'relatoria', 'emvotacao', 'comresolucao');//explode(',', trim($opts['flow'])); + $opts['delibera_flow'] = explode(',', trim($opts['delibera_flow'])); } return $opts; } @@ -67,15 +69,193 @@ public function preMainConfigSave($opts) */ public function topicMeta($post, $custom, $options_plugin_delibera, $situacao, $disable_edicao) { - $flow = implode(',', array_map("htmlspecialchars", $options_plugin_delibera['flow']) ); + $flow = implode(',', array_map("htmlspecialchars", $this->get($post->ID)) ); ?>

- - id="flow" name="flow" class="flow widefat" value=""/> + + id="delibera_flow" name="delibera_flow" class="delibera_flow widefat" value=""/>

0) + { + return $flow; + } + else + { + return $default_flow; + } + } + + /** + * List of Modules and each situation for get information about the module, like deadline + */ + public function getFlowModules() + { + $modules = array(); + /* Modules need to register to make part of flow + * Form: $modules['situacao'] = ModuleObject; + */ + $modules = apply_filters('delibera_register_flow_module', $modules); + return $modules; + } + + public function getLastDeadline($situacao, $post_id = false) + { + if($post_id == false) + { + $post_id = get_the_ID(); + } + $flow = $this->get($post_id); + $modules = $this->getFlowModules(); + + $now = array_search($situacao, $flow); + if(($now - 1) > 0) + { + $modules[$flow[$now - 1]]->getDeadline(); + } + } + + /** + * + * Faz agendamento das datas para seguir passos + * 1) Excluir ao atingir data de validação se não foi validade + * 2) Iniciar votação se tiver encaminhamento, ou novo prazo, caso contrário + * 3) Fim da votação + * @param $prazo_validacao + * @param $prazo_discussao + * @param $prazo_votacao + */ + public function criarAgenda($postID, $prazo_validacao, $prazo_discussao, $prazo_votacao, $prazo_relatoria = false, $prazo_eleicao_relator = false) + { + + if($prazo_validacao !== false) + { + delibera_add_cron( + delibera_tratar_data($prazo_validacao), + 'delibera_tratar_prazo_validacao', + array( + 'post_ID' => $postID, + 'prazo_validacao' => $prazo_validacao + ) + ); + delibera_add_cron( + strtotime("-1 day", delibera_tratar_data($prazo_validacao)), + 'delibera_notificar_fim_prazo', + array( + 'post_ID' => $postID, + 'prazo_validacao' => $prazo_validacao + ) + ); + } + + if($prazo_discussao !== false) + { + delibera_add_cron( + delibera_tratar_data($prazo_discussao), + 'delibera_tratar_prazo_discussao', + array( + 'post_ID' => $postID, + 'prazo_discussao' => $prazo_discussao + ) + ); + delibera_add_cron( + strtotime("-1 day", delibera_tratar_data($prazo_discussao)), + 'delibera_notificar_fim_prazo', + array( + 'post_ID' => $postID, + 'prazo_discussao' => $prazo_discussao + ) + ); + } + + if($prazo_eleicao_relator != false) + { + delibera_add_cron( + delibera_tratar_data($prazo_eleicao_relator), + 'delibera_tratar_prazo_eleicao_relator', + array( + 'post_ID' => $postID, + 'prazo_votacao' => $prazo_eleicao_relator + ) + ); + delibera_add_cron( + strtotime("-1 day", delibera_tratar_data($prazo_eleicao_relator)), + 'delibera_notificar_fim_prazo', + array( + 'post_ID' => $postID, + 'prazo_votacao' => $prazo_eleicao_relator + ) + ); + } + + if($prazo_relatoria != false) + { + delibera_add_cron( + delibera_tratar_data($prazo_relatoria), + 'delibera_tratar_prazo_relatoria', + array( + 'post_ID' => $postID, + 'prazo_votacao' => $prazo_relatoria + ) + ); + delibera_add_cron( + strtotime("-1 day", delibera_tratar_data($prazo_relatoria)), + 'delibera_notificar_fim_prazo', + array( + 'post_ID' => $postID, + 'prazo_votacao' => $prazo_relatoria + ) + ); + } + + if($prazo_votacao != false) + { + delibera_add_cron( + delibera_tratar_data($prazo_votacao), + 'delibera_tratar_prazo_votacao', + array( + 'post_ID' => $postID, + 'prazo_votacao' => $prazo_votacao + ) + ); + delibera_add_cron( + strtotime("-1 day", delibera_tratar_data($prazo_votacao)), + 'delibera_notificar_fim_prazo', + array( + 'post_ID' => $postID, + 'prazo_votacao' => $prazo_votacao + ) + ); + } + } + + public function savePostMetas($events_meta, $opt) + { + if(array_key_exists('delibera_flow', $_POST) ) + { + $events_meta['delibera_flow'] = explode(',', trim($_POST['delibera_flow'])); + } + + return $events_meta; + } + public function publishPauta($postID, $opt, $alterar) { $prazo_validacao = get_post_meta($postID, 'prazo_validacao', true); diff --git a/delibera_topic_deadline.php b/delibera_topic_deadline.php index c21d7ca..6f246ae 100644 --- a/delibera_topic_deadline.php +++ b/delibera_topic_deadline.php @@ -74,120 +74,6 @@ function delibera_reabrir_pauta_action() require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_cron.php'; -/** - * - * Faz agendamento das datas para seguir passos - * 1) Excluir ao atingir data de validação se não foi validade - * 2) Iniciar votação se tiver encaminhamento, ou novo prazo, caso contrário - * 3) Fim da votação - * @param $prazo_validacao - * @param $prazo_discussao - * @param $prazo_votacao - */ -function delibera_criar_agenda($postID, $prazo_validacao, $prazo_discussao, $prazo_votacao, $prazo_relatoria = false, $prazo_eleicao_relator = false) -{ - - if($prazo_validacao !== false) - { - delibera_add_cron( - delibera_tratar_data($prazo_validacao), - 'delibera_tratar_prazo_validacao', - array( - 'post_ID' => $postID, - 'prazo_validacao' => $prazo_validacao - ) - ); - delibera_add_cron( - strtotime("-1 day", delibera_tratar_data($prazo_validacao)), - 'delibera_notificar_fim_prazo', - array( - 'post_ID' => $postID, - 'prazo_validacao' => $prazo_validacao - ) - ); - } - - if($prazo_discussao !== false) - { - delibera_add_cron( - delibera_tratar_data($prazo_discussao), - 'delibera_tratar_prazo_discussao', - array( - 'post_ID' => $postID, - 'prazo_discussao' => $prazo_discussao - ) - ); - delibera_add_cron( - strtotime("-1 day", delibera_tratar_data($prazo_discussao)), - 'delibera_notificar_fim_prazo', - array( - 'post_ID' => $postID, - 'prazo_discussao' => $prazo_discussao - ) - ); - } - - if($prazo_eleicao_relator != false) - { - delibera_add_cron( - delibera_tratar_data($prazo_eleicao_relator), - 'delibera_tratar_prazo_eleicao_relator', - array( - 'post_ID' => $postID, - 'prazo_votacao' => $prazo_eleicao_relator - ) - ); - delibera_add_cron( - strtotime("-1 day", delibera_tratar_data($prazo_eleicao_relator)), - 'delibera_notificar_fim_prazo', - array( - 'post_ID' => $postID, - 'prazo_votacao' => $prazo_eleicao_relator - ) - ); - } - - if($prazo_relatoria != false) - { - delibera_add_cron( - delibera_tratar_data($prazo_relatoria), - 'delibera_tratar_prazo_relatoria', - array( - 'post_ID' => $postID, - 'prazo_votacao' => $prazo_relatoria - ) - ); - delibera_add_cron( - strtotime("-1 day", delibera_tratar_data($prazo_relatoria)), - 'delibera_notificar_fim_prazo', - array( - 'post_ID' => $postID, - 'prazo_votacao' => $prazo_relatoria - ) - ); - } - - if($prazo_votacao != false) - { - delibera_add_cron( - delibera_tratar_data($prazo_votacao), - 'delibera_tratar_prazo_votacao', - array( - 'post_ID' => $postID, - 'prazo_votacao' => $prazo_votacao - ) - ); - delibera_add_cron( - strtotime("-1 day", delibera_tratar_data($prazo_votacao)), - 'delibera_notificar_fim_prazo', - array( - 'post_ID' => $postID, - 'prazo_votacao' => $prazo_votacao - ) - ); - } -} - function delibera_tratar_prazos($args) { $situacao = delibera_get_situacao($args['post_ID']); diff --git a/modules/discussion/discussion.php b/modules/discussion/discussion.php index 06bf340..4c2384e 100644 --- a/modules/discussion/discussion.php +++ b/modules/discussion/discussion.php @@ -17,6 +17,7 @@ public function __construct() add_filter('delibera_check_post_data', array($this, 'checkPostData'), 10, 3); add_filter('delibera_save_post_metas', array($this, 'savePostMetas'), 10, 2); add_action('delibera_create_pauta_frontend', array($this, 'createPautaAtFront')); + add_filter('delibera_register_flow_module', array($this, 'registerFlowModule')); add_shortcode( 'delibera_lista_de_pautas', array($this, 'replacePautas' )); } @@ -41,6 +42,16 @@ public function registerTax() } } + /** + * Register situacao objects for flow treat + * @param array $modules + */ + public function registerFlowModule($modules) + { + $modules['discussao'] = $this; + return $modules; + } + /** * Append configurations * @param array $opts @@ -123,7 +134,7 @@ public function topicMeta($post, $custom, $options_plugin_delibera, $situacao, $ public function publishPauta($postID, $opt, $alterar) { - if(/*!array_key_exists('discussao', $opt) || $opt['discussao'] == 'S' && TODO check activation */ $opt['flow'][0] == 'discussao' ) + if(/*!array_key_exists('discussao', $opt) || $opt['discussao'] == 'S' && TODO check activation */ $opt['delibera_flow'][0] == 'discussao' ) { if(!$alterar) { @@ -213,6 +224,15 @@ public function createPautaAtFront($opt) } } + public function getDeadline($post_id = false) + { + if($post_id == false) + { + $post_id = get_the_ID(); + } + return get_post_meta($post_id, 'prazo_discussao', true); + } + } $DeliberaDiscussion = new \Delibera\Modules\Discussion(); diff --git a/modules/rapporteur/rapporteur.php b/modules/rapporteur/rapporteur.php index 611ed32..1afb493 100644 --- a/modules/rapporteur/rapporteur.php +++ b/modules/rapporteur/rapporteur.php @@ -17,6 +17,7 @@ public function __construct() add_filter('delibera_check_post_data', array($this, 'checkPostData'), 10, 3); add_filter('delibera_save_post_metas', array($this, 'savePostMetas'), 10, 2); add_action('delibera_create_pauta_frontend', array($this, 'createPautaAtFront')); + add_filter('delibera_register_flow_module', array($this, 'registerFlowModule')); } @@ -60,6 +61,17 @@ public function registerTax() } } + /** + * Register situacao objects for flow treat + * @param array $modules + */ + public function registerFlowModule($modules) + { + $modules['relatoria'] = $this; + $modules['eleicaoredator'] = $this; + return $modules; + } + /** * Append configurations * @param array $opts @@ -181,7 +193,7 @@ public function topicMeta($post, $custom, $options_plugin_delibera, $situacao, $ public function publishPauta($postID, $opt, $alterar) { - if(!array_key_exists('relatoria', $opt) || $opt['relatoria'] == 'S' && $opt['flow'][0] == 'relatoria' ) + if(!array_key_exists('relatoria', $opt) || $opt['relatoria'] == 'S' && $opt['delibera_flow'][0] == 'relatoria' ) { if(!$alterar) { diff --git a/modules/validation/validation.php b/modules/validation/validation.php index 3941e4f..84eb009 100644 --- a/modules/validation/validation.php +++ b/modules/validation/validation.php @@ -17,6 +17,7 @@ public function __construct() add_filter('delibera_check_post_data', array($this, 'checkPostData'), 10, 3); add_filter('delibera_save_post_metas', array($this, 'savePostMetas'), 10, 2); add_action('delibera_create_pauta_frontend', array($this, 'createPautaAtFront')); + add_filter('delibera_register_flow_module', array($this, 'registerFlowModule')); add_shortcode( 'delibera_lista_de_propostas', array($this, 'replacePropostas' )); } @@ -55,6 +56,17 @@ public function registerTax() ); } } + + /** + * Register situacao objects for flow treat + * @param array $modules + */ + public function registerFlowModule($modules) + { + $modules['validacao'] = $this; + $modules['naovalidada'] = $this; + return $modules; + } /** * Append configurations @@ -157,7 +169,7 @@ public function topicMeta($post, $custom, $options_plugin_delibera, $situacao, $ public function publishPauta($postID, $opt, $alterar) { - if(!array_key_exists('validacao', $opt) || $opt['validacao'] == 'S' && $opt['flow'][0] == 'validacao' ) + if(!array_key_exists('validacao', $opt) || $opt['validacao'] == 'S' && $opt['delibera_flow'][0] == 'validacao' ) { if(!$alterar) { @@ -270,6 +282,14 @@ public function createPautaAtFront($opt) } } + public function getDeadline($post_id = false) + { + if($post_id == false) + { + $post_id = get_the_ID(); + } + return get_post_meta($post_id, 'prazo_validacao', true); + } } $DeliberaValidation = new \Delibera\Modules\Validation(); diff --git a/modules/vote/vote.php b/modules/vote/vote.php index fa9b40d..0ce2313 100644 --- a/modules/vote/vote.php +++ b/modules/vote/vote.php @@ -17,6 +17,7 @@ public function __construct() add_filter('delibera_check_post_data', array($this, 'checkPostData'), 10, 3); add_filter('delibera_save_post_metas', array($this, 'savePostMetas'), 10, 2); add_action('delibera_create_pauta_frontend', array($this, 'createPautaAtFront')); + add_filter('delibera_register_flow_module', array($this, 'registerFlowModule')); } @@ -40,6 +41,16 @@ public function registerTax() } } + /** + * Register situacao objects for flow treat + * @param array $modules + */ + public function registerFlowModule($modules) + { + $modules['emvotacao'] = $this; + return $modules; + } + /** * Append configurations * @param array $opts @@ -118,7 +129,7 @@ public function topicMeta($post, $custom, $options_plugin_delibera, $situacao, $ public function publishPauta($postID, $opt, $alterar) { - if(!array_key_exists('relatoria', $opt) || $opt['relatoria'] == 'S' && $opt['flow'][0] == 'relatoria' ) + if(!array_key_exists('relatoria', $opt) || $opt['relatoria'] == 'S' && $opt['delibera_flow'][0] == 'relatoria' ) { if(!$alterar) { From e5ba87840efeb6a4730081bceb410b4b5233e2c3 Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Wed, 24 Feb 2016 01:45:42 -0300 Subject: [PATCH 039/435] get module deadline --- delibera_flow.php | 8 ++++++-- modules/rapporteur/rapporteur.php | 18 ++++++++++++++++++ modules/vote/vote.php | 9 +++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/delibera_flow.php b/delibera_flow.php index 2c106b6..3d1c7bb 100644 --- a/delibera_flow.php +++ b/delibera_flow.php @@ -126,9 +126,13 @@ public function getLastDeadline($situacao, $post_id = false) $modules = $this->getFlowModules(); $now = array_search($situacao, $flow); - if(($now - 1) > 0) + if(($now - 1) > 0 && array_key_exists($flow[$now - 1], $modules) && property_exists($modules[$flow[$now - 1]], 'getDeadline')) { - $modules[$flow[$now - 1]]->getDeadline(); + return $modules[$flow[$now - 1]]->getDeadline(); + } + else + { + return date('d/m/Y'); } } diff --git a/modules/rapporteur/rapporteur.php b/modules/rapporteur/rapporteur.php index 1afb493..764393a 100644 --- a/modules/rapporteur/rapporteur.php +++ b/modules/rapporteur/rapporteur.php @@ -281,6 +281,24 @@ public function createPautaAtFront($opt) } } + public function getDeadline($post_id = false) + { + if($post_id == false) + { + $post_id = get_the_ID(); + } + $opt = delibera_get_config(); + /** + * Add time to Relator election when activated + */ + if($opt['eleicao_relator'] == 'S') + { + return date('d/m/Y', strtotime ('+'.$opt['dias_votacao_relator'].' DAYS', delibera_tratar_data(get_post_meta($post_id, 'prazo_relatoria', true)))); + } + + return get_post_meta($post_id, 'prazo_relatoria', true); + } + } $DeliberaRapporteur = new \Delibera\Modules\Rapporteur(); diff --git a/modules/vote/vote.php b/modules/vote/vote.php index 0ce2313..1f28ddd 100644 --- a/modules/vote/vote.php +++ b/modules/vote/vote.php @@ -213,6 +213,15 @@ public function createPautaAtFront($opt) } } + public function getDeadline($post_id = false) + { + if($post_id == false) + { + $post_id = get_the_ID(); + } + return get_post_meta($post_id, 'prazo_votacao', true); + } + } $DeliberaVote = new \Delibera\Modules\Vote(); From 1dec36b7a96cd25274c14e15d123ae7da9097154 Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Wed, 24 Feb 2016 02:12:46 -0300 Subject: [PATCH 040/435] add calendar deadline notice and next step --- delibera_flow.php | 114 ------------------------------ modules/discussion/discussion.php | 22 ++++++ modules/rapporteur/rapporteur.php | 45 ++++++++++++ modules/validation/validation.php | 22 ++++++ modules/vote/vote.php | 28 ++++++++ 5 files changed, 117 insertions(+), 114 deletions(-) diff --git a/delibera_flow.php b/delibera_flow.php index 3d1c7bb..fc9e96e 100644 --- a/delibera_flow.php +++ b/delibera_flow.php @@ -136,120 +136,6 @@ public function getLastDeadline($situacao, $post_id = false) } } - /** - * - * Faz agendamento das datas para seguir passos - * 1) Excluir ao atingir data de validação se não foi validade - * 2) Iniciar votação se tiver encaminhamento, ou novo prazo, caso contrário - * 3) Fim da votação - * @param $prazo_validacao - * @param $prazo_discussao - * @param $prazo_votacao - */ - public function criarAgenda($postID, $prazo_validacao, $prazo_discussao, $prazo_votacao, $prazo_relatoria = false, $prazo_eleicao_relator = false) - { - - if($prazo_validacao !== false) - { - delibera_add_cron( - delibera_tratar_data($prazo_validacao), - 'delibera_tratar_prazo_validacao', - array( - 'post_ID' => $postID, - 'prazo_validacao' => $prazo_validacao - ) - ); - delibera_add_cron( - strtotime("-1 day", delibera_tratar_data($prazo_validacao)), - 'delibera_notificar_fim_prazo', - array( - 'post_ID' => $postID, - 'prazo_validacao' => $prazo_validacao - ) - ); - } - - if($prazo_discussao !== false) - { - delibera_add_cron( - delibera_tratar_data($prazo_discussao), - 'delibera_tratar_prazo_discussao', - array( - 'post_ID' => $postID, - 'prazo_discussao' => $prazo_discussao - ) - ); - delibera_add_cron( - strtotime("-1 day", delibera_tratar_data($prazo_discussao)), - 'delibera_notificar_fim_prazo', - array( - 'post_ID' => $postID, - 'prazo_discussao' => $prazo_discussao - ) - ); - } - - if($prazo_eleicao_relator != false) - { - delibera_add_cron( - delibera_tratar_data($prazo_eleicao_relator), - 'delibera_tratar_prazo_eleicao_relator', - array( - 'post_ID' => $postID, - 'prazo_votacao' => $prazo_eleicao_relator - ) - ); - delibera_add_cron( - strtotime("-1 day", delibera_tratar_data($prazo_eleicao_relator)), - 'delibera_notificar_fim_prazo', - array( - 'post_ID' => $postID, - 'prazo_votacao' => $prazo_eleicao_relator - ) - ); - } - - if($prazo_relatoria != false) - { - delibera_add_cron( - delibera_tratar_data($prazo_relatoria), - 'delibera_tratar_prazo_relatoria', - array( - 'post_ID' => $postID, - 'prazo_votacao' => $prazo_relatoria - ) - ); - delibera_add_cron( - strtotime("-1 day", delibera_tratar_data($prazo_relatoria)), - 'delibera_notificar_fim_prazo', - array( - 'post_ID' => $postID, - 'prazo_votacao' => $prazo_relatoria - ) - ); - } - - if($prazo_votacao != false) - { - delibera_add_cron( - delibera_tratar_data($prazo_votacao), - 'delibera_tratar_prazo_votacao', - array( - 'post_ID' => $postID, - 'prazo_votacao' => $prazo_votacao - ) - ); - delibera_add_cron( - strtotime("-1 day", delibera_tratar_data($prazo_votacao)), - 'delibera_notificar_fim_prazo', - array( - 'post_ID' => $postID, - 'prazo_votacao' => $prazo_votacao - ) - ); - } - } - public function savePostMetas($events_meta, $opt) { if(array_key_exists('delibera_flow', $_POST) ) diff --git a/modules/discussion/discussion.php b/modules/discussion/discussion.php index 4c2384e..c6e5cdf 100644 --- a/modules/discussion/discussion.php +++ b/modules/discussion/discussion.php @@ -157,6 +157,28 @@ public function publishPauta($postID, $opt, $alterar) add_post_meta($postID, $key, $value, true); // Senão, cria } } + + $prazo_discussao = get_post_meta($postID, 'prazo_discussao', true); + + if($prazo_discussao !== false) + { + delibera_add_cron( + delibera_tratar_data($prazo_discussao), + 'delibera_tratar_prazo_discussao', + array( + 'post_ID' => $postID, + 'prazo_discussao' => $prazo_discussao + ) + ); + delibera_add_cron( + strtotime("-1 day", delibera_tratar_data($prazo_discussao)), + 'delibera_notificar_fim_prazo', + array( + 'post_ID' => $postID, + 'prazo_discussao' => $prazo_discussao + ) + ); + } } function checkPostData($erros, $opt, $autosave) diff --git a/modules/rapporteur/rapporteur.php b/modules/rapporteur/rapporteur.php index 764393a..3ca7ca6 100644 --- a/modules/rapporteur/rapporteur.php +++ b/modules/rapporteur/rapporteur.php @@ -208,6 +208,51 @@ public function publishPauta($postID, $opt, $alterar) } } + + $prazo_eleicao_relator = get_post_meta($postID, 'prazo_eleicao_relator', true); + + if( ! empty($prazo_eleicao_relator) ) + { + delibera_add_cron( + delibera_tratar_data($prazo_eleicao_relator), + 'delibera_tratar_prazo_eleicao_relator', + array( + 'post_ID' => $postID, + 'prazo_votacao' => $prazo_eleicao_relator + ) + ); + delibera_add_cron( + strtotime("-1 day", delibera_tratar_data($prazo_eleicao_relator)), + 'delibera_notificar_fim_prazo', + array( + 'post_ID' => $postID, + 'prazo_votacao' => $prazo_eleicao_relator + ) + ); + } + + $prazo_relatoria = get_post_meta($postID, 'prazo_relatoria', true); + + if( ! empty($prazo_relatoria) ) + { + delibera_add_cron( + delibera_tratar_data($prazo_relatoria), + 'delibera_tratar_prazo_relatoria', + array( + 'post_ID' => $postID, + 'prazo_votacao' => $prazo_relatoria + ) + ); + delibera_add_cron( + strtotime("-1 day", delibera_tratar_data($prazo_relatoria)), + 'delibera_notificar_fim_prazo', + array( + 'post_ID' => $postID, + 'prazo_votacao' => $prazo_relatoria + ) + ); + } + } function checkPostData($erros, $opt, $autosave) diff --git a/modules/validation/validation.php b/modules/validation/validation.php index 84eb009..ab4daa8 100644 --- a/modules/validation/validation.php +++ b/modules/validation/validation.php @@ -192,6 +192,28 @@ public function publishPauta($postID, $opt, $alterar) add_post_meta($postID, $key, $value, true); // Senão, cria } } + + $prazo_validacao = get_post_meta($postID, 'prazo_validacao', true); + + if( ! empty($prazo_validacao) ) + { + delibera_add_cron( + delibera_tratar_data($prazo_validacao), + 'delibera_tratar_prazo_validacao', + array( + 'post_ID' => $postID, + 'prazo_validacao' => $prazo_validacao + ) + ); + delibera_add_cron( + strtotime("-1 day", delibera_tratar_data($prazo_validacao)), + 'delibera_notificar_fim_prazo', + array( + 'post_ID' => $postID, + 'prazo_validacao' => $prazo_validacao + ) + ); + } } function checkPostData($erros, $opt, $autosave) diff --git a/modules/vote/vote.php b/modules/vote/vote.php index 1f28ddd..7f5229a 100644 --- a/modules/vote/vote.php +++ b/modules/vote/vote.php @@ -159,6 +159,34 @@ public function publishPauta($postID, $opt, $alterar) add_post_meta($postID, $key, $value, true); // Senão, cria } } + /* + * Faz agendamento das datas para seguir passos + * 1) Excluir ao atingir data de validação se não foi validade + * 2) Iniciar votação se tiver encaminhamento, ou novo prazo, caso contrário + * 3) Fim da votação + * + */ + $prazo_votacao = get_post_meta($postID, 'prazo_votacao', true); + + if( ! empty($prazo_votacao) ) + { + delibera_add_cron( + delibera_tratar_data($prazo_votacao), + 'delibera_tratar_prazo_votacao', + array( + 'post_ID' => $postID, + 'prazo_votacao' => $prazo_votacao + ) + ); + delibera_add_cron( + strtotime("-1 day", delibera_tratar_data($prazo_votacao)), + 'delibera_notificar_fim_prazo', + array( + 'post_ID' => $postID, + 'prazo_votacao' => $prazo_votacao + ) + ); + } } From 3e55c25e2b5ca6fe4aab1b502ca57022eb142b53 Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Wed, 24 Feb 2016 02:28:07 -0300 Subject: [PATCH 041/435] remove unused function --- delibera_flow.php | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/delibera_flow.php b/delibera_flow.php index fc9e96e..2f44ffa 100644 --- a/delibera_flow.php +++ b/delibera_flow.php @@ -16,7 +16,7 @@ public function __construct() add_action('delibera_topic_meta', array($this, 'topicMeta'), 10, 5); add_filter('delibera_save_post_metas', array($this, 'savePostMetas'), 10, 2); - add_action('delibera_publish_pauta', array($this, 'publishPauta'), 10, 3); + //add_action('delibera_publish_pauta', array($this, 'publishPauta'), 10, 3); } @@ -146,34 +146,6 @@ public function savePostMetas($events_meta, $opt) return $events_meta; } - public function publishPauta($postID, $opt, $alterar) - { - $prazo_validacao = get_post_meta($postID, 'prazo_validacao', true); - $prazo_discussao = get_post_meta($postID, 'prazo_discussao', true); - $prazo_relatoria = get_post_meta($postID, 'prazo_relatoria', true); - $prazo_eleicao_relator = get_post_meta($postID, 'prazo_eleicao_relator', true); - $prazo_votacao = get_post_meta($postID, 'prazo_votacao', true); - - - delibera_criar_agenda( - $post->ID, - $prazo_validacao, - $prazo_discussao, - $prazo_votacao, - $opt['relatoria'] == 'S' ? $prazo_relatoria : false, - $opt['relatoria'] == 'S' && $opt['eleicao_relator'] == 'S' ? $prazo_eleicao_relator : false - ); - // discussao - /*else - { - if (! $alterar) - { - wp_set_object_terms ( $post->ID, 'discussao', 'situacao', false ); - } - delibera_criar_agenda ( $post->ID, false, $prazo_discussao, $prazo_votacao, $opt ['relatoria'] == 'S' ? $prazo_relatoria : false, $opt ['relatoria'] == 'S' && $opt ['eleicao_relator'] == 'S' ? $prazo_eleicao_relator : false ); - }*/ - } - } From 56641230dd0797ab203bb5d4addeb0dcef54dde1 Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Thu, 25 Feb 2016 00:11:50 -0300 Subject: [PATCH 042/435] fix notice when create pauta --- delibera_topic.php | 52 ++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/delibera_topic.php b/delibera_topic.php index e9f80a0..e1067bc 100644 --- a/delibera_topic.php +++ b/delibera_topic.php @@ -280,31 +280,33 @@ function delibera_save_post($post_id, $post) // Setup the array of supported file types. In this case, it's just PDF. $supported_types = array('application/pdf'); - // Get the file type of the upload - $arr_uploaded_file_type = wp_check_filetype(basename($_FILES['pauta_pdf_contribution']['name'])); - $uploaded_file_type = $arr_uploaded_file_type['type']; - - if (isset ($_FILES['pauta_pdf_contribution']['name']) && $_FILES['pauta_pdf_contribution']['name'] != '') { - if (!in_array($uploaded_file_type, $supported_types)) { - //TODO: Improve this message and avoid wp_die - wp_die("O arquivo para web não é um PDF (formato permitido)."); - } - - - // Use the WordPress API to upload the file - $upload_pauta_pdf = wp_upload_bits($_FILES['pauta_pdf_contribution']['name'], null, file_get_contents($_FILES['pauta_pdf_contribution']['tmp_name'])); - - if (isset($upload_pauta_pdf['error']) && $upload_pauta_pdf['error'] != 0) { - $events_meta['pauta_pdf_contribution'] = none; - wp_die('Erro ao salvar arquivo para Web. O erro foi: ' . $upload_pauta_pdf['error']); - } else { - $events_meta['pauta_pdf_contribution'] = $upload_pauta_pdf['url']; - - global $wpdb; - - $wpdb->query($wpdb->prepare("UPDATE " . $wpdb->prefix . "posts SET post_content=%s WHERE ID=%d", '', $post->ID)); - } - } + if (! $autosave && array_key_exists('pauta_pdf_contribution', $_FILES)) + { + // Get the file type of the upload + $arr_uploaded_file_type = wp_check_filetype ( basename ( $_FILES ['pauta_pdf_contribution'] ['name'] ) ); + $uploaded_file_type = $arr_uploaded_file_type ['type']; + + if (isset ( $_FILES ['pauta_pdf_contribution'] ['name'] ) && $_FILES ['pauta_pdf_contribution'] ['name'] != '') { + if (! in_array ( $uploaded_file_type, $supported_types )) { + // TODO: Improve this message and avoid wp_die + wp_die ( "O arquivo para web não é um PDF (formato permitido)." ); + } + + // Use the WordPress API to upload the file + $upload_pauta_pdf = wp_upload_bits ( $_FILES ['pauta_pdf_contribution'] ['name'], null, file_get_contents ( $_FILES ['pauta_pdf_contribution'] ['tmp_name'] ) ); + + if (isset ( $upload_pauta_pdf ['error'] ) && $upload_pauta_pdf ['error'] != 0) { + $events_meta ['pauta_pdf_contribution'] = none; + wp_die ( 'Erro ao salvar arquivo para Web. O erro foi: ' . $upload_pauta_pdf ['error'] ); + } else { + $events_meta ['pauta_pdf_contribution'] = $upload_pauta_pdf ['url']; + + global $wpdb; + + $wpdb->query ( $wpdb->prepare ( "UPDATE " . $wpdb->prefix . "posts SET post_content=%s WHERE ID=%d", '', $post->ID ) ); + } + } + } /* ######### FOR PDF UPLOAD FILE ######### */ /* ######### END ######### */ From 3716b726c2558f4b8d0cc538198b9df3cf62e454 Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Thu, 25 Feb 2016 21:01:40 -0300 Subject: [PATCH 043/435] add module template class --- delibera_flow.php | 2 +- delibera_init.php | 1 + modules/discussion/discussion.php | 67 ++++--------- modules/modulebase.php | 157 ++++++++++++++++++++++++++++++ modules/rapporteur/rapporteur.php | 53 +++------- modules/validation/validation.php | 76 ++++++--------- modules/vote/vote.php | 56 +++-------- 7 files changed, 235 insertions(+), 177 deletions(-) create mode 100644 modules/modulebase.php diff --git a/delibera_flow.php b/delibera_flow.php index 2f44ffa..9992b46 100644 --- a/delibera_flow.php +++ b/delibera_flow.php @@ -148,5 +148,5 @@ public function savePostMetas($events_meta, $opt) } - +global $DeliberaFlow; $DeliberaFlow = new \Delibera\Flow(); diff --git a/delibera_init.php b/delibera_init.php index aac97db..70bdd70 100644 --- a/delibera_init.php +++ b/delibera_init.php @@ -169,6 +169,7 @@ function delibera_Add_custom_taxonomy() function deliberaLoadModules() { + include dirname(__FILE__).'/modules/modulebase.php'; $modules = array_filter(glob(dirname(__FILE__).'/modules/*'), 'is_dir'); foreach ($modules as $module) { diff --git a/modules/discussion/discussion.php b/modules/discussion/discussion.php index c6e5cdf..e836ad8 100644 --- a/modules/discussion/discussion.php +++ b/modules/discussion/discussion.php @@ -3,24 +3,26 @@ // PHP 5.3 and later: namespace Delibera\Modules; -class Discussion +class Discussion extends \Delibera\Modules\ModuleBase { - public function __construct() - { - add_action('delibera_situacao_register', array($this, 'registerTax')); - add_filter('delibera_get_main_config', array($this, 'getMainConfig')); - add_filter('delivera_config_page_rows', array($this, 'configPageRows'), 10, 2); - add_filter('delibera_situation_button_text', array($this, 'situationButtonText')); - add_action('delibera_topic_meta', array($this, 'topicMeta'), 10, 5); - add_action('delibera_publish_pauta', array($this, 'publishPauta'), 10, 3); - add_filter('delibera_check_post_data', array($this, 'checkPostData'), 10, 3); - add_filter('delibera_save_post_metas', array($this, 'savePostMetas'), 10, 2); - add_action('delibera_create_pauta_frontend', array($this, 'createPautaAtFront')); - add_filter('delibera_register_flow_module', array($this, 'registerFlowModule')); - - add_shortcode( 'delibera_lista_de_pautas', array($this, 'replacePautas' )); - } + /** + * List of of topic status + * @var array + */ + protected $situacao = array('discussao'); + + /** + * Name of module deadline metadata + * @var String + */ + protected $prazo_meta = 'prazo_discussao'; + + /** + * List of pair shotcode name => method + * @var array + */ + protected $shorcodes = array('delibera_lista_de_pautas' => 'replacePautas' ); /** * Register Tax for the module @@ -42,16 +44,6 @@ public function registerTax() } } - /** - * Register situacao objects for flow treat - * @param array $modules - */ - public function registerFlowModule($modules) - { - $modules['discussao'] = $this; - return $modules; - } - /** * Append configurations * @param array $opts @@ -113,7 +105,9 @@ public function topicMeta($post, $custom, $options_plugin_delibera, $situacao, $ $now = strtotime(date('Y/m/d')." 11:59:59"); - $prazo_discussao_sugerido = strtotime("+$dias_discussao days", $now); + global $DeliberaFlow; + + $prazo_discussao_sugerido = strtotime("+$dias_discussao days", delibera_tratar_data($DeliberaFlow->getLastDeadline($post->ID))); $prazo_discussao = date('d/m/Y', $prazo_discussao_sugerido); if(!($post->post_status == 'draft' || @@ -192,16 +186,6 @@ function checkPostData($erros, $opt, $autosave) return $erros; } - /** - * - * Retorna pautas em Validação - * @param array $filtro - */ - public static function getPautas($filtro = array()) - { - return delibera_get_pautas_em($filtro, 'discussao'); - } - public function replacePautas($matches) { $temp = explode(',', $matches[1]); // configurações da shorttag @@ -246,15 +230,6 @@ public function createPautaAtFront($opt) } } - public function getDeadline($post_id = false) - { - if($post_id == false) - { - $post_id = get_the_ID(); - } - return get_post_meta($post_id, 'prazo_discussao', true); - } - } $DeliberaDiscussion = new \Delibera\Modules\Discussion(); diff --git a/modules/modulebase.php b/modules/modulebase.php new file mode 100644 index 0000000..13e213e --- /dev/null +++ b/modules/modulebase.php @@ -0,0 +1,157 @@ + method + * @var array + */ + protected $shortcodes = array(); + + public function __construct() + { + add_filter('delibera_register_flow_module', array($this, 'registerFlowModule')); + add_action('delibera_situacao_register', array($this, 'registerTax')); + add_filter('delibera_get_main_config', array($this, 'getMainConfig')); + add_filter('delivera_config_page_rows', array($this, 'configPageRows'), 10, 2); + add_filter('delibera_situation_button_text', array($this, 'situationButtonText')); + add_action('delibera_topic_meta', array($this, 'topicMeta'), 10, 5); + add_action('delibera_publish_pauta', array($this, 'publishPauta'), 10, 3); + add_filter('delibera_check_post_data', array($this, 'checkPostData'), 10, 3); + add_filter('delibera_save_post_metas', array($this, 'savePostMetas'), 10, 2); + add_action('delibera_create_pauta_frontend', array($this, 'createPautaAtFront')); + + foreach ($this->shortcodes as $name => $function) + { + add_shortcode( $name, array( $this, $function )); + } + } + + /** + * Register situacao objects for flow treat + * @param array $modules + */ + public function registerFlowModule($modules) + { + foreach ($this->situacao as $situacao) + { + $modules[$situacao] = $this; + } + return $modules; + } + + /** + * Register Tax for the module + */ + abstract public function registerTax(); + + /** + * Append configurations + * @param array $opts + */ + abstract public function getMainConfig($opts); + + /** + * Array to show on config page + * @param array $rows + */ + abstract public function configPageRows($rows, $opt); + + /** + * Label to apply to button + * @param unknown $situation + */ + abstract public function situationButtonText($situation); + + /** + * + * Post Meta Fields display + * + * @param \WP_Post $post + * @param array $custom post custom fields + * @param array $options_plugin_delibera Delibera options array + * @param WP_Term $situacao + * @param bool $disable_edicao + * + */ + abstract public function topicMeta($post, $custom, $options_plugin_delibera, $situacao, $disable_edicao); + + /** + * When the topic is published + * @param int $postID + * @param array $opt delibera configs + * @param bool $alterar has been altered + */ + abstract public function publishPauta($postID, $opt, $alterar); + + /** + * Validate topic required data + * @param array $erros erros report array + * @param array $opt Delibera configs + * @param bool $autosave is autosave? + * @return array erros report array append if needed + */ + abstract public function checkPostData($erros, $opt, $autosave); + + /** + * Save topic metadata + * @param array $events_meta + * @param array $opt Delibera configs + * + * @return array events_meta to be save on the topic + */ + abstract public function savePostMetas($events_meta, $opt); + + /** + * Treat postback of frotend topic + * @param array $opt Delibera configs + */ + abstract public function createPautaAtFront($opt); + + /** + * Return this module deadline for the current post + * @param int $post_id + * @return mixed|string deadline date + */ + public function getDeadline($post_id = false) + { + if($post_id == false) + { + $post_id = get_the_ID(); + } + if(is_array($this->prazo_meta)) + { + $situacao = delibera_get_situacao($post_id); + return array_key_exists($situacao, $this->prazo_meta) ? get_post_meta($post_id, $this->prazo_meta[$situacao], true) : date('d/m/Y'); + } + return get_post_meta($post_id, $this->prazo_meta, true); + } + + /** + * + * Retorn topic at module situation + * @param array $filtro + */ + public static function getPautas($filtro = array()) + { + return delibera_get_pautas_em($filtro, $this->situacao); + } + +} \ No newline at end of file diff --git a/modules/rapporteur/rapporteur.php b/modules/rapporteur/rapporteur.php index 3ca7ca6..cecf20a 100644 --- a/modules/rapporteur/rapporteur.php +++ b/modules/rapporteur/rapporteur.php @@ -3,23 +3,20 @@ // PHP 5.3 and later: namespace Delibera\Modules; -class Rapporteur +class Rapporteur extends \Delibera\Modules\ModuleBase { + /** + * List of of topic status + * @var array + */ + protected $situacao = array('relatoria', 'eleicao_relator'); + + /** + * Name of module deadline metadata + * @var array situacao a => deadline_a + */ + protected $prazo_meta = array('relatoria' => 'prazo_relatoria', 'eleicao_relator' => 'prazo_eleicao_relator'); - public function __construct() - { - add_action('delibera_situacao_register', array($this, 'registerTax')); - add_filter('delibera_get_main_config', array($this, 'getMainConfig')); - add_filter('delivera_config_page_rows', array($this, 'configPageRows'), 10, 2); - add_filter('delibera_situation_button_text', array($this, 'situationButtonText')); - add_action('delibera_topic_meta', array($this, 'topicMeta'), 10, 5); - add_action('delibera_publish_pauta', array($this, 'publishPauta'), 10, 3); - add_filter('delibera_check_post_data', array($this, 'checkPostData'), 10, 3); - add_filter('delibera_save_post_metas', array($this, 'savePostMetas'), 10, 2); - add_action('delibera_create_pauta_frontend', array($this, 'createPautaAtFront')); - add_filter('delibera_register_flow_module', array($this, 'registerFlowModule')); - - } /** * Register Tax for the module @@ -61,17 +58,6 @@ public function registerTax() } } - /** - * Register situacao objects for flow treat - * @param array $modules - */ - public function registerFlowModule($modules) - { - $modules['relatoria'] = $this; - $modules['eleicaoredator'] = $this; - return $modules; - } - /** * Append configurations * @param array $opts @@ -101,7 +87,7 @@ public function configPageRows($rows, $opt) "label" => __('Prazo para relatoria:', 'delibera'), "content" => '' ); - /*$rows[] = array( + $rows[] = array( "id" => "eleicao_relator", "label" => __('Necessário eleição de relator?', 'delibera'), "content" => '' @@ -110,7 +96,7 @@ public function configPageRows($rows, $opt) "id" => "dias_votacao_relator", "label" => __('Prazo para eleição de relator:', 'delibera'), "content" => '' - );*/ + ); return $rows; } @@ -280,17 +266,6 @@ function checkPostData($erros, $opt, $autosave) return $erros; } - /** - * - * Retorna pautas em Relatoria ou Eleição para relator - * - * @param array $filtro - */ - public static function getPautas($filtro = array()) - { - return delibera_get_pautas_em($filtro, array('eleicaoredator', 'relatoria')); - } - public function savePostMetas($events_meta, $opt) { if( diff --git a/modules/validation/validation.php b/modules/validation/validation.php index ab4daa8..bddc315 100644 --- a/modules/validation/validation.php +++ b/modules/validation/validation.php @@ -3,24 +3,12 @@ // PHP 5.3 and later: namespace Delibera\Modules; -class Validation +class Validation extends \Delibera\Modules\ModuleBase { - public function __construct() - { - add_action('delibera_situacao_register', array($this, 'registerTax')); - add_filter('delibera_get_main_config', array($this, 'getMainConfig')); - add_filter('delivera_config_page_rows', array($this, 'configPageRows'), 10, 2); - add_filter('delibera_situation_button_text', array($this, 'situationButtonText')); - add_action('delibera_topic_meta', array($this, 'topicMeta'), 10, 5); - add_action('delibera_publish_pauta', array($this, 'publishPauta'), 10, 3); - add_filter('delibera_check_post_data', array($this, 'checkPostData'), 10, 3); - add_filter('delibera_save_post_metas', array($this, 'savePostMetas'), 10, 2); - add_action('delibera_create_pauta_frontend', array($this, 'createPautaAtFront')); - add_filter('delibera_register_flow_module', array($this, 'registerFlowModule')); - - add_shortcode( 'delibera_lista_de_propostas', array($this, 'replacePropostas' )); - } + protected $situacao = array('validacao', 'naovalidada'); + protected $prazo_meta = 'prazo_validacao'; + protected $shortcodes = array('delibera_lista_de_propostas' => 'replacePropostas' ); /** * Register Tax for the module @@ -57,17 +45,6 @@ public function registerTax() } } - /** - * Register situacao objects for flow treat - * @param array $modules - */ - public function registerFlowModule($modules) - { - $modules['validacao'] = $this; - $modules['naovalidada'] = $this; - return $modules; - } - /** * Append configurations * @param array $opts @@ -167,6 +144,12 @@ public function topicMeta($post, $custom, $options_plugin_delibera, $situacao, $ } + /** + * When the topic is published + * @param int $postID + * @param array $opt delibera configs + * @param bool $alterar has been altered + */ public function publishPauta($postID, $opt, $alterar) { if(!array_key_exists('validacao', $opt) || $opt['validacao'] == 'S' && $opt['delibera_flow'][0] == 'validacao' ) @@ -216,7 +199,14 @@ public function publishPauta($postID, $opt, $alterar) } } - function checkPostData($erros, $opt, $autosave) + /** + * Validate topic required data + * @param array $erros erros report array + * @param array $opt Delibera configs + * @param bool $autosave is autosave? + * @return array erros report array append if needed + */ + public function checkPostData($erros, $opt, $autosave) { if($opt['validacao'] == 'S') { @@ -247,16 +237,6 @@ public static function getPropostas($filtro = array()) return self::getPautas($filtro); } - /** - * - * Retorna pautas em Validação - * @param array $filtro - */ - public static function getPautas($filtro = array()) - { - return delibera_get_pautas_em($filtro, 'validacao'); - } - public function replacePropostas($matches) { global $wp_posts; @@ -282,6 +262,13 @@ public function replacePropostas($matches) return ''; // Retornar código da representação } + /** + * Save topic metadata + * @param array $events_meta + * @param array $opt Delibera configs + * + * @return array events_meta to be save on the topic + */ public function savePostMetas($events_meta, $opt) { if( // Se tem validação, tem que ter o prazo @@ -296,6 +283,10 @@ public function savePostMetas($events_meta, $opt) return $events_meta; } + /** + * Treat postback of frotend topic + * @param array $opt Delibera configs + */ public function createPautaAtFront($opt) { if($opt['validacao'] == 'S'){ @@ -303,15 +294,6 @@ public function createPautaAtFront($opt) $_POST['min_validacoes'] = $opt['minimo_validacao']; } } - - public function getDeadline($post_id = false) - { - if($post_id == false) - { - $post_id = get_the_ID(); - } - return get_post_meta($post_id, 'prazo_validacao', true); - } } $DeliberaValidation = new \Delibera\Modules\Validation(); diff --git a/modules/vote/vote.php b/modules/vote/vote.php index 7f5229a..31bd6e6 100644 --- a/modules/vote/vote.php +++ b/modules/vote/vote.php @@ -3,23 +3,20 @@ // PHP 5.3 and later: namespace Delibera\Modules; -class Vote +class Vote extends \Delibera\Modules\ModuleBase { - public function __construct() - { - add_action('delibera_situacao_register', array($this, 'registerTax')); - add_filter('delibera_get_main_config', array($this, 'getMainConfig')); - add_filter('delivera_config_page_rows', array($this, 'configPageRows'), 10, 2); - add_filter('delibera_situation_button_text', array($this, 'situationButtonText')); - add_action('delibera_topic_meta', array($this, 'topicMeta'), 10, 5); - add_action('delibera_publish_pauta', array($this, 'publishPauta'), 10, 3); - add_filter('delibera_check_post_data', array($this, 'checkPostData'), 10, 3); - add_filter('delibera_save_post_metas', array($this, 'savePostMetas'), 10, 2); - add_action('delibera_create_pauta_frontend', array($this, 'createPautaAtFront')); - add_filter('delibera_register_flow_module', array($this, 'registerFlowModule')); - - } + /** + * List of of topic status + * @var array + */ + protected $situacao = array('emvotacao'); + + /** + * Name of module deadline metadata + * @var String + */ + protected $prazo_meta = 'prazo_votacao'; /** * Register Tax for the module @@ -41,16 +38,6 @@ public function registerTax() } } - /** - * Register situacao objects for flow treat - * @param array $modules - */ - public function registerFlowModule($modules) - { - $modules['emvotacao'] = $this; - return $modules; - } - /** * Append configurations * @param array $opts @@ -211,16 +198,6 @@ public static function getEmvotacao($filtro = array()) return self::getPautas($filtro); } - /** - * - * Retorna pautas em Votação - * @param array $filtro - */ - public static function getPautas($filtro = array()) - { - return delibera_get_pautas_em($filtro, 'emvotacao'); - } - public function savePostMetas($events_meta, $opt) { if(array_key_exists('prazo_votacao', $_POST)) @@ -241,15 +218,6 @@ public function createPautaAtFront($opt) } } - public function getDeadline($post_id = false) - { - if($post_id == false) - { - $post_id = get_the_ID(); - } - return get_post_meta($post_id, 'prazo_votacao', true); - } - } $DeliberaVote = new \Delibera\Modules\Vote(); From effd99902e6fb4e8c6534fda784d1f50b4e48cb1 Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Thu, 25 Feb 2016 22:46:26 -0300 Subject: [PATCH 044/435] init modules and deadline trigger --- delibera_comments.php | 100 +---------------------- delibera_flow.php | 39 ++++++++- delibera_topic_deadline.php | 76 +---------------- modules/discussion/discussion.php | 43 +++++++++- modules/modulebase.php | 12 +++ modules/rapporteur/rapporteur.php | 60 ++++++++++++-- modules/validation/validation.php | 33 +++++++- modules/vote/vote.php | 131 +++++++++++++++++++++++++++++- 8 files changed, 301 insertions(+), 193 deletions(-) diff --git a/delibera_comments.php b/delibera_comments.php index e14e63c..112da57 100644 --- a/delibera_comments.php +++ b/delibera_comments.php @@ -421,7 +421,7 @@ function delibera_save_comment_metas($comment_id) add_comment_meta($comment_id, 'delibera_votos', $votos, true); $comment = get_comment($comment_id); - delibera_valida_votos($comment->comment_post_ID); + //delibera_valida_votos($comment->comment_post_ID); TODO use module version $nvotos = get_post_meta($comment->comment_post_ID, 'delibera_numero_comments_votos', true); $nvotos++; @@ -846,101 +846,3 @@ function delibera_valida_permissoes($comment_ID) } add_action( 'wp_blacklist_check', 'delibera_valida_permissoes' ); -/** - * - * Verifica se o número de votos é igual ao número de representantes para deflagar fim da votação - * @param integer $postID - */ -function delibera_valida_votos($postID) -{ - global $wp_roles,$wpdb; - $users_count = 0; - foreach ($wp_roles->roles as $nome => $role) - { - if(is_array($role['capabilities']) && array_key_exists('votar', $role['capabilities']) && $role['capabilities']['votar'] == 1 ? "SSSSSim" : "NNNnnnnnnnao") - { - $result = $wpdb->get_results("SELECT count(*) as n FROM $wpdb->usermeta WHERE meta_key = 'wp_capabilities' AND meta_value LIKE '%$nome%' "); - $users_count += $result[0]->n; - } - } - - $votos = delibera_get_comments_votacoes($postID); - - $votos_count = count($votos); - - if($votos_count >= $users_count) - { - delibera_computa_votos($postID, $votos); - } -} - -/** - * - * Faz a apuração dos votos e toma as devidas ações: - * Empate: Mais prazo; - * Vencedor: Marco com resolucao e marca o encaminhamento. - * @param interger $postID - * @param array $votos - */ -function delibera_computa_votos($postID, $votos = null) -{ - if(is_null($votos)) // Ocorre no fim do prazo de votação - { - $votos = delibera_get_comments_votacoes($postID); - } - $encaminhamentos = delibera_get_comments_encaminhamentos($postID); - $encaminhamentos_votos = array(); - foreach ($encaminhamentos as $encaminhamento) - { - $encaminhamentos_votos[$encaminhamento->comment_ID] = 0; - } - - foreach ($votos as $voto_comment) - { - $voto = get_comment_meta($voto_comment->comment_ID, 'delibera_votos', true); - foreach ($voto as $voto_para) - { - if (array_key_exists($voto_para, $encaminhamentos_votos)) - { - $encaminhamentos_votos[$voto_para]++; - } else { - $encaminhamentos_votos[$voto_para] = 1; - } - } - } - $maisvotado = array(-1, -1); - $iguais = array(); - - foreach ($encaminhamentos_votos as $encaminhamentos_voto_key => $encaminhamentos_voto_valor) - { - if($encaminhamentos_voto_valor > $maisvotado[1]) - { - $maisvotado[0] = $encaminhamentos_voto_key; - $maisvotado[1] = $encaminhamentos_voto_valor; - $iguais = array(); - } - elseif($encaminhamentos_voto_valor == $maisvotado[1]) - { - $iguais[] = $encaminhamentos_voto_key; - } - delete_comment_meta($encaminhamentos_voto_key, 'delibera_comment_numero_votos'); - add_comment_meta($encaminhamentos_voto_key, 'delibera_comment_numero_votos', $encaminhamentos_voto_valor, true); - } - - // nao finaliza a votacao caso haja um empate, exceto quando o administrador clicar no botão "Forçar fim do prazo" - if(count($iguais) > 0 && !(isset($_REQUEST['action']) && $_REQUEST['action'] == 'delibera_forca_fim_prazo_action')) // Empato - { - delibera_novo_prazo($postID); - } - else - { - wp_set_object_terms($postID, 'comresolucao', 'situacao', false); - update_comment_meta($maisvotado[0], 'delibera_comment_tipo', 'resolucao'); - add_post_meta($postID, 'data_resolucao', date('d/m/Y H:i:s'), true); - ////delibera_notificar_situacao($postID); - if(has_action('votacao_concluida')) - { - do_action('votacao_concluida', $post); - } - } -} \ No newline at end of file diff --git a/delibera_flow.php b/delibera_flow.php index 9992b46..d05965f 100644 --- a/delibera_flow.php +++ b/delibera_flow.php @@ -8,6 +8,9 @@ class Flow { + + protected $flow = array(); + public function __construct() { add_filter('delibera_get_main_config', array($this, 'getMainConfig')); @@ -78,11 +81,12 @@ public function topicMeta($post, $custom, $options_plugin_delibera, $situacao, $ flow)) return $this->flow[$post_id]; + + $options_plugin_delibera = delibera_get_config(); + $default_flow = isset($options_plugin_delibera['delibera_flow']) ? $options_plugin_delibera['delibera_flow'] : array(); + $flow = get_post_meta($post_id, 'delibera_flow', true); if(is_array($flow) && count($flow) > 0) { + $this->flow[$post_id] = $flow; return $flow; } else { + $this->flow[$post_id] = $default_flow; return $default_flow; } } @@ -146,6 +157,28 @@ public function savePostMetas($events_meta, $opt) return $events_meta; } + /** + * Go to the next module on flow + * @param string $post_id + */ + public static function next($post_id = false) + { + global $DeliberaFlow; + + $flow = $DeliberaFlow->get($post_id); + $situacao = delibera_get_situacao($post_id); + $current = array_search($situacao, $flow); + $modules = $DeliberaFlow->getFlowModules(); //TODO cache? + + if(array_key_exists($current+1, $flow)) + { + $modules[$flow[$current+1]]->initModule($post_id); + } + else + { + //TODO the end? + } + } } global $DeliberaFlow; diff --git a/delibera_topic_deadline.php b/delibera_topic_deadline.php index 6f246ae..8854a02 100644 --- a/delibera_topic_deadline.php +++ b/delibera_topic_deadline.php @@ -19,7 +19,7 @@ function delibera_forca_fim_prazo($postID) )); break; case 'emvotacao': - delibera_computa_votos($postID); + //delibera_computa_votos($postID); TODO use module break; } //delibera_notificar_situacao($postID); @@ -73,71 +73,6 @@ function delibera_reabrir_pauta_action() require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_cron.php'; - -function delibera_tratar_prazos($args) -{ - $situacao = delibera_get_situacao($args['post_ID']); - switch ($situacao->slug) - { - case 'validacao': - delibera_tratar_prazo_validacao($args); - break; - case 'discussao': - delibera_tratar_prazo_discussao($args); - break; - case 'relatoria': - delibera_tratar_prazo_relatoria($args); - break; - case 'emvotacao': - delibera_tratar_prazo_votacao($args); - break; - } -} - -add_action('delibera_tratar_prazos', 'delibera_tratar_prazos', 1, 1); - -function delibera_tratar_prazo_validacao($args) -{ - $situacao = delibera_get_situacao($args['post_ID']); - if($situacao->slug == 'validacao') - { - delibera_marcar_naovalidada($args['post_ID']); - } -} - -function delibera_tratar_prazo_discussao($args) -{ - $situacao = delibera_get_situacao($args['post_ID']); - if($situacao->slug == 'discussao') - { - $post_id = $args['post_ID']; - if(count(delibera_get_comments_encaminhamentos($post_id)) > 0) - { - $opts = delibera_get_config(); - if($opts['eleicao_relator'] == 'S') - { - wp_set_object_terms($post_id, 'eleicaoredator', 'situacao', false); //Mudar situação para Votação - } - elseif($opts['relatoria'] == 'S') - { - wp_set_object_terms($post_id, 'relatoria', 'situacao', false); //Mudar situação para Votação - } - else - { - wp_set_object_terms($post_id, 'emvotacao', 'situacao', false); //Mudar situação para Votação - } - if(has_action('delibera_discussao_concluida')) - { - do_action('delibera_discussao_concluida', $post_id); - } - } - else - { - delibera_novo_prazo($post_id); - } - } -} - function delibera_tratar_prazo_relatoria($args) { $situacao = delibera_get_situacao($args['post_ID']); @@ -160,15 +95,6 @@ function delibera_tratar_prazo_relatoria($args) } } -function delibera_tratar_prazo_votacao($args) -{ - $situacao = delibera_get_situacao($args['post_ID']); - if($situacao->slug == 'emvotacao') - { - delibera_computa_votos($args['post_ID']); - } -} - function delibera_marcar_naovalidada($postID) { wp_set_object_terms($postID, 'naovalidada', 'situacao', false); diff --git a/modules/discussion/discussion.php b/modules/discussion/discussion.php index e836ad8..fe3f580 100644 --- a/modules/discussion/discussion.php +++ b/modules/discussion/discussion.php @@ -44,6 +44,16 @@ public function registerTax() } } + /** + * + * {@inheritDoc} + * @see \Delibera\Modules\ModuleBase::initModule() + */ + public function initModule($post_id) + { + wp_set_object_terms($post_id, 'discussao', 'situacao', false); + } + /** * Append configurations * @param array $opts @@ -158,10 +168,10 @@ public function publishPauta($postID, $opt, $alterar) { delibera_add_cron( delibera_tratar_data($prazo_discussao), - 'delibera_tratar_prazo_discussao', + array($this, 'deadline'), array( - 'post_ID' => $postID, - 'prazo_discussao' => $prazo_discussao + 'post_id' => $postID, + 'prazo' => $prazo_discussao ) ); delibera_add_cron( @@ -230,6 +240,33 @@ public function createPautaAtFront($opt) } } + /** + * + * {@inheritDoc} + * @see \Delibera\Modules\ModuleBase::deadline() + */ + public function deadline($args) + { + $post_id = $args['post_id']; + $situacao = delibera_get_situacao($post_id); + if($situacao->slug == 'discussao') + { + if(count(delibera_get_comments_encaminhamentos($post_id)) > 0) + { + \Delibera\Flow::next($post_id); + + if(has_action('delibera_discussao_concluida')) + { + do_action('delibera_discussao_concluida', $post_id); + } + } + else + { + delibera_novo_prazo($post_id); + } + } + } + } $DeliberaDiscussion = new \Delibera\Modules\Discussion(); diff --git a/modules/modulebase.php b/modules/modulebase.php index 13e213e..e7236b6 100644 --- a/modules/modulebase.php +++ b/modules/modulebase.php @@ -62,6 +62,12 @@ public function registerFlowModule($modules) */ abstract public function registerTax(); + /** + * Initial situation on module begins + * @param int $post_id + */ + abstract public function initModule($post_id); + /** * Append configurations * @param array $opts @@ -154,4 +160,10 @@ public static function getPautas($filtro = array()) return delibera_get_pautas_em($filtro, $this->situacao); } + /** + * Trigger module deadline event + * @param array $args in form: array('post_id' => $post_id, 'prazo' => $prazo) + */ + abstract public function deadline($args); + } \ No newline at end of file diff --git a/modules/rapporteur/rapporteur.php b/modules/rapporteur/rapporteur.php index cecf20a..a245b39 100644 --- a/modules/rapporteur/rapporteur.php +++ b/modules/rapporteur/rapporteur.php @@ -58,6 +58,24 @@ public function registerTax() } } + /** + * + * {@inheritDoc} + * @see \Delibera\Modules\ModuleBase::initModule() + */ + public function initModule($post_id) + { + $opts = delibera_get_config(); + if($opts['eleicao_relator'] == 'S') + { + wp_set_object_terms($post_id, 'eleicaoredator', 'situacao', false); //Mudar situação para Votação + } + elseif($opts['relatoria'] == 'S') + { + wp_set_object_terms($post_id, 'relatoria', 'situacao', false); //Mudar situação para Votação + } + } + /** * Append configurations * @param array $opts @@ -201,10 +219,10 @@ public function publishPauta($postID, $opt, $alterar) { delibera_add_cron( delibera_tratar_data($prazo_eleicao_relator), - 'delibera_tratar_prazo_eleicao_relator', + array($this, 'deadline'), array( - 'post_ID' => $postID, - 'prazo_votacao' => $prazo_eleicao_relator + 'post_id' => $postID, + 'prazo' => $prazo_eleicao_relator ) ); delibera_add_cron( @@ -223,10 +241,10 @@ public function publishPauta($postID, $opt, $alterar) { delibera_add_cron( delibera_tratar_data($prazo_relatoria), - 'delibera_tratar_prazo_relatoria', + array($this, 'deadline'), array( - 'post_ID' => $postID, - 'prazo_votacao' => $prazo_relatoria + 'post_id' => $postID, + 'prazo' => $prazo_relatoria ) ); delibera_add_cron( @@ -319,6 +337,36 @@ public function getDeadline($post_id = false) return get_post_meta($post_id, 'prazo_relatoria', true); } + /** + * + * {@inheritDoc} + * @see \Delibera\Modules\ModuleBase::deadline() + */ + public function deadline($args) + { + $situacao = delibera_get_situacao($args['post_ID']); + if($situacao->slug == 'relatoria') + { + $post_id = $args['post_ID']; + if(count(delibera_get_comments_encaminhamentos($post_id)) > 0) + { + //wp_set_object_terms($post_id, 'emvotacao', 'situacao', false); //Mudar situação para Votação + \Delibera\Flow::next($post_id); + + //delibera_notificar_situacao($post_id); + + if(has_action('delibera_relatoria_concluida')) + { + do_action('delibera_relatoria_concluida', $post_id); + } + } + else + { + delibera_novo_prazo($post_id); + } + } + } + } $DeliberaRapporteur = new \Delibera\Modules\Rapporteur(); diff --git a/modules/validation/validation.php b/modules/validation/validation.php index bddc315..44c7e18 100644 --- a/modules/validation/validation.php +++ b/modules/validation/validation.php @@ -44,6 +44,16 @@ public function registerTax() ); } } + + /** + * + * {@inheritDoc} + * @see \Delibera\Modules\ModuleBase::initModule() + */ + public function initModule($post_id) + { + wp_set_object_terms($post_id, 'validacao', 'situacao', false); + } /** * Append configurations @@ -182,17 +192,17 @@ public function publishPauta($postID, $opt, $alterar) { delibera_add_cron( delibera_tratar_data($prazo_validacao), - 'delibera_tratar_prazo_validacao', + array($this, 'deadline'), array( - 'post_ID' => $postID, - 'prazo_validacao' => $prazo_validacao + 'post_id' => $postID, + 'prazo' => $prazo_validacao ) ); delibera_add_cron( strtotime("-1 day", delibera_tratar_data($prazo_validacao)), 'delibera_notificar_fim_prazo', array( - 'post_ID' => $postID, + 'post_id' => $postID, 'prazo_validacao' => $prazo_validacao ) ); @@ -294,6 +304,21 @@ public function createPautaAtFront($opt) $_POST['min_validacoes'] = $opt['minimo_validacao']; } } + + /** + * + * {@inheritDoc} + * @see \Delibera\Modules\ModuleBase::deadline() + */ + public function deadline($args) + { + $situacao = delibera_get_situacao($args['post_id']); + if($situacao->slug == 'validacao') + { + delibera_marcar_naovalidada($post_id); + } + } + } $DeliberaValidation = new \Delibera\Modules\Validation(); diff --git a/modules/vote/vote.php b/modules/vote/vote.php index 31bd6e6..37ccd48 100644 --- a/modules/vote/vote.php +++ b/modules/vote/vote.php @@ -38,6 +38,16 @@ public function registerTax() } } + /** + * + * {@inheritDoc} + * @see \Delibera\Modules\ModuleBase::initModule() + */ + public function initModule($post_id) + { + wp_set_object_terms($post_id, 'emvotacao', 'situacao', false); + } + /** * Append configurations * @param array $opts @@ -159,10 +169,10 @@ public function publishPauta($postID, $opt, $alterar) { delibera_add_cron( delibera_tratar_data($prazo_votacao), - 'delibera_tratar_prazo_votacao', + array($this, 'deadline'), array( - 'post_ID' => $postID, - 'prazo_votacao' => $prazo_votacao + 'post_id' => $postID, + 'prazo' => $prazo_votacao ) ); delibera_add_cron( @@ -218,6 +228,121 @@ public function createPautaAtFront($opt) } } + /** + * + * Faz a apuração dos votos e toma as devidas ações: + * Empate: Mais prazo; + * Vencedor: Marco com resolucao e marca o encaminhamento. + * @param interger $postID + * @param array $votos + */ + function computaVotos($postID, $votos = null) + { + if(is_null($votos)) // Ocorre no fim do prazo de votação + { + $votos = delibera_get_comments_votacoes($postID); + } + $encaminhamentos = delibera_get_comments_encaminhamentos($postID); + $encaminhamentos_votos = array(); + foreach ($encaminhamentos as $encaminhamento) + { + $encaminhamentos_votos[$encaminhamento->comment_ID] = 0; + } + + foreach ($votos as $voto_comment) + { + $voto = get_comment_meta($voto_comment->comment_ID, 'delibera_votos', true); + foreach ($voto as $voto_para) + { + if (array_key_exists($voto_para, $encaminhamentos_votos)) + { + $encaminhamentos_votos[$voto_para]++; + } else { + $encaminhamentos_votos[$voto_para] = 1; + } + } + } + $maisvotado = array(-1, -1); + $iguais = array(); + + foreach ($encaminhamentos_votos as $encaminhamentos_voto_key => $encaminhamentos_voto_valor) + { + if($encaminhamentos_voto_valor > $maisvotado[1]) + { + $maisvotado[0] = $encaminhamentos_voto_key; + $maisvotado[1] = $encaminhamentos_voto_valor; + $iguais = array(); + } + elseif($encaminhamentos_voto_valor == $maisvotado[1]) + { + $iguais[] = $encaminhamentos_voto_key; + } + delete_comment_meta($encaminhamentos_voto_key, 'delibera_comment_numero_votos'); + add_comment_meta($encaminhamentos_voto_key, 'delibera_comment_numero_votos', $encaminhamentos_voto_valor, true); + } + + // nao finaliza a votacao caso haja um empate, exceto quando o administrador clicar no botão "Forçar fim do prazo" + if(count($iguais) > 0 && !(isset($_REQUEST['action']) && $_REQUEST['action'] == 'delibera_forca_fim_prazo_action')) // Empato + { + delibera_novo_prazo($postID); + } + else + { + //wp_set_object_terms($postID, 'comresolucao', 'situacao', false); + \Delibera\Flow::next($postID); + + update_comment_meta($maisvotado[0], 'delibera_comment_tipo', 'resolucao'); + add_post_meta($postID, 'data_resolucao', date('d/m/Y H:i:s'), true); + ////delibera_notificar_situacao($postID); + if(has_action('votacao_concluida')) + { + do_action('votacao_concluida', $post); + } + } + } + + /** + * + * Verifica se o número de votos é igual ao número de representantes para deflagar fim da votação + * @param integer $postID + */ + public function validaVotos($postID) + { + global $wp_roles,$wpdb; + $users_count = 0; + foreach ($wp_roles->roles as $nome => $role) + { + if(is_array($role['capabilities']) && array_key_exists('votar', $role['capabilities']) && $role['capabilities']['votar'] == 1 ? "SSSSSim" : "NNNnnnnnnnao") + { + $result = $wpdb->get_results("SELECT count(*) as n FROM $wpdb->usermeta WHERE meta_key = 'wp_capabilities' AND meta_value LIKE '%$nome%' "); + $users_count += $result[0]->n; + } + } + + $votos = delibera_get_comments_votacoes($postID); + + $votos_count = count($votos); + + if($votos_count >= $users_count) + { + $this->computaVotos($postID, $votos); + } + } + + /** + * + * {@inheritDoc} + * @see \Delibera\Modules\ModuleBase::deadline() + */ + public function deadline($args) + { + $situacao = delibera_get_situacao($args['post_id']); + if($situacao->slug == 'emvotacao') + { + $this->computaVotos($args['post_id']); + } + } + } $DeliberaVote = new \Delibera\Modules\Vote(); From 6b9b75b62b16eb07eaf64ee8798003e6b2d63aab Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Thu, 25 Feb 2016 23:14:09 -0300 Subject: [PATCH 045/435] preview Rapporteur election --- modules/rapporteur/rapporteur.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/rapporteur/rapporteur.php b/modules/rapporteur/rapporteur.php index a245b39..dde6348 100644 --- a/modules/rapporteur/rapporteur.php +++ b/modules/rapporteur/rapporteur.php @@ -365,6 +365,10 @@ public function deadline($args) delibera_novo_prazo($post_id); } } + elseif($situacao->slug == 'eleicao_relator') + { + //TODO eleicao relator deadline + } } } From dcf3ef4947ca55d6606e7d587078ac98af9724aa Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Thu, 25 Feb 2016 23:15:47 -0300 Subject: [PATCH 046/435] remove unused deadline function and treat force deadline on \Delibera\Flow --- delibera_flow.php | 20 +++++++++++++++ delibera_topic.php | 2 +- delibera_topic_deadline.php | 50 +------------------------------------ 3 files changed, 22 insertions(+), 50 deletions(-) diff --git a/delibera_flow.php b/delibera_flow.php index d05965f..a95cfff 100644 --- a/delibera_flow.php +++ b/delibera_flow.php @@ -179,6 +179,26 @@ public static function next($post_id = false) //TODO the end? } } + + public static function forcarFimPrazo($post_id) + { + if(is_object($post_id)) $post_id = $post_id->ID; + + global $DeliberaFlow; + + $flow = $DeliberaFlow->get($post_id); + $situacao = delibera_get_situacao($post_id); + $current = array_search($situacao, $flow); + $modules = $DeliberaFlow->getFlowModules(); //TODO cache? + + if(array_key_exists($current, $flow)) + { + $modules[$flow[$current]]->deadline(array('post_id' => $post_id, 'prazo' => date('d/m/Y'), 'force' => true)); + } + $DeliberaFlow->next($post_id); + //delibera_notificar_situacao($postID); // Originaly comment, why? + } + } global $DeliberaFlow; diff --git a/delibera_topic.php b/delibera_topic.php index e1067bc..ee7c7cf 100644 --- a/delibera_topic.php +++ b/delibera_topic.php @@ -332,7 +332,7 @@ function delibera_save_post($post_id, $post) current_user_can('forcar_prazo') ) { - delibera_forca_fim_prazo($post->ID); + \Delibera\Flow::forcarFimPrazo($post->ID); } if($post->post_status == 'publish' && !$autosave) diff --git a/delibera_topic_deadline.php b/delibera_topic_deadline.php index 8854a02..05b6703 100644 --- a/delibera_topic_deadline.php +++ b/delibera_topic_deadline.php @@ -1,36 +1,10 @@ slug) - { - case 'discussao': - delibera_tratar_prazo_discussao(array( - 'post_ID' => $postID, - 'prazo_discussao' => date('d/m/Y') - )); - break; - case 'relatoria': - delibera_tratar_prazo_relatoria(array( - 'post_ID' => $postID, - 'prazo_relatoria' => date('d/m/Y') - )); - break; - case 'emvotacao': - //delibera_computa_votos($postID); TODO use module - break; - } - //delibera_notificar_situacao($postID); -} - - function delibera_forca_fim_prazo_action() { if(current_user_can('forcar_prazo') && check_admin_referer('delibera_forca_fim_prazo_action'.$_REQUEST['post'], '_wpnonce')) { - delibera_forca_fim_prazo($_REQUEST['post']); + \Delibera\Flow::forcarFimPrazo($_REQUEST['post']); wp_redirect( admin_url( 'edit.php?post_type=pauta') ); } @@ -73,28 +47,6 @@ function delibera_reabrir_pauta_action() require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_cron.php'; -function delibera_tratar_prazo_relatoria($args) -{ - $situacao = delibera_get_situacao($args['post_ID']); - if($situacao->slug == 'relatoria') - { - $post_id = $args['post_ID']; - if(count(delibera_get_comments_encaminhamentos($post_id)) > 0) - { - wp_set_object_terms($post_id, 'emvotacao', 'situacao', false); //Mudar situação para Votação - //delibera_notificar_situacao($post_id); - if(has_action('delibera_relatoria_concluida')) - { - do_action('delibera_relatoria_concluida', $post_id); - } - } - else - { - delibera_novo_prazo($post_id); - } - } -} - function delibera_marcar_naovalidada($postID) { wp_set_object_terms($postID, 'naovalidada', 'situacao', false); From 26ddbffc1bb1ed842548910e4805ff5c01e6a14a Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Fri, 26 Feb 2016 17:01:45 -0300 Subject: [PATCH 047/435] remove abstract from props for php 5.5 compatibility --- modules/modulebase.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/modulebase.php b/modules/modulebase.php index e7236b6..964beaf 100644 --- a/modules/modulebase.php +++ b/modules/modulebase.php @@ -11,13 +11,13 @@ abstract class ModuleBase * List of of topic status * @var array */ - abstract protected $situacao = array(); + protected $situacao = array(); /** * Name of module deadline metadata * @var String */ - abstract protected $prazo_meta = 'prazo'; + protected $prazo_meta = 'prazo'; /** * List of pair shotcode name => method From 02fafaee1fdd2eb0ac966e6e953989b93f475972 Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Fri, 26 Feb 2016 17:02:45 -0300 Subject: [PATCH 048/435] reopen topic is a flow function --- delibera_flow.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/delibera_flow.php b/delibera_flow.php index a95cfff..feaaae5 100644 --- a/delibera_flow.php +++ b/delibera_flow.php @@ -19,7 +19,7 @@ public function __construct() add_action('delibera_topic_meta', array($this, 'topicMeta'), 10, 5); add_filter('delibera_save_post_metas', array($this, 'savePostMetas'), 10, 2); - //add_action('delibera_publish_pauta', array($this, 'publishPauta'), 10, 3); + add_action('delibera_publish_pauta', array($this, 'publishPauta'), 10, 3); } @@ -157,6 +157,17 @@ public function savePostMetas($events_meta, $opt) return $events_meta; } + /** + * When the topic is published + * @param int $postID + * @param array $opt delibera configs + * @param bool $alterar has been altered + */ + public function publishPauta($postID, $opt, $alterar) + { + self::reabrirPauta($postID, false); + } + /** * Go to the next module on flow * @param string $post_id @@ -199,6 +210,14 @@ public static function forcarFimPrazo($post_id) //delibera_notificar_situacao($postID); // Originaly comment, why? } + public static function reabrirPauta($postID, $new_deadline = false) + { + global $DeliberaFlow; + $flow = $DeliberaFlow->get($postID); + $flow[0]->initModule($postID); + if($new_deadline) delibera_novo_prazo($postID); + } + } global $DeliberaFlow; From ef4e87c161cd1e391bf279875050fd1ad88eb3e6 Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Fri, 26 Feb 2016 17:03:25 -0300 Subject: [PATCH 049/435] lets flow control initial situacao --- modules/validation/validation.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/modules/validation/validation.php b/modules/validation/validation.php index 44c7e18..11bfea1 100644 --- a/modules/validation/validation.php +++ b/modules/validation/validation.php @@ -162,14 +162,6 @@ public function topicMeta($post, $custom, $options_plugin_delibera, $situacao, $ */ public function publishPauta($postID, $opt, $alterar) { - if(!array_key_exists('validacao', $opt) || $opt['validacao'] == 'S' && $opt['delibera_flow'][0] == 'validacao' ) - { - if(!$alterar) - { - wp_set_object_terms($postID, 'validacao', 'situacao', false); - } - - } $events_meta = array(); $events_meta['delibera_numero_comments_validacoes'] = 0; $events_meta['numero_validacoes'] = 0; From 955847e724785d1f985f14f55019150892944b7e Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Fri, 26 Feb 2016 23:23:12 -0300 Subject: [PATCH 050/435] fix #50 --- delibera_cron.php | 5 +- delibera_flow.php | 47 ++++++++++++++----- delibera_topic.php | 7 +-- modules/discussion/discussion.php | 30 ++++++++---- modules/modulebase.php | 39 ++++++++++++---- modules/rapporteur/rapporteur.php | 76 +++++++++++++++---------------- modules/validation/validation.php | 43 +++++++++++++---- modules/vote/vote.php | 30 ++++++++---- 8 files changed, 186 insertions(+), 91 deletions(-) diff --git a/delibera_cron.php b/delibera_cron.php index eb08115..712c07d 100644 --- a/delibera_cron.php +++ b/delibera_cron.php @@ -104,13 +104,14 @@ function delibera_del_cron($postID) $crons = get_option('delibera-cron', array()); if(!is_array($crons)) $crons = array(); $crons_new = array(); - foreach($crons as $cron_data => $cron_value) { $new_cron = array(); foreach ($cron_value as $call) { - if($call['args']['post_ID'] != $postID) + if(isset($call['args']['post_ID'])) $call['args']['post_id'] = $call['args']['post_ID']; // precisa ser compatível com cron anteriores + + if($call['args']['post_id'] != $postID) { $new_cron[] = $call; } diff --git a/delibera_flow.php b/delibera_flow.php index feaaae5..efb4ff3 100644 --- a/delibera_flow.php +++ b/delibera_flow.php @@ -10,6 +10,7 @@ class Flow { protected $flow = array(); + protected $deadlines = array(); public function __construct() { @@ -18,9 +19,8 @@ public function __construct() add_filter('delibera-pre-main-config-save', array($this, 'preMainConfigSave')); add_action('delibera_topic_meta', array($this, 'topicMeta'), 10, 5); add_filter('delibera_save_post_metas', array($this, 'savePostMetas'), 10, 2); - add_action('delibera_publish_pauta', array($this, 'publishPauta'), 10, 3); - + add_filter('delibera_flow_list', array($this, 'filterFlowList')); } /** @@ -29,7 +29,7 @@ public function __construct() */ public function getMainConfig($opts) { - $opts['delibera_flow'] = array('validacao', 'discussao', 'elegerelator', 'relatoria', 'emvotacao', 'comresolucao'); + $opts['delibera_flow'] = array('validacao', 'discussao', 'relatoria', 'emvotacao', 'comresolucao'); return $opts; } @@ -87,6 +87,11 @@ public function topicMeta($post, $custom, $options_plugin_delibera, $situacao, $ */ public function get($post_id = false) { + $options_plugin_delibera = delibera_get_config(); + + $default_flow = isset($options_plugin_delibera['delibera_flow']) ? $options_plugin_delibera['delibera_flow'] : array(); + $default_flow = apply_filters('delibera_flow_list', $default_flow); + if($post_id == false) { $post_id = get_the_ID(); @@ -98,12 +103,10 @@ public function get($post_id = false) if(array_key_exists($post_id, $this->flow)) return $this->flow[$post_id]; - $options_plugin_delibera = delibera_get_config(); - $default_flow = isset($options_plugin_delibera['delibera_flow']) ? $options_plugin_delibera['delibera_flow'] : array(); - $flow = get_post_meta($post_id, 'delibera_flow', true); if(is_array($flow) && count($flow) > 0) { + $flow = apply_filters('delibera_flow_list', $flow); $this->flow[$post_id] = $flow; return $flow; } @@ -127,17 +130,19 @@ public function getFlowModules() return $modules; } - public function getLastDeadline($situacao, $post_id = false) + public static function getLastDeadline($situacao, $post_id = false) { + global $DeliberaFlow; + if($post_id == false) { $post_id = get_the_ID(); } - $flow = $this->get($post_id); - $modules = $this->getFlowModules(); + $flow = $DeliberaFlow->get($post_id); + $modules = $DeliberaFlow->getFlowModules(); $now = array_search($situacao, $flow); - if(($now - 1) > 0 && array_key_exists($flow[$now - 1], $modules) && property_exists($modules[$flow[$now - 1]], 'getDeadline')) + if(($now - 1) >= 0 && array_key_exists($now - 1, $flow) && array_key_exists($flow[$now - 1], $modules) && method_exists($modules[$flow[$now - 1]], 'getDeadline')) { return $modules[$flow[$now - 1]]->getDeadline(); } @@ -214,10 +219,30 @@ public static function reabrirPauta($postID, $new_deadline = false) { global $DeliberaFlow; $flow = $DeliberaFlow->get($postID); - $flow[0]->initModule($postID); + $modules = $DeliberaFlow->getFlowModules(); + $modules[$flow[0]]->initModule($postID); if($new_deadline) delibera_novo_prazo($postID); } + /** + * Check if module has bean remove or altered + * @param array $flows + * @return array + */ + public function filterFlowList($flow) + { + if(is_array($flow)) + { + $modules = $this->getFlowModules(); + $flow = array_values(array_intersect($flow, array_keys($modules))); + return $flow; + } + else + { + return array(); + } + } + } global $DeliberaFlow; diff --git a/delibera_topic.php b/delibera_topic.php index ee7c7cf..df35e20 100644 --- a/delibera_topic.php +++ b/delibera_topic.php @@ -87,11 +87,6 @@ function delibera_pauta_meta() $pdf_html .= "

"; echo $pdf_html; - if($options_plugin_delibera['validacao'] == "S") // Adiciona prazo de validação se for necessário - { - //TODO adicionar modulo anterior ao prazo $dias_discussao += $dias_validacao; - } - $now = strtotime(date('Y/m/d')." 11:59:59"); if ( @@ -143,7 +138,7 @@ function delibera_publish_pauta($postID, $post, $alterar = false) do_action('delibera_publish_pauta', $postID, $opt, $alterar); - $curtir = get_post_meta($post_id, 'delibera_numero_curtir', true); + $curtir = get_post_meta($postID, 'delibera_numero_curtir', true); if($curtir == "" || $curtir === false || is_null($curtir)) { $events_meta['delibera_numero_comments_padroes'] = 0; diff --git a/modules/discussion/discussion.php b/modules/discussion/discussion.php index fe3f580..a2e7a51 100644 --- a/modules/discussion/discussion.php +++ b/modules/discussion/discussion.php @@ -12,6 +12,12 @@ class Discussion extends \Delibera\Modules\ModuleBase */ protected $situacao = array('discussao'); + /** + * + * @var array list of module flows + */ + protected $flows = array('discussao'); + /** * Name of module deadline metadata * @var String @@ -98,6 +104,19 @@ public function situationButtonText($situation) return $situation; } + /** + * + * {@inheritDoc} + * @see \Delibera\Modules\ModuleBase::generateDeadline() + */ + public function generateDeadline($options_plugin_delibera) + { + $dias_discussao = intval(htmlentities($options_plugin_delibera['dias_discussao'])); + + $prazo_discussao_sugerido = strtotime("+$dias_discussao days", delibera_tratar_data(\Delibera\Flow::getLastDeadline('discussao'))); + return date('d/m/Y', $prazo_discussao_sugerido); + } + /** * * Post Meta Fields display @@ -111,15 +130,8 @@ public function situationButtonText($situation) */ public function topicMeta($post, $custom, $options_plugin_delibera, $situacao, $disable_edicao) { - $dias_discussao = intval(htmlentities($options_plugin_delibera['dias_discussao'])); - - $now = strtotime(date('Y/m/d')." 11:59:59"); - - global $DeliberaFlow; + $prazo_discussao = $this->generateDeadline($options_plugin_delibera); - $prazo_discussao_sugerido = strtotime("+$dias_discussao days", delibera_tratar_data($DeliberaFlow->getLastDeadline($post->ID))); - $prazo_discussao = date('d/m/Y', $prazo_discussao_sugerido); - if(!($post->post_status == 'draft' || $post->post_status == 'auto-draft' || $post->post_status == 'pending')) @@ -178,7 +190,7 @@ public function publishPauta($postID, $opt, $alterar) strtotime("-1 day", delibera_tratar_data($prazo_discussao)), 'delibera_notificar_fim_prazo', array( - 'post_ID' => $postID, + 'post_id' => $postID, 'prazo_discussao' => $prazo_discussao ) ); diff --git a/modules/modulebase.php b/modules/modulebase.php index 964beaf..3b0fec6 100644 --- a/modules/modulebase.php +++ b/modules/modulebase.php @@ -8,20 +8,26 @@ abstract class ModuleBase { /** - * List of of topic status - * @var array + * + * @var array List of of topic status */ protected $situacao = array(); /** - * Name of module deadline metadata - * @var String + * + * @var array list of module flows + */ + protected $flows = array(); + + /** + * + * @var String Name of module deadline metadata */ protected $prazo_meta = 'prazo'; /** - * List of pair shotcode name => method - * @var array + * + * @var array List of pair shotcode name => method */ protected $shortcodes = array(); @@ -50,7 +56,7 @@ public function __construct() */ public function registerFlowModule($modules) { - foreach ($this->situacao as $situacao) + foreach ($this->flows as $situacao) { $modules[$situacao] = $this; } @@ -131,6 +137,12 @@ abstract public function savePostMetas($events_meta, $opt); */ abstract public function createPautaAtFront($opt); + /** + * Generate deadline date + * @param array $options_plugin_delibera Delibera configs + */ + abstract public function generateDeadline($options_plugin_delibera); + /** * Return this module deadline for the current post * @param int $post_id @@ -145,9 +157,18 @@ public function getDeadline($post_id = false) if(is_array($this->prazo_meta)) { $situacao = delibera_get_situacao($post_id); - return array_key_exists($situacao, $this->prazo_meta) ? get_post_meta($post_id, $this->prazo_meta[$situacao], true) : date('d/m/Y'); + $situacao = $situacao->slug; + + return !empty($situacao) && array_key_exists($situacao, $this->prazo_meta) ? get_post_meta($post_id, $this->prazo_meta[$situacao], true) : $this->generateDeadline(delibera_get_config()); } - return get_post_meta($post_id, $this->prazo_meta, true); + $deadline = get_post_meta($post_id, $this->prazo_meta, true); + + if(empty($deadline)) + { + return $this->generateDeadline(delibera_get_config()); + } + + return $deadline; } /** diff --git a/modules/rapporteur/rapporteur.php b/modules/rapporteur/rapporteur.php index dde6348..9fcfe4a 100644 --- a/modules/rapporteur/rapporteur.php +++ b/modules/rapporteur/rapporteur.php @@ -11,6 +11,12 @@ class Rapporteur extends \Delibera\Modules\ModuleBase */ protected $situacao = array('relatoria', 'eleicao_relator'); + /** + * + * @var array list of module flows + */ + protected $flows = array('relatoria'); + /** * Name of module deadline metadata * @var array situacao a => deadline_a @@ -132,6 +138,31 @@ public function situationButtonText($situation) return $situation; } + /** + * + * {@inheritDoc} + * @see \Delibera\Modules\ModuleBase::generateDeadline() + */ + public function generateDeadline($options_plugin_delibera) + { + $dias_relatoria = intval(htmlentities($options_plugin_delibera['dias_relatoria'])); + $dias_votacao_relator = intval(htmlentities($options_plugin_delibera['dias_votacao_relator'])); + + //$dias_relatoria += $dias_discussao; // TODO issue #50 + if($options_plugin_delibera['eleicao_relator'] == "S") // Adiciona prazo de vatacao relator se for necessário + { + $dias_relatoria += $dias_votacao_relator; + } + + $prazo_eleicao_relator_sugerido = strtotime("+$dias_votacao_relator days", delibera_tratar_data(\Delibera\Flow::getLastDeadline('relatoria'))); + $prazo_relatoria_sugerido = strtotime("+$dias_relatoria days", delibera_tratar_data(\Delibera\Flow::getLastDeadline('relatoria'))); + + $prazo_eleicao_relator = date('d/m/Y', $prazo_eleicao_relator_sugerido); + + return date('d/m/Y', $prazo_relatoria_sugerido); + + } + /** * * Post Meta Fields display @@ -145,26 +176,13 @@ public function situationButtonText($situation) */ public function topicMeta($post, $custom, $options_plugin_delibera, $situacao, $disable_edicao) { - $now = strtotime(date('Y/m/d')." 11:59:59"); - - $dias_relatoria = intval(htmlentities($options_plugin_delibera['dias_relatoria'])); $dias_votacao_relator = intval(htmlentities($options_plugin_delibera['dias_votacao_relator'])); - - if($options_plugin_delibera['relatoria'] == "S") // Adiciona prazo de relatoria se for necessário - { - //$dias_relatoria += $dias_discussao; // TODO issue #50 - if($options_plugin_delibera['eleicao_relator'] == "S") // Adiciona prazo de vatacao relator se for necessário - { - $dias_relatoria += $dias_votacao_relator; - $dias_votacao_relator += $dias_discussao; - } - } - - $prazo_eleicao_relator_sugerido = strtotime("+$dias_votacao_relator days", $now); - $prazo_relatoria_sugerido = strtotime("+$dias_relatoria days", $now); - + + $prazo_eleicao_relator_sugerido = strtotime("+$dias_votacao_relator days", delibera_tratar_data(\Delibera\Flow::getLastDeadline('relatoria', $post->ID))); + $prazo_eleicao_relator = date('d/m/Y', $prazo_eleicao_relator_sugerido); - $prazo_relatoria = date('d/m/Y', $prazo_relatoria_sugerido); + + $prazo_relatoria = $this->generateDeadline($options_plugin_delibera); if(!($post->post_status == 'draft' || $post->post_status == 'auto-draft' || @@ -229,7 +247,7 @@ public function publishPauta($postID, $opt, $alterar) strtotime("-1 day", delibera_tratar_data($prazo_eleicao_relator)), 'delibera_notificar_fim_prazo', array( - 'post_ID' => $postID, + 'post_id' => $postID, 'prazo_votacao' => $prazo_eleicao_relator ) ); @@ -251,7 +269,7 @@ public function publishPauta($postID, $opt, $alterar) strtotime("-1 day", delibera_tratar_data($prazo_relatoria)), 'delibera_notificar_fim_prazo', array( - 'post_ID' => $postID, + 'post_id' => $postID, 'prazo_votacao' => $prazo_relatoria ) ); @@ -319,24 +337,6 @@ public function createPautaAtFront($opt) } } - public function getDeadline($post_id = false) - { - if($post_id == false) - { - $post_id = get_the_ID(); - } - $opt = delibera_get_config(); - /** - * Add time to Relator election when activated - */ - if($opt['eleicao_relator'] == 'S') - { - return date('d/m/Y', strtotime ('+'.$opt['dias_votacao_relator'].' DAYS', delibera_tratar_data(get_post_meta($post_id, 'prazo_relatoria', true)))); - } - - return get_post_meta($post_id, 'prazo_relatoria', true); - } - /** * * {@inheritDoc} diff --git a/modules/validation/validation.php b/modules/validation/validation.php index 11bfea1..26436ba 100644 --- a/modules/validation/validation.php +++ b/modules/validation/validation.php @@ -5,9 +5,28 @@ class Validation extends \Delibera\Modules\ModuleBase { - + /** + * + * @var array List of of topic status + */ protected $situacao = array('validacao', 'naovalidada'); + + /** + * + * @var array list of module flows + */ + protected $flows = array('validacao'); + + /** + * + * @var String Name of module deadline metadata + */ protected $prazo_meta = 'prazo_validacao'; + + /** + * + * @var array List of pair shotcode name => method + */ protected $shortcodes = array('delibera_lista_de_propostas' => 'replacePropostas' ); /** @@ -106,6 +125,20 @@ public function situationButtonText($situation) return $situation; } + /** + * + * {@inheritDoc} + * @see \Delibera\Modules\ModuleBase::generateDeadline() + */ + public function generateDeadline($options_plugin_delibera) + { + $dias_validacao = intval(htmlentities($options_plugin_delibera['dias_validacao'])); + + $prazo_validacao_sugerido = strtotime("+$dias_validacao days", delibera_tratar_data(\Delibera\Flow::getLastDeadline('valicacao'))); + + return date('d/m/Y', $prazo_validacao_sugerido); + } + /** * * Post Meta Fields display @@ -123,13 +156,7 @@ public function topicMeta($post, $custom, $options_plugin_delibera, $situacao, $ $min_validacoes = array_key_exists("min_validacoes", $custom) ? $custom["min_validacoes"][0] : htmlentities($options_plugin_delibera['minimo_validacao']); - $dias_validacao = intval(htmlentities($options_plugin_delibera['dias_validacao'])); - - $now = strtotime(date('Y/m/d')." 11:59:59"); - - $prazo_validacao_sugerido = strtotime("+$dias_validacao days", $now); - - $prazo_validacao = date('d/m/Y', $prazo_validacao_sugerido); + $prazo_validacao = $this->generateDeadline($options_plugin_delibera); if(!($post->post_status == 'draft' || $post->post_status == 'auto-draft' || diff --git a/modules/vote/vote.php b/modules/vote/vote.php index 37ccd48..28ff262 100644 --- a/modules/vote/vote.php +++ b/modules/vote/vote.php @@ -12,6 +12,12 @@ class Vote extends \Delibera\Modules\ModuleBase */ protected $situacao = array('emvotacao'); + /** + * + * @var array list of module flows + */ + protected $flows = array('emvotacao'); + /** * Name of module deadline metadata * @var String @@ -86,6 +92,20 @@ public function situationButtonText($situation) return $situation; } + /** + * + * {@inheritDoc} + * @see \Delibera\Modules\ModuleBase::generateDeadline() + */ + public function generateDeadline($options_plugin_delibera) + { + $dias_votacao = intval(htmlentities($options_plugin_delibera['dias_votacao'])); + + $prazo_votacao_sugerido = strtotime("+$dias_votacao days", delibera_tratar_data(\Delibera\Flow::getLastDeadline('emvotacao'))); + + return date('d/m/Y', $prazo_votacao_sugerido); + } + /** * * Post Meta Fields display @@ -99,13 +119,7 @@ public function situationButtonText($situation) */ public function topicMeta($post, $custom, $options_plugin_delibera, $situacao, $disable_edicao) { - $now = strtotime(date('Y/m/d')." 11:59:59"); - - $dias_votacao = /*$dias_discussao +*/ intval(htmlentities($options_plugin_delibera['dias_votacao'])); - - $prazo_votacao_sugerido = strtotime("+$dias_votacao days", $now); - - $prazo_votacao = date('d/m/Y', $prazo_votacao_sugerido); + $prazo_votacao = $this->generateDeadline($options_plugin_delibera); if(!($post->post_status == 'draft' || $post->post_status == 'auto-draft' || @@ -179,7 +193,7 @@ public function publishPauta($postID, $opt, $alterar) strtotime("-1 day", delibera_tratar_data($prazo_votacao)), 'delibera_notificar_fim_prazo', array( - 'post_ID' => $postID, + 'post_id' => $postID, 'prazo_votacao' => $prazo_votacao ) ); From f8867745d9e359bc24da7d39d2089d382f49fc3f Mon Sep 17 00:00:00 2001 From: Lucas Pirola Date: Mon, 7 Mar 2016 07:47:12 -0300 Subject: [PATCH 051/435] Turn delibera theme atenas compatible with Twenty Fifteen wp theme --- themes/atenas/delibera_style.css | 97 -------------------------------- 1 file changed, 97 deletions(-) diff --git a/themes/atenas/delibera_style.css b/themes/atenas/delibera_style.css index a7a2121..e592514 100644 --- a/themes/atenas/delibera_style.css +++ b/themes/atenas/delibera_style.css @@ -5,13 +5,8 @@ /* Header - archive ================================================================================*/ -#content{ - float: none; -} - .home p.delibera-boasvindas { padding-left:20px; - float: left; color: #fff7e4; font-size: 22px; font-weight: bold; @@ -25,7 +20,6 @@ p.delibera-boasvindas { color:#5d5a5d; - float: left; font-size: 22px; font-weight: bold; width: 500px; @@ -39,7 +33,6 @@ p.delibera-login { } .single p.delibera-login { - float:left; font-size:12px; width: 70%; } @@ -49,7 +42,6 @@ p.delibera-participacao a{ padding-top:15px; padding-bottom:15px; display: block; - float: right; width: 225px; text-align:center; color:white; @@ -72,7 +64,6 @@ p.delibera-participacao a{ #filtro { background:#e7f1ee; padding:15px; - float: right; margin-top: 0; width: 220px; } @@ -104,7 +95,6 @@ p.delibera-participacao a{ margin-top: 2px; opacity:0.7; cursor:pointer; - float:left; } .delibera-filtros-mostrar:hover { @@ -121,16 +111,12 @@ p.delibera-participacao a{ margin-top: 2px; cursor:pointer; opacity:0.7; - float:left; } .delibera-filtros-esconder:hover { opacity: 1.0; } -.form-filtro-ultimos-chebox-span { - float: left; -} .form-filtro-ultimos-chebox-label-todos { color: #434343; @@ -143,7 +129,6 @@ p.delibera-participacao a{ #filtro { background:#e7f1ee; padding:15px; - float: right; margin-top: 0; width: 220px; } @@ -242,7 +227,6 @@ p.delibera-participacao a{ ================================================================================*/ .post-type-archive-pauta .hentry { - float: left; margin: 10px; width: 400px; border: 3px solid #c4c2c2; @@ -304,14 +288,12 @@ body.post-type-archive-pauta .entry-meta { text-transform: uppercase; text-align: left; color: #CD334E; - float: left; width: 100%; } span.archive-situacao { display:block; font-size:11px; - float:right; text-transform:uppercase; color:#CD334E; } @@ -346,14 +328,12 @@ body.post-type-archive-pauta .entry-utility { } .single-pauta #leader img { - float: left; margin-right: 20px; border: 3px solid #ebebeb; } .single-pauta #leader h1.entry-title { clear: none; - float: left; font-family: 'LucidaSansDemiboldRoman', arial, sans-serif; line-height:27px; margin-right: 20px; @@ -432,9 +412,7 @@ span.delibera_seguir_text:hover { } .single-pauta .hentry { - float: left; background: #fff; - width: 100%; border-radius: 15px; } @@ -442,7 +420,6 @@ span.delibera_seguir_text:hover { border-left: 1px solid #EEE; border-right: 1px solid #EEE; color: #4F4F4F; - float: left; line-height: 1.9em; padding: 20px 30px; width: 100%; @@ -459,7 +436,6 @@ span.delibera_seguir_text:hover { padding: 0 15px; padding-top:1px; width:100%; - float:left; border:none; } @@ -468,7 +444,6 @@ span.delibera_seguir_text:hover { } .single .pauta .entry-share { - float:left; clear:both; margin: 10px; margin-left: 12px; @@ -477,7 +452,6 @@ span.delibera_seguir_text:hover { .single-pauta .entry-respond a.comment-reply-link { background-position:right 3px; - float: right; text-align: right; padding-right: 22px; padding-top: 0 !important; @@ -489,7 +463,6 @@ span.delibera_seguir_text:hover { .comentario_coluna2 { background: url('images/icone-grafico.png') center right no-repeat ; width: 170px !important; - float: right !important; margin-right: 4px; padding-right: 22px; text-align: right; @@ -529,7 +502,6 @@ span.delibera_seguir_text:hover { .single .delibera-comment-text, .author .delibera-comment-text { color:#4f4f4f; - float:left; width:600px; margin-left:30px; } @@ -538,7 +510,6 @@ span.delibera_seguir_text:hover { color:#4f4f4f; margin:5px 0; display: block; - float: left; margin: 0; } } @@ -579,7 +550,6 @@ a.comment-reply-link:hover{ clear:right; color:#4F4F4F !important; font-family: 'LucidaSansDemiboldRoman', arial, helvetica; - float: right; font-size:10px; margin-top:5px; margin-right: 4px;; @@ -604,7 +574,6 @@ a.comment-reply-link:hover{ } span.delibera_unlike_text { - float:right; background:url('images/discordo.png') right center no-repeat ; font-weight: bold; } @@ -625,7 +594,6 @@ span.delibera_like_text { span.delibera-unlike-count,.delibera_like span.delibera_like_reposta { display:block; - float:right; clear:both; } @@ -688,7 +656,6 @@ span.delibera-unlike-count, .delibera_unlike span.delibera_unlike_reposta { color:#464646; font-family: 'Candal', arial, helvetica; margin:10px 0 0 20px; - float: left; } #painel_validacao{ @@ -700,7 +667,6 @@ span.delibera-unlike-count, .delibera_unlike span.delibera_unlike_reposta { } .single-pauta p.comment-form-comment label { - float:left; font-size:12px; margin:20px 5px; text-transform:uppercase; @@ -718,7 +684,6 @@ span.delibera-unlike-count, .delibera_unlike span.delibera_unlike_reposta { .single-post #respond { background:#eee; - float:left; padding:15px; width:612px; } @@ -769,7 +734,6 @@ span.delibera-unlike-count, .delibera_unlike span.delibera_unlike_reposta { #delibera-comments .children { display: block; - float: left; position: relative; } @@ -780,7 +744,6 @@ span.delibera-unlike-count, .delibera_unlike span.delibera_unlike_reposta { #delibera-comments .delibera-comment-text { width: 67%; display: block; - float: left; position: relative; } @@ -788,13 +751,11 @@ span.delibera-unlike-count, .delibera_unlike span.delibera_unlike_reposta { #delibera-comments .delibera-comment-botoes { width: 27%; display: block; - float: left; position: relative; } #delibera-comments .delibera-comment-author.vcard { display: block; - float: left; position: relative; } @@ -833,7 +794,6 @@ span.delibera-unlike-count, .delibera_unlike span.delibera_unlike_reposta { } #delibera #tabs { - float: left; width: 650px; background: white; border-bottom-right-radius: 50px; @@ -847,7 +807,6 @@ ul.tab-navigation { } ul.tab-navigation li { - float: left; position: relative; top: 1px; white-space: nowrap; @@ -858,7 +817,6 @@ ul.tab-navigation li a { background: #666; color: #fff; display: block; - float: left; margin-right: 5px; padding: 5px 25px; } @@ -922,12 +880,9 @@ ul.tab-navigation li a:hover { .post-type-archive-pauta #content, .single-pauta #content { -moz-border-radius: 20px; -webkit-border-radius: 20px; - width: 100%; - margin: 0 auto; } .single .hentry img.alignnone { - float:left; margin-right: 20px; background:#fff; } @@ -963,7 +918,6 @@ ul.tab-navigation li a:hover { li.comment .vcard img{ border:2px solid #fff; - float:left; height:40px; margin: 0 20px 10px 10px; width:40px; @@ -973,7 +927,6 @@ li.comment .vcard img{ cite.fn a{ display:block; - float:left; font-style:normal; font-family: 'LucidaSansDemiboldRoman', arial, helvetica; margin-left: 60px; @@ -997,11 +950,6 @@ label.encaminhamento-label { padding-top: 5px; text-align: right; text-transform: uppercase; - float: right; -} - -.single a.comment-reply-link { - float:right; } .single li.depth-1 .delibera-comment-body { @@ -1028,17 +976,14 @@ li.comment ul.children li.depth-3 .delibera-like { } #respond p.logged-in-as { - float:right; text-align:right; } .single-pauta p.logged-in-as { - float:left; } .single-pauta li.comment .reply { clear: right; - float: right; height: 20px; margin-right: 2px; width: 190px; @@ -1047,13 +992,11 @@ li.comment ul.children li.depth-3 .delibera-like { input.baseadoem-checkbox { margin-left: 8px; cursor:pointer; - float:right; } .baseadoem-checkbox-div { margin: 10px 0; display: block; - float: right; } .baseadoem-checkbox-div:hover { @@ -1064,7 +1007,6 @@ input.baseadoem-checkbox { clear: right; color:#4f4f4f; display:block; - float:right; font-family: 'LucidaSansDemiboldRoman', arial, helvetica; font-size:10px; opacity:0.7; @@ -1076,7 +1018,6 @@ input.baseadoem-checkbox { } input#baseadoem-checkbox-9 { - float:right; } .single-pauta ol.commentlist { @@ -1085,11 +1026,9 @@ input#baseadoem-checkbox-9 { .single-pauta .delibera_before_fields { width: 578px; - float: left; } .home p.delibera-pagina-discussoes { - float: right; margin-top: 55px; margin-right: 5px; } @@ -1098,7 +1037,6 @@ p.delibera-pagina-discussoes a { /* border-bottom:2px solid #034ea1; color:#666;*/ margin-top: 20px; - float: right; text-align:right; text-transform:uppercase; margin-right: 30px; @@ -1154,7 +1092,6 @@ a#cancel-comment-reply-link { ================================================================================*/ p.nocomments { - float:left; text-align:center; font-size:16px; padding-top:20px; @@ -1214,10 +1151,6 @@ body.author #content { color: #F8A600; } -#delibera .author-avatar, .author .author-avatar { - float: left; -} - #delibera #ultimos-comentarios .author-avatar img, .author #ultimos-comentarios .author-avatar img { border: 3px solid #5BB762; margin-right: 35px; @@ -1232,7 +1165,6 @@ body.author #content { #delibera #membros a.membro-thumbnail { border: 3px solid #5BB762; display: block; - float:left; height: 60px; margin-right: 35px; width: 60px; @@ -1254,7 +1186,6 @@ body.author #content { #delibera #membros .membro-social a { display: block; - float: right; height: 16px; margin: 0 5px; width: 16px; @@ -1268,10 +1199,6 @@ body.author #content { background: url('images/icone-facebook.png'); } -form.delibera-edit-comment-form { - float:left; -} - form.delibera-edit-comment-form textarea { padding:5px; font-family: 'LucidaSansRegular',arial, helvetica, sans-serif; @@ -1351,7 +1278,6 @@ input .delibera-encaminha-label { border:1px solid #ccc; color:#fff; font-size:11px; - float:right; margin-top:90px; padding:10px; width:300px; @@ -1381,7 +1307,6 @@ input .delibera-encaminha-label { ================================================================================*/ .single .pauta .entry-share { - float:left; clear:both; margin: 10px; margin-left: 12px; @@ -1391,7 +1316,6 @@ input .delibera-encaminha-label { padding: 0; } .single .entry-share { - float:left; clear:both; margin: 10px; margin-left: 12px; @@ -1400,14 +1324,12 @@ input .delibera-encaminha-label { .single .share-twitter, .single .share-facebook, .single .share-this { width: 128px; - float:left; } .single-pauta .share-twitter, .single-pauta .share-facebook, .single-pauta .share-this { width: 100px; - float:left; } @@ -1429,7 +1351,6 @@ input .delibera-encaminha-label { .single-pauta .entry-respond a.comment-reply-link { background-position:right 3px; - float: right; text-align: right; padding-right: 22px; padding-top: 0 !important; @@ -1466,19 +1387,6 @@ h3#delibera-comments-title { height: 16px; background: url(images/icone-excluir.png); cursor: pointer; - float:right; -} - -.painel-baseouseem-item { - float:left; -} - -.painel-baseouseem-link { - float:left; -} - -.painel-baseouseem-label { - float:left; } #coluna-pagina { @@ -1575,7 +1483,6 @@ h1.author { } #author-avatar { - float: left; width: 225px; } @@ -1584,7 +1491,6 @@ h1.author { } #author-data{ - float: left; padding-left:25px; width: 675px; } @@ -1593,7 +1499,6 @@ h1.author { background:url('images/icone-user.png') left 5px no-repeat; padding-left:22px !important; padding-top:3px; - float: left; font-size:11px; margin-left:10px; text-transform:uppercase; @@ -1616,7 +1521,6 @@ h1.author { background:url('images/link.png') left 5px no-repeat; padding-left:22px !important; padding-top:3px; - float: left; font-size:11px; margin-left:10px; text-transform:uppercase; @@ -1630,7 +1534,6 @@ h1.author { #author-edit a { display:block; - float:right; } #entry-author-info { From 9ada43d24d40bdd7486ec51798274b07558b1ae8 Mon Sep 17 00:00:00 2001 From: Lucas Pirola Date: Mon, 7 Mar 2016 08:28:54 -0300 Subject: [PATCH 052/435] Add library to enable share link to social network https://github.com/carrot/share-button This library has almost 4k starres at github and an very clean api. The customization is easy with configurations and css. The script do not load external javascript from social network sites wihch improve user experience because overall time of load page is decreased. --- css/share-button.min.css | 1 + js/share-button.min.js | 2 ++ 2 files changed, 3 insertions(+) create mode 100644 css/share-button.min.css create mode 100644 js/share-button.min.js diff --git a/css/share-button.min.css b/css/share-button.min.css new file mode 100644 index 0000000..a0a35d6 --- /dev/null +++ b/css/share-button.min.css @@ -0,0 +1 @@ +@import url(//fonts.googleapis.com/css?family=Lato);share-button{position:relative;font-size:16px;color:#333;background:#a29baa;padding:5px 10px 5px 1.75em;border-radius:5px;font-family:Lato,sans-serif;font-weight:800;-webkit-font-smoothing:antialiased;cursor:pointer;white-space:nowrap;-webkit-transition:all .3s ease;transition:all .3s ease;text-transform:uppercase}share-button:hover{color:rgba(51,51,51,0.8);background:rgba(162,155,170,0.8)}share-button:before{position:absolute;line-height:1em;left:0.6em;width:1em;height:1em;content:' ';background:url(data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2020%2020%22%20style%3D%22fill%3A%23000%3B%22%20height%3D%22%22%20width%3D%22%22%3E%20%3Cpath%20d%3D%22M15%2015H2V6h2.595s.69-.896%202.17-2H1c-.553%200-1%20.45-1%201v11c0%20.553.447%201%201%201h15c.553%200%201-.447%201-1v-3.746L15%2013.9V15zm-1.64-6.95v3.55L20%206.4l-6.64-5v3.132C5.3%204.532%205.3%2012.5%205.3%2012.5c2.282-3.748%203.686-4.45%208.06-4.45z%22%2F%3E%3C%2Fsvg%3E) no-repeat}share-button .sb-social{position:absolute;opacity:0;visibility:hidden;-webkit-transition:all 0.4s ease;transition:all 0.4s ease}share-button .sb-social.sb-center{left:50%}share-button .sb-social.sb-center.sb-top{top:0;-webkit-transform:translate(-50%,-100%);transform:translate(-50%,-100%)}share-button .sb-social.sb-center.sb-bottom{bottom:0;-webkit-transform:translate(-50%,100%);transform:translate(-50%,100%)}share-button .sb-social.sb-center.active.sb-top{top:-1em}share-button .sb-social.sb-center.active.sb-bottom{bottom:-1em}share-button .sb-social.sb-left{left:50%}share-button .sb-social.sb-left.sb-top{top:0;-webkit-transform:translate(calc(-100% + 30px),-100%);transform:translate(calc(-100% + 30px),-100%)}share-button .sb-social.sb-left.sb-middle{top:50%;left:0;-webkit-transform:translate(-100%,-50%);transform:translate(-100%,-50%)}share-button .sb-social.sb-left.sb-bottom{bottom:0;-webkit-transform:translate(calc(-100% + 30px),100%);transform:translate(calc(-100% + 30px),100%)}share-button .sb-social.sb-left.active.sb-top{top:-1em}share-button .sb-social.sb-left.active.sb-middle{left:-1em}share-button .sb-social.sb-left.active.sb-bottom{bottom:-1em}share-button .sb-social.sb-right{left:50%}share-button .sb-social.sb-right.sb-top{top:0;-webkit-transform:translate(-30px,-100%);transform:translate(-30px,-100%)}share-button .sb-social.sb-right.sb-middle{top:50%;left:100%;-webkit-transform:translate(0,-50%);transform:translate(0,-50%)}share-button .sb-social.sb-right.sb-bottom{bottom:0;-webkit-transform:translate(-30px,100%);transform:translate(-30px,100%)}share-button .sb-social.sb-right.active.sb-top{top:-1em}share-button .sb-social.sb-right.active.sb-middle{left:calc(100% + 1em)}share-button .sb-social.sb-right.active.sb-bottom{bottom:-1em}share-button .sb-social.active{opacity:1;-webkit-transition:all 0.4s ease;transition:all 0.4s ease;visibility:visible}share-button .sb-social.load{-webkit-transition:none!important;transition:none!important}@media screen and (max-width:400px){share-button .sb-social.networks-6.sb-center{white-space:initial;text-align:center;width:300px}}@media screen and (max-width:460px){share-button .sb-social.networks-7.sb-center{white-space:initial;text-align:center;width:360px}}@media screen and (max-width:400px){share-button .sb-social.networks-7.sb-center{white-space:initial;text-align:center;width:300px}}@media screen and (max-width:520px){share-button .sb-social.networks-8.sb-center{white-space:initial;text-align:center;width:420px}}@media screen and (max-width:460px){share-button .sb-social.networks-8.sb-center{white-space:initial;text-align:center;width:360px}}@media screen and (max-width:400px){share-button .sb-social.networks-8.sb-center{white-space:initial;text-align:center;width:300px}}share-button .sb-social ul{margin:0;padding:0;list-style:none;line-height:0}share-button .sb-social ul li{position:relative;height:22px;width:60px;padding:12px 0;margin:0;text-align:center;font-size:20px;cursor:pointer;z-index:2;box-sizing:content-box;-webkit-transition:all .3s ease;transition:all .3s ease}share-button .sb-social ul li.enabled{display:inline-block}share-button .sb-social ul li.disabled{display:none}share-button .sb-social ul li:hover:before{opacity:0}share-button .sb-social ul li:hover:after{opacity:0.5}share-button .sb-social ul li:before,share-button .sb-social ul li:after{content:' ';position:absolute;width:inherit;height:inherit;-webkit-transform:translate(-20%,0);transform:translate(-20%,0);-webkit-transition:all .3s ease;transition:all .3s ease;background-repeat:no-repeat!important}share-button .sb-social ul li:before{opacity:1}share-button .sb-social ul li:after{opacity:0}share-button .sb-social ul li a{position:absolute;top:0;left:0;width:100%;height:100%;z-index:3}share-button .sb-social li[class*='email']{background:#42c5b0}share-button .sb-social li[class*='email']:before{background-image:url(data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2020%2020%22%20style%3D%22fill%3A%23fff%3B%22%20height%3D%22%22%20width%3D%22%22%3E%20%3Cpath%20d%3D%22M18.64%202.634c-.344.12-17.32%206.104-17.656%206.222-.284.1-.347.345-.01.48l3.796%201.52%202.25.9L18.004%203.69c.148-.106.318.097.21.213-.106.117-7.87%208.513-7.87%208.513v.002l-.452.503.6.323%204.98%202.682c.292.156.67.027.753-.334.1-.425%202.845-12.26%202.906-12.524.08-.343-.146-.552-.49-.43zM7%2017.162c0%20.246.14.315.33.14.252-.228%202.85-2.56%202.85-2.56L7%2013.098v4.064z%22%2F%3E%3C%2Fsvg%3E)}share-button .sb-social li[class*='email']:after{background-image:url(data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2020%2020%22%20style%3D%22fill%3A%23000%3B%22%20height%3D%22%22%20width%3D%22%22%3E%20%3Cpath%20d%3D%22M18.64%202.634c-.344.12-17.32%206.104-17.656%206.222-.284.1-.347.345-.01.48l3.796%201.52%202.25.9L18.004%203.69c.148-.106.318.097.21.213-.106.117-7.87%208.513-7.87%208.513v.002l-.452.503.6.323%204.98%202.682c.292.156.67.027.753-.334.1-.425%202.845-12.26%202.906-12.524.08-.343-.146-.552-.49-.43zM7%2017.162c0%20.246.14.315.33.14.252-.228%202.85-2.56%202.85-2.56L7%2013.098v4.064z%22%2F%3E%3C%2Fsvg%3E)}share-button .sb-social li[class*='facebook']{background:#3b5998}share-button .sb-social li[class*='facebook']:before{background-image:url(data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20512%20512%22%20style%3D%22fill%3A%23fff%3B%22%20height%3D%22%22%20width%3D%22%22%3E%20%3Cpath%20d%3D%22M288%20192v-38.1c0-17.2%203.8-25.9%2030.5-25.9H352V64h-55.9c-68.5%200-91.1%2031.4-91.1%2085.3V192h-45v64h45v192h83V256h56.4l7.6-64h-64z%22%2F%3E%3C%2Fsvg%3E)}share-button .sb-social li[class*='facebook']:after{background-image:url(data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20512%20512%22%20style%3D%22fill%3A%23000%3B%22%20height%3D%22%22%20width%3D%22%22%3E%20%3Cpath%20d%3D%22M288%20192v-38.1c0-17.2%203.8-25.9%2030.5-25.9H352V64h-55.9c-68.5%200-91.1%2031.4-91.1%2085.3V192h-45v64h45v192h83V256h56.4l7.6-64h-64z%22%2F%3E%3C%2Fsvg%3E)}share-button .sb-social li[class*='googlePlus']{background:#e34429}share-button .sb-social li[class*='googlePlus']:before{background-image:url(data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2020%2020%22%20style%3D%22fill%3A%23fff%3B%22%20height%3D%22%22%20width%3D%22%22%3E%20%3Cpath%20d%3D%22M1.99%205.59c0%201.493.498%202.57%201.48%203.204.807.52%201.74.598%202.227.598.118%200%20.213-.006.28-.01%200%200-.155%201.004.59%201.996H6.53c-1.29%200-5.493.27-5.493%203.727%200%203.516%203.86%203.695%204.635%203.695.06%200%20.097-.002.097-.002.007%200%20.062.002.157.002.497%200%201.782-.062%202.975-.643%201.548-.75%202.333-2.06%202.333-3.885%200-1.764-1.196-2.814-2.07-3.582-.532-.47-.993-.873-.993-1.266%200-.4.337-.7.762-1.082.69-.615%201.34-1.492%201.34-3.15%200-1.457-.19-2.436-1.355-3.057.12-.062.55-.107.762-.137.63-.086%201.554-.184%201.554-.7V1.2h-4.6c-.046.002-4.65.172-4.65%204.39zm7.422%209.01c.088%201.406-1.115%202.443-2.922%202.574-1.834.135-3.344-.69-3.432-2.096-.043-.676.254-1.336.835-1.863.59-.533%201.398-.863%202.278-.928.106-.007.21-.013.31-.013%201.7%200%202.85%201%202.934%202.325zm-1.2-9.976c.45%201.588-.23%203.246-1.317%203.553-.125.034-.253.05-.384.05-.993%200-1.98-1.005-2.344-2.392-.204-.776-.187-1.458.047-2.112.23-.645.643-1.078%201.163-1.225.125-.034.254-.052.385-.052%201.2%200%201.973.498%202.45%202.178zM16%208V5h-2v3h-3v2h3v3h2v-3h3V8h-3z%22%2F%3E%3C%2Fsvg%3E)}share-button .sb-social li[class*='googlePlus']:after{background-image:url(data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2020%2020%22%20style%3D%22fill%3A%23000%3B%22%20height%3D%22%22%20width%3D%22%22%3E%20%3Cpath%20d%3D%22M1.99%205.59c0%201.493.498%202.57%201.48%203.204.807.52%201.74.598%202.227.598.118%200%20.213-.006.28-.01%200%200-.155%201.004.59%201.996H6.53c-1.29%200-5.493.27-5.493%203.727%200%203.516%203.86%203.695%204.635%203.695.06%200%20.097-.002.097-.002.007%200%20.062.002.157.002.497%200%201.782-.062%202.975-.643%201.548-.75%202.333-2.06%202.333-3.885%200-1.764-1.196-2.814-2.07-3.582-.532-.47-.993-.873-.993-1.266%200-.4.337-.7.762-1.082.69-.615%201.34-1.492%201.34-3.15%200-1.457-.19-2.436-1.355-3.057.12-.062.55-.107.762-.137.63-.086%201.554-.184%201.554-.7V1.2h-4.6c-.046.002-4.65.172-4.65%204.39zm7.422%209.01c.088%201.406-1.115%202.443-2.922%202.574-1.834.135-3.344-.69-3.432-2.096-.043-.676.254-1.336.835-1.863.59-.533%201.398-.863%202.278-.928.106-.007.21-.013.31-.013%201.7%200%202.85%201%202.934%202.325zm-1.2-9.976c.45%201.588-.23%203.246-1.317%203.553-.125.034-.253.05-.384.05-.993%200-1.98-1.005-2.344-2.392-.204-.776-.187-1.458.047-2.112.23-.645.643-1.078%201.163-1.225.125-.034.254-.052.385-.052%201.2%200%201.973.498%202.45%202.178zM16%208V5h-2v3h-3v2h3v3h2v-3h3V8h-3z%22%2F%3E%3C%2Fsvg%3E)}share-button .sb-social li[class*='linkedin']{background:#4875b4}share-button .sb-social li[class*='linkedin']:before{background-image:url(data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2020%2020%22%20style%3D%22fill%3A%23fff%3B%22%20height%3D%22%22%20width%3D%22%22%3E%20%3Cpath%20d%3D%22M5%203c0%201.1-.7%202-2%202-1.2%200-2-.9-2-1.9C1%202%201.8%201%203%201s2%20.9%202%202zM1%2019h4V6H1v13zM14.6%206.2c-2.1%200-3.3%201.2-3.8%202h-.1l-.2-1.7H6.9c0%201.1.1%202.4.1%203.9V19h4v-7.1c0-.4%200-.7.1-1%20.3-.7.8-1.6%201.9-1.6%201.4%200%202%201.2%202%202.8V19h4v-7.4c0-3.7-1.9-5.4-4.4-5.4z%22%2F%3E%3C%2Fsvg%3E)}share-button .sb-social li[class*='linkedin']:after{background-image:url(data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2020%2020%22%20style%3D%22fill%3A%23000%3B%22%20height%3D%22%22%20width%3D%22%22%3E%20%3Cpath%20d%3D%22M5%203c0%201.1-.7%202-2%202-1.2%200-2-.9-2-1.9C1%202%201.8%201%203%201s2%20.9%202%202zM1%2019h4V6H1v13zM14.6%206.2c-2.1%200-3.3%201.2-3.8%202h-.1l-.2-1.7H6.9c0%201.1.1%202.4.1%203.9V19h4v-7.1c0-.4%200-.7.1-1%20.3-.7.8-1.6%201.9-1.6%201.4%200%202%201.2%202%202.8V19h4v-7.4c0-3.7-1.9-5.4-4.4-5.4z%22%2F%3E%3C%2Fsvg%3E)}share-button .sb-social li[class*='pinterest']{background:#c5282f}share-button .sb-social li[class*='pinterest']:before{background-image:url(data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2020%2020%22%20style%3D%22fill%3A%23fff%3B%22%20height%3D%22%22%20width%3D%22%22%3E%20%3Cpath%20d%3D%22M8.617%2013.227C8.09%2015.98%207.45%2018.62%205.55%2020c-.587-4.162.86-7.287%201.533-10.605-1.147-1.93.138-5.812%202.555-4.855%202.975%201.176-2.576%207.172%201.15%207.922%203.89.78%205.48-6.75%203.066-9.2C10.37-.274%203.708%203.18%204.528%208.246c.2%201.238%201.478%201.613.51%203.322-2.23-.494-2.896-2.254-2.81-4.6.138-3.84%203.45-6.527%206.77-6.9%204.202-.47%208.145%201.543%208.69%205.494.613%204.462-1.896%209.294-6.39%208.946-1.217-.095-1.727-.7-2.68-1.28z%22%2F%3E%3C%2Fsvg%3E)}share-button .sb-social li[class*='pinterest']:after{background-image:url(data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2020%2020%22%20style%3D%22fill%3A%23000%3B%22%20height%3D%22%22%20width%3D%22%22%3E%20%3Cpath%20d%3D%22M8.617%2013.227C8.09%2015.98%207.45%2018.62%205.55%2020c-.587-4.162.86-7.287%201.533-10.605-1.147-1.93.138-5.812%202.555-4.855%202.975%201.176-2.576%207.172%201.15%207.922%203.89.78%205.48-6.75%203.066-9.2C10.37-.274%203.708%203.18%204.528%208.246c.2%201.238%201.478%201.613.51%203.322-2.23-.494-2.896-2.254-2.81-4.6.138-3.84%203.45-6.527%206.77-6.9%204.202-.47%208.145%201.543%208.69%205.494.613%204.462-1.896%209.294-6.39%208.946-1.217-.095-1.727-.7-2.68-1.28z%22%2F%3E%3C%2Fsvg%3E)}share-button .sb-social li[class*='reddit']{background:#a1caf2}share-button .sb-social li[class*='reddit']:before{background-image:url(data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20512%20426.66%22%20style%3D%22fill%3A%23fff%3B%22%20height%3D%22%22%20width%3D%22%22%3E%20%3Cpath%20d%3D%22M478.905%20196.556c0-4.5-1.028-8.933-3.268-13.09l-.053-.053-.026-.06c-3.004-6.198-7.72-10.862-13.4-14.05-5.677-3.19-12.317-4.836-18.983-4.836-6.02%200-12.016%201.363-17.338%204.038%2016.916%2014.677%2031.765%2032.37%2041.37%2053.128%203.08-2.668%205.717-5.97%207.68-9.604%202.57-4.785%204.018-10.186%204.018-15.475zm-33.635%2073.442c0-18.484-6.653-36.98-17.43-51.94-21.476-29.868-54.82-49.38-89.497-60.243l-.25-.118c-6.64-2.05-13.373-3.808-20.158-5.402-20.263-4.61-41.026-6.884-61.796-6.884-27.874%200-55.738%204.1-82.43%2012.347-34.67%2011.034-68.108%2030.375-89.557%2060.36v.054C73.29%20233.138%2066.92%20251.74%2066.92%20270.226c0%206.824.857%2013.648%202.655%2020.315h.02c3.906%2014.834%2011.54%2028.153%2021.416%2039.76%209.875%2011.542%2021.99%2021.45%2034.736%2029.525%202.82%201.766%205.652%203.412%208.55%205.06%2037.01%2020.645%2079.63%2029.695%20121.947%2029.695%207.146%200%2014.354-.224%2021.455-.737%2042.62-3.518%2085.41-16.1%20119.995-41.804h.013c11.015-8.145%2021.212-18.05%2029.288-29.25%208.09-11.21%2014.018-23.715%2016.653-37.31v-.067h.012c1.093-5.126%201.607-10.238%201.607-15.416zM86.078%20168.736c-5.514-2.562-11.212-4.387-16.845-4.387-.94%200-1.896.057-2.846.17h-.27c-8.09.23-16.25%203.754-22.377%209.445-6.133%205.633-10.19%2013.2-10.494%2021.62v.053l-.013.06c-.06.684-.08%201.362-.08%201.988%200%205.178%201.59%2010.184%204.276%2014.735%201.994%203.414%204.602%206.483%207.554%209.158%209.453-20.703%2024.222-38.226%2041.093-52.844zM390.448%2058.2c0%20.566%200%201.14.066%201.706v.112c.25%207.167%203.637%2013.827%208.788%2018.774%205.164%204.895%2012.016%207.964%2018.972%207.964h.185l1.5.06c7.01%200%2013.98-3.017%2019.21-7.91%205.242-4.948%208.707-11.66%208.983-18.888v-.053c.053-.572.08-1.08.08-1.653%200-7.45-3.48-14.505-8.933-19.795-5.414-5.237-12.713-8.478-19.92-8.478-2.318%200-4.61.34-6.877%201.026l-.053.053h-.08c-5.928%201.534-11.487%205.177-15.48%2010.07-4.017%204.835-6.44%2010.81-6.44%2017.01zm121.447%20134.937v.06c.08%201.14.105%202.22.105%203.36%200%2012.396-3.992%2024.405-10.646%2034.523-6.218%209.5-14.782%2017.47-24.637%2022.818.633%204.94%201%209.947%201%2014.9-.025%2026.798-9.247%2053.135-25.334%2074.24h-.026c-29.735%2039.538-75.373%2062.857-121.46%2074.583h-.012l-.04.055c-24.57%205.98-49.906%208.985-75.247%208.985-37.766%200-75.512-6.772-110.722-20.923h-.046c-36.508-15.085-71.296-38.97-92.633-74.016-11.475-18.72-17.772-40.683-17.772-62.685%200-5.006.33-10.013%201-14.913-9.617-5.454-17.937-13.082-24.116-22.238C4.71%20221.976.532%20210.487%200%20198.314v-.224c.013-17.068%207.424-33.228%2018.945-45.11%2011.52-11.95%2027.252-19.743%2044.136-19.743h.7c1.76-.12%203.558-.172%205.343-.172%208.478%200%2016.976%201.364%2025.045%204.493h.086c6.89%202.904%2013.734%206.43%2019.834%2011.265%201.977-1.02%204.13-2.22%206.555-3.13%2036.982-21.902%2079.958-30.32%20121.848-32.766.363-20.764%202.91-42.495%2013.03-61.5%208.426-15.81%2023.05-28.102%2040.48-32.37h.158c6.627-1.305%2013.32-1.877%2019.96-1.877%2017.706%200%2035.19%204.156%2051.565%2010.698%207.233-10.922%2017.575-19.46%2029.71-24.235l.118-.06.106-.053C404.73%201.31%20412.266%200%20419.83%200c7.956%200%2015.98%201.482%2023.503%204.835v-.053l.026.053.13.06c10.79%204.157%2019.92%2011.83%2026.39%2021.33%206.47%209.618%2010.29%2021.105%2010.29%2032.884%200%202.16-.133%204.32-.384%206.54l-.013.06-.026.11c-1.265%2015.25-8.985%2028.617-19.92%2038.116-11%209.617-25.243%2015.42-39.867%2015.42-2.345%200-4.716-.17-7.06-.46-14.507-1.134-28.024-8.13-37.958-18.604-9.974-10.408-16.39-24.347-16.39-39.36%200-.685.066-1.48.093-2.166-13.623-6.087-28.062-11.094-42.437-11.094-2.068%200-4.15.12-6.23.343h-.027c-10.75%201.027-20.75%207.793-25.597%2017.522v.053c-7.365%2014.342-8.814%2031.067-9.038%2047.733%2041.224%202.675%2082.71%2012.575%20119.087%2033.45h.054l.527.343c.686.396%201.95%201.08%203.123%201.707%202.49-2.05%205.14-4.098%208.155-5.916%2011.028-7.338%2024.085-10.98%2037.154-10.98%205.81%200%2011.62.737%2017.26%202.16h.013l.225.06.224.06c13.307%203.41%2025.36%2011.033%2034.426%2021.33%209.05%2010.354%2015.15%2023.384%2016.337%2037.6zm-345.39%2080.38h.15c3.254%201.198%206.606%201.765%209.934%201.765%208.285%200%2016.34-3.347%2022.44-8.866%206.094-5.573%2010.258-13.426%2010.258-22.358l-.015-.737.033-1.315c0-8.867-4.11-16.785-10.145-22.292-6.053-5.64-14.09-9.05-22.41-9.05-2.22%200-4.492.288-6.7.796h-.124c-11.008%202.34-20.678%2010.466-24.24%2021.73l-.015.066c-1.02%203.057-1.494%206.244-1.494%209.38%200%206.93%202.272%2013.597%206.198%2019.17%203.887%205.4%209.4%209.67%2016.008%2011.66m179.218%2041.42c-2.635-1.713-5.665-2.74-8.88-2.74-2.582%200-5.27.737-7.654%202.345-22.62%2013.48-49.234%2020.87-75.644%2020.87-19.82%200-39.524-4.15-57.37-12.91l-.092-.054-.085-.053c-2.688-1.08-5.758-3.426-9.104-5.64-1.7-1.132-3.47-2.213-5.44-3.017-1.942-.855-4.103-1.423-6.41-1.423-1.91%200-3.92.462-5.9%201.305l-.303.118h.013c-3.107%201.2-5.538%203.413-7.106%205.97-1.634%202.687-2.438%205.743-2.438%208.826%200%202.794.66%205.574%202.016%208.077%201.29%202.384%203.274%204.49%205.876%205.86%2025.514%2017.233%2055.545%2025.03%2085.702%2024.967%2027.187%200%2054.538-6.258%2078.885-17.747l.132-.054.132-.052c3.2-1.95%207.47-3.65%2011.486-6.087%202.003-1.317%203.94-2.74%205.612-4.678%201.66-1.87%203.003-4.204%203.767-6.997.304-1.252.462-2.45.462-3.584%200-2.267-.567-4.428-1.49-6.378-1.373-2.844-3.585-5.215-6.168-6.928zm20.473-82.5c1.318%203.372%201.91%206.89%201.91%2010.354%200%206.942-2.41%2013.78-6.455%2019.287-3.992%205.468-9.657%209.67-16.323%2011.555l-.146.053h-.09c-3.11%201.08-6.326%201.594-9.488%201.594-7.457%200-14.756-2.677-20.605-7.274-5.797-4.56-10.197-11.093-11.567-18.84h-.012l-.014-.105-.026-.064h.026c-.435-1.99-.658-3.98-.658-5.97%200-6.718%202.292-13.2%206.073-18.496%203.766-5.342%209.075-9.55%2015.294-11.712h.093c3.518-1.31%207.232-1.99%2010.896-1.99%206.692%200%2013.28%202.043%2018.84%205.745%205.48%203.637%209.934%208.985%2012.173%2015.65l.053.106.04.103h-.016z%22%2F%3E%3C%2Fsvg%3E)}share-button .sb-social li[class*='reddit']:after{background-image:url(data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20512%20426.66%22%20style%3D%22fill%3A%23000%3B%22%20height%3D%22%22%20width%3D%22%22%3E%20%3Cpath%20d%3D%22M478.905%20196.556c0-4.5-1.028-8.933-3.268-13.09l-.053-.053-.026-.06c-3.004-6.198-7.72-10.862-13.4-14.05-5.677-3.19-12.317-4.836-18.983-4.836-6.02%200-12.016%201.363-17.338%204.038%2016.916%2014.677%2031.765%2032.37%2041.37%2053.128%203.08-2.668%205.717-5.97%207.68-9.604%202.57-4.785%204.018-10.186%204.018-15.475zm-33.635%2073.442c0-18.484-6.653-36.98-17.43-51.94-21.476-29.868-54.82-49.38-89.497-60.243l-.25-.118c-6.64-2.05-13.373-3.808-20.158-5.402-20.263-4.61-41.026-6.884-61.796-6.884-27.874%200-55.738%204.1-82.43%2012.347-34.67%2011.034-68.108%2030.375-89.557%2060.36v.054C73.29%20233.138%2066.92%20251.74%2066.92%20270.226c0%206.824.857%2013.648%202.655%2020.315h.02c3.906%2014.834%2011.54%2028.153%2021.416%2039.76%209.875%2011.542%2021.99%2021.45%2034.736%2029.525%202.82%201.766%205.652%203.412%208.55%205.06%2037.01%2020.645%2079.63%2029.695%20121.947%2029.695%207.146%200%2014.354-.224%2021.455-.737%2042.62-3.518%2085.41-16.1%20119.995-41.804h.013c11.015-8.145%2021.212-18.05%2029.288-29.25%208.09-11.21%2014.018-23.715%2016.653-37.31v-.067h.012c1.093-5.126%201.607-10.238%201.607-15.416zM86.078%20168.736c-5.514-2.562-11.212-4.387-16.845-4.387-.94%200-1.896.057-2.846.17h-.27c-8.09.23-16.25%203.754-22.377%209.445-6.133%205.633-10.19%2013.2-10.494%2021.62v.053l-.013.06c-.06.684-.08%201.362-.08%201.988%200%205.178%201.59%2010.184%204.276%2014.735%201.994%203.414%204.602%206.483%207.554%209.158%209.453-20.703%2024.222-38.226%2041.093-52.844zM390.448%2058.2c0%20.566%200%201.14.066%201.706v.112c.25%207.167%203.637%2013.827%208.788%2018.774%205.164%204.895%2012.016%207.964%2018.972%207.964h.185l1.5.06c7.01%200%2013.98-3.017%2019.21-7.91%205.242-4.948%208.707-11.66%208.983-18.888v-.053c.053-.572.08-1.08.08-1.653%200-7.45-3.48-14.505-8.933-19.795-5.414-5.237-12.713-8.478-19.92-8.478-2.318%200-4.61.34-6.877%201.026l-.053.053h-.08c-5.928%201.534-11.487%205.177-15.48%2010.07-4.017%204.835-6.44%2010.81-6.44%2017.01zm121.447%20134.937v.06c.08%201.14.105%202.22.105%203.36%200%2012.396-3.992%2024.405-10.646%2034.523-6.218%209.5-14.782%2017.47-24.637%2022.818.633%204.94%201%209.947%201%2014.9-.025%2026.798-9.247%2053.135-25.334%2074.24h-.026c-29.735%2039.538-75.373%2062.857-121.46%2074.583h-.012l-.04.055c-24.57%205.98-49.906%208.985-75.247%208.985-37.766%200-75.512-6.772-110.722-20.923h-.046c-36.508-15.085-71.296-38.97-92.633-74.016-11.475-18.72-17.772-40.683-17.772-62.685%200-5.006.33-10.013%201-14.913-9.617-5.454-17.937-13.082-24.116-22.238C4.71%20221.976.532%20210.487%200%20198.314v-.224c.013-17.068%207.424-33.228%2018.945-45.11%2011.52-11.95%2027.252-19.743%2044.136-19.743h.7c1.76-.12%203.558-.172%205.343-.172%208.478%200%2016.976%201.364%2025.045%204.493h.086c6.89%202.904%2013.734%206.43%2019.834%2011.265%201.977-1.02%204.13-2.22%206.555-3.13%2036.982-21.902%2079.958-30.32%20121.848-32.766.363-20.764%202.91-42.495%2013.03-61.5%208.426-15.81%2023.05-28.102%2040.48-32.37h.158c6.627-1.305%2013.32-1.877%2019.96-1.877%2017.706%200%2035.19%204.156%2051.565%2010.698%207.233-10.922%2017.575-19.46%2029.71-24.235l.118-.06.106-.053C404.73%201.31%20412.266%200%20419.83%200c7.956%200%2015.98%201.482%2023.503%204.835v-.053l.026.053.13.06c10.79%204.157%2019.92%2011.83%2026.39%2021.33%206.47%209.618%2010.29%2021.105%2010.29%2032.884%200%202.16-.133%204.32-.384%206.54l-.013.06-.026.11c-1.265%2015.25-8.985%2028.617-19.92%2038.116-11%209.617-25.243%2015.42-39.867%2015.42-2.345%200-4.716-.17-7.06-.46-14.507-1.134-28.024-8.13-37.958-18.604-9.974-10.408-16.39-24.347-16.39-39.36%200-.685.066-1.48.093-2.166-13.623-6.087-28.062-11.094-42.437-11.094-2.068%200-4.15.12-6.23.343h-.027c-10.75%201.027-20.75%207.793-25.597%2017.522v.053c-7.365%2014.342-8.814%2031.067-9.038%2047.733%2041.224%202.675%2082.71%2012.575%20119.087%2033.45h.054l.527.343c.686.396%201.95%201.08%203.123%201.707%202.49-2.05%205.14-4.098%208.155-5.916%2011.028-7.338%2024.085-10.98%2037.154-10.98%205.81%200%2011.62.737%2017.26%202.16h.013l.225.06.224.06c13.307%203.41%2025.36%2011.033%2034.426%2021.33%209.05%2010.354%2015.15%2023.384%2016.337%2037.6zm-345.39%2080.38h.15c3.254%201.198%206.606%201.765%209.934%201.765%208.285%200%2016.34-3.347%2022.44-8.866%206.094-5.573%2010.258-13.426%2010.258-22.358l-.015-.737.033-1.315c0-8.867-4.11-16.785-10.145-22.292-6.053-5.64-14.09-9.05-22.41-9.05-2.22%200-4.492.288-6.7.796h-.124c-11.008%202.34-20.678%2010.466-24.24%2021.73l-.015.066c-1.02%203.057-1.494%206.244-1.494%209.38%200%206.93%202.272%2013.597%206.198%2019.17%203.887%205.4%209.4%209.67%2016.008%2011.66m179.218%2041.42c-2.635-1.713-5.665-2.74-8.88-2.74-2.582%200-5.27.737-7.654%202.345-22.62%2013.48-49.234%2020.87-75.644%2020.87-19.82%200-39.524-4.15-57.37-12.91l-.092-.054-.085-.053c-2.688-1.08-5.758-3.426-9.104-5.64-1.7-1.132-3.47-2.213-5.44-3.017-1.942-.855-4.103-1.423-6.41-1.423-1.91%200-3.92.462-5.9%201.305l-.303.118h.013c-3.107%201.2-5.538%203.413-7.106%205.97-1.634%202.687-2.438%205.743-2.438%208.826%200%202.794.66%205.574%202.016%208.077%201.29%202.384%203.274%204.49%205.876%205.86%2025.514%2017.233%2055.545%2025.03%2085.702%2024.967%2027.187%200%2054.538-6.258%2078.885-17.747l.132-.054.132-.052c3.2-1.95%207.47-3.65%2011.486-6.087%202.003-1.317%203.94-2.74%205.612-4.678%201.66-1.87%203.003-4.204%203.767-6.997.304-1.252.462-2.45.462-3.584%200-2.267-.567-4.428-1.49-6.378-1.373-2.844-3.585-5.215-6.168-6.928zm20.473-82.5c1.318%203.372%201.91%206.89%201.91%2010.354%200%206.942-2.41%2013.78-6.455%2019.287-3.992%205.468-9.657%209.67-16.323%2011.555l-.146.053h-.09c-3.11%201.08-6.326%201.594-9.488%201.594-7.457%200-14.756-2.677-20.605-7.274-5.797-4.56-10.197-11.093-11.567-18.84h-.012l-.014-.105-.026-.064h.026c-.435-1.99-.658-3.98-.658-5.97%200-6.718%202.292-13.2%206.073-18.496%203.766-5.342%209.075-9.55%2015.294-11.712h.093c3.518-1.31%207.232-1.99%2010.896-1.99%206.692%200%2013.28%202.043%2018.84%205.745%205.48%203.637%209.934%208.985%2012.173%2015.65l.053.106.04.103h-.016z%22%2F%3E%3C%2Fsvg%3E)}share-button .sb-social li[class*='twitter']{background:#6cdfea}share-button .sb-social li[class*='twitter']:before{background-image:url(data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2020%2020%22%20style%3D%22fill%3A%23fff%3B%22%20height%3D%22%22%20width%3D%22%22%3E%20%3Cpath%20d%3D%22M17.316%206.246c.008.162.01.326.01.488%200%204.99-3.796%2010.742-10.74%2010.742-2.132%200-4.115-.625-5.786-1.697.296.033.596.05.9.05%201.77%200%203.397-.603%204.688-1.614-1.65-.03-3.046-1.12-3.526-2.62.23.042.467.065.71.065.345%200%20.68-.044.995-.13C2.84%2011.18%201.54%209.658%201.54%207.828V7.78c.508.284%201.09.454%201.71.474-1.014-.678-1.68-1.832-1.68-3.143%200-.69.185-1.34.51-1.896C3.943%205.498%206.726%207%209.863%207.158c-.064-.277-.097-.564-.097-.86%200-2.085%201.69-3.774%203.774-3.774%201.085%200%202.066.457%202.755%201.19.86-.17%201.667-.483%202.397-.915-.282.88-.88%201.62-1.66%202.086.764-.092%201.49-.293%202.168-.594-.506.758-1.146%201.422-1.884%201.953z%22%2F%3E%3C%2Fsvg%3E)}share-button .sb-social li[class*='twitter']:after{background-image:url(data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2020%2020%22%20style%3D%22fill%3A%23000%3B%22%20height%3D%22%22%20width%3D%22%22%3E%20%3Cpath%20d%3D%22M17.316%206.246c.008.162.01.326.01.488%200%204.99-3.796%2010.742-10.74%2010.742-2.132%200-4.115-.625-5.786-1.697.296.033.596.05.9.05%201.77%200%203.397-.603%204.688-1.614-1.65-.03-3.046-1.12-3.526-2.62.23.042.467.065.71.065.345%200%20.68-.044.995-.13C2.84%2011.18%201.54%209.658%201.54%207.828V7.78c.508.284%201.09.454%201.71.474-1.014-.678-1.68-1.832-1.68-3.143%200-.69.185-1.34.51-1.896C3.943%205.498%206.726%207%209.863%207.158c-.064-.277-.097-.564-.097-.86%200-2.085%201.69-3.774%203.774-3.774%201.085%200%202.066.457%202.755%201.19.86-.17%201.667-.483%202.397-.915-.282.88-.88%201.62-1.66%202.086.764-.092%201.49-.293%202.168-.594-.506.758-1.146%201.422-1.884%201.953z%22%2F%3E%3C%2Fsvg%3E)}share-button .sb-social li[class*='whatsapp']{background:#4dc247}share-button .sb-social li[class*='whatsapp']:before{background-image:url(data:image/svg+xml,%3Csvg%20viewBox%3D%220%200%2087%2088%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20style%3D%22fill%3A%23fff%3B%22%20height%3D%22%22%20width%3D%22%22%3E%20%3Cpath%20d%3D%22M61.623%2051.83c-.94-.515-5.562-3.01-6.428-3.363-.867-.35-1.5-.535-2.173.4-.675.934-2.593%203.023-3.175%203.642-.583.615-1.144.672-2.084.16-.94-.516-3.99-1.646-7.525-5.045-2.752-2.645-4.557-5.854-5.08-6.834-.526-.977-.005-1.477.493-1.936.45-.413%201-1.084%201.5-1.625.5-.54.678-.934%201.02-1.563.343-.625.204-1.19-.017-1.678-.222-.49-1.962-5.276-2.687-7.223-.725-1.946-1.537-1.657-2.095-1.678-.557-.023-1.194-.126-1.833-.15-.637-.024-1.684.176-2.6%201.104-.912.922-3.474%203.147-3.65%207.862-.174%204.713%203.084%209.395%203.538%2010.05.456.658%206.23%2010.875%2015.823%2015.075%209.596%204.2%209.645%202.92%2011.406%202.826%201.763-.09%205.756-2.104%206.638-4.31.884-2.205.955-4.125.73-4.532-.225-.408-.855-.673-1.794-1.188m-17.6%2022.714c-6.345%200-12.253-1.903-17.187-5.163L14.84%2073.22l3.902-11.6C15%2056.466%2012.79%2050.137%2012.79%2043.3c0-17.226%2014.014-31.24%2031.24-31.24%2017.224%200%2031.24%2014.012%2031.24%2031.24%200%2017.226-14.016%2031.24-31.24%2031.24M6.5%2043.3c0%207.09%201.968%2013.72%205.384%2019.38L5.11%2082.808l20.78-6.65c5.375%202.972%2011.558%204.667%2018.137%204.667%2020.725%200%2037.528-16.802%2037.528-37.525%200-20.727-16.804-37.528-37.53-37.528-20.723%200-37.523%2016.8-37.523%2037.527z%22%2F%3E%3C%2Fsvg%3E)}share-button .sb-social li[class*='whatsapp']:after{background-image:url(data:image/svg+xml,%3Csvg%20viewBox%3D%220%200%2087%2088%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20style%3D%22fill%3A%23000%3B%22%20height%3D%22%22%20width%3D%22%22%3E%20%3Cpath%20d%3D%22M61.623%2051.83c-.94-.515-5.562-3.01-6.428-3.363-.867-.35-1.5-.535-2.173.4-.675.934-2.593%203.023-3.175%203.642-.583.615-1.144.672-2.084.16-.94-.516-3.99-1.646-7.525-5.045-2.752-2.645-4.557-5.854-5.08-6.834-.526-.977-.005-1.477.493-1.936.45-.413%201-1.084%201.5-1.625.5-.54.678-.934%201.02-1.563.343-.625.204-1.19-.017-1.678-.222-.49-1.962-5.276-2.687-7.223-.725-1.946-1.537-1.657-2.095-1.678-.557-.023-1.194-.126-1.833-.15-.637-.024-1.684.176-2.6%201.104-.912.922-3.474%203.147-3.65%207.862-.174%204.713%203.084%209.395%203.538%2010.05.456.658%206.23%2010.875%2015.823%2015.075%209.596%204.2%209.645%202.92%2011.406%202.826%201.763-.09%205.756-2.104%206.638-4.31.884-2.205.955-4.125.73-4.532-.225-.408-.855-.673-1.794-1.188m-17.6%2022.714c-6.345%200-12.253-1.903-17.187-5.163L14.84%2073.22l3.902-11.6C15%2056.466%2012.79%2050.137%2012.79%2043.3c0-17.226%2014.014-31.24%2031.24-31.24%2017.224%200%2031.24%2014.012%2031.24%2031.24%200%2017.226-14.016%2031.24-31.24%2031.24M6.5%2043.3c0%207.09%201.968%2013.72%205.384%2019.38L5.11%2082.808l20.78-6.65c5.375%202.972%2011.558%204.667%2018.137%204.667%2020.725%200%2037.528-16.802%2037.528-37.525%200-20.727-16.804-37.528-37.53-37.528-20.723%200-37.523%2016.8-37.523%2037.527z%22%2F%3E%3C%2Fsvg%3E)} \ No newline at end of file diff --git a/js/share-button.min.js b/js/share-button.min.js new file mode 100644 index 0000000..3353c65 --- /dev/null +++ b/js/share-button.min.js @@ -0,0 +1,2 @@ +!function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.ShareButton=e()}}(function(){return function e(t,n,o){function i(s,a){if(!n[s]){if(!t[s]){var c="function"==typeof require&&require;if(!a&&c)return c(s,!0);if(r)return r(s,!0);throw new Error("Cannot find module '"+s+"'")}var u=n[s]={exports:{}};t[s][0].call(u.exports,function(e){var n=t[s][1][e];return i(n?n:e)},u,u.exports,e,t,n,o)}return n[s].exports}for(var r="function"==typeof require&&require,s=0;sa;)s.call(e,i=r[a++])&&t.push(i);return t}},{"./$":27}],14:[function(e,t,n){var o=e("./$.global"),i=e("./$.core"),r=e("./$.hide"),s=e("./$.redefine"),a=e("./$.ctx"),c="prototype",u=function(e,t,n){var l,f,d,h,p=e&u.F,g=e&u.G,y=e&u.S,m=e&u.P,v=e&u.B,b=g?o:y?o[t]||(o[t]={}):(o[t]||{})[c],w=g?i:i[t]||(i[t]={}),k=w[c]||(w[c]={});g&&(n=t);for(l in n)f=!p&&b&&l in b,d=(f?b:n)[l],h=v&&f?a(d,o):m&&"function"==typeof d?a(Function.call,d):d,b&&!f&&s(b,l,d),w[l]!=d&&r(w,l,h),m&&k[l]!=d&&(k[l]=d)};o.core=i,u.F=1,u.G=2,u.S=4,u.P=8,u.B=16,u.W=32,t.exports=u},{"./$.core":9,"./$.ctx":10,"./$.global":17,"./$.hide":19,"./$.redefine":31}],15:[function(e,t,n){t.exports=function(e){try{return!!e()}catch(t){return!0}}},{}],16:[function(e,t,n){var o=e("./$.to-iobject"),i=e("./$").getNames,r={}.toString,s="object"==typeof window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],a=function(e){try{return i(e)}catch(t){return s.slice()}};t.exports.get=function(e){return s&&"[object Window]"==r.call(e)?a(e):i(o(e))}},{"./$":27,"./$.to-iobject":34}],17:[function(e,t,n){var o=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=o)},{}],18:[function(e,t,n){var o={}.hasOwnProperty;t.exports=function(e,t){return o.call(e,t)}},{}],19:[function(e,t,n){var o=e("./$"),i=e("./$.property-desc");t.exports=e("./$.descriptors")?function(e,t,n){return o.setDesc(e,t,i(1,n))}:function(e,t,n){return e[t]=n,e}},{"./$":27,"./$.descriptors":12,"./$.property-desc":30}],20:[function(e,t,n){var o=e("./$.cof");t.exports=Object("z").propertyIsEnumerable(0)?Object:function(e){return"String"==o(e)?e.split(""):Object(e)}},{"./$.cof":8}],21:[function(e,t,n){var o=e("./$.cof");t.exports=Array.isArray||function(e){return"Array"==o(e)}},{"./$.cof":8}],22:[function(e,t,n){t.exports=function(e){return"object"==typeof e?null!==e:"function"==typeof e}},{}],23:[function(e,t,n){"use strict";var o=e("./$"),i=e("./$.property-desc"),r=e("./$.set-to-string-tag"),s={};e("./$.hide")(s,e("./$.wks")("iterator"),function(){return this}),t.exports=function(e,t,n){e.prototype=o.create(s,{next:i(1,n)}),r(e,t+" Iterator")}},{"./$":27,"./$.hide":19,"./$.property-desc":30,"./$.set-to-string-tag":32,"./$.wks":36}],24:[function(e,t,n){"use strict";var o=e("./$.library"),i=e("./$.export"),r=e("./$.redefine"),s=e("./$.hide"),a=e("./$.has"),c=e("./$.iterators"),u=e("./$.iter-create"),l=e("./$.set-to-string-tag"),f=e("./$").getProto,d=e("./$.wks")("iterator"),h=!([].keys&&"next"in[].keys()),p="@@iterator",g="keys",y="values",m=function(){return this};t.exports=function(e,t,n,v,b,w,k){u(n,t,v);var $,_,j=function(e){if(!h&&e in C)return C[e];switch(e){case g:return function(){return new n(this,e)};case y:return function(){return new n(this,e)}}return function(){return new n(this,e)}},S=t+" Iterator",x=b==y,O=!1,C=e.prototype,P=C[d]||C[p]||b&&C[b],L=P||j(b);if(P){var E=f(L.call(new e));l(E,S,!0),!o&&a(C,p)&&s(E,d,m),x&&P.name!==y&&(O=!0,L=function(){return P.call(this)})}if(o&&!k||!h&&!O&&C[d]||s(C,d,L),c[t]=L,c[S]=m,b)if($={values:x?L:j(y),keys:w?L:j(g),entries:x?j("entries"):L},k)for(_ in $)_ in C||r(C,_,$[_]);else i(i.P+i.F*(h||O),t,$);return $}},{"./$":27,"./$.export":14,"./$.has":18,"./$.hide":19,"./$.iter-create":23,"./$.iterators":26,"./$.library":29,"./$.redefine":31,"./$.set-to-string-tag":32,"./$.wks":36}],25:[function(e,t,n){t.exports=function(e,t){return{value:t,done:!!e}}},{}],26:[function(e,t,n){t.exports={}},{}],27:[function(e,t,n){var o=Object;t.exports={create:o.create,getProto:o.getPrototypeOf,isEnum:{}.propertyIsEnumerable,getDesc:o.getOwnPropertyDescriptor,setDesc:o.defineProperty,setDescs:o.defineProperties,getKeys:o.keys,getNames:o.getOwnPropertyNames,getSymbols:o.getOwnPropertySymbols,each:[].forEach}},{}],28:[function(e,t,n){var o=e("./$"),i=e("./$.to-iobject");t.exports=function(e,t){for(var n,r=i(e),s=o.getKeys(r),a=s.length,c=0;a>c;)if(r[n=s[c++]]===t)return n}},{"./$":27,"./$.to-iobject":34}],29:[function(e,t,n){t.exports=!1},{}],30:[function(e,t,n){t.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},{}],31:[function(e,t,n){var o=e("./$.global"),i=e("./$.hide"),r=e("./$.uid")("src"),s="toString",a=Function[s],c=(""+a).split(s);e("./$.core").inspectSource=function(e){return a.call(e)},(t.exports=function(e,t,n,s){"function"==typeof n&&(n.hasOwnProperty(r)||i(n,r,e[t]?""+e[t]:c.join(String(t))),n.hasOwnProperty("name")||i(n,"name",t)),e===o?e[t]=n:(s||delete e[t],i(e,t,n))})(Function.prototype,s,function(){return"function"==typeof this&&this[r]||a.call(this)})},{"./$.core":9,"./$.global":17,"./$.hide":19,"./$.uid":35}],32:[function(e,t,n){var o=e("./$").setDesc,i=e("./$.has"),r=e("./$.wks")("toStringTag");t.exports=function(e,t,n){e&&!i(e=n?e:e.prototype,r)&&o(e,r,{configurable:!0,value:t})}},{"./$":27,"./$.has":18,"./$.wks":36}],33:[function(e,t,n){var o=e("./$.global"),i="__core-js_shared__",r=o[i]||(o[i]={});t.exports=function(e){return r[e]||(r[e]={})}},{"./$.global":17}],34:[function(e,t,n){var o=e("./$.iobject"),i=e("./$.defined");t.exports=function(e){return o(i(e))}},{"./$.defined":11,"./$.iobject":20}],35:[function(e,t,n){var o=0,i=Math.random();t.exports=function(e){return"Symbol(".concat(void 0===e?"":e,")_",(++o+i).toString(36))}},{}],36:[function(e,t,n){var o=e("./$.shared")("wks"),i=e("./$.uid"),r=e("./$.global").Symbol;t.exports=function(e){return o[e]||(o[e]=r&&r[e]||(r||i)("Symbol."+e))}},{"./$.global":17,"./$.shared":33,"./$.uid":35}],37:[function(e,t,n){"use strict";var o=e("./$.add-to-unscopables"),i=e("./$.iter-step"),r=e("./$.iterators"),s=e("./$.to-iobject");t.exports=e("./$.iter-define")(Array,"Array",function(e,t){this._t=s(e),this._i=0,this._k=t},function(){var e=this._t,t=this._k,n=this._i++;return!e||n>=e.length?(this._t=void 0,i(1)):"keys"==t?i(0,n):"values"==t?i(0,e[n]):i(0,[n,e[n]])},"values"),r.Arguments=r.Array,o("keys"),o("values"),o("entries")},{"./$.add-to-unscopables":5,"./$.iter-define":24,"./$.iter-step":25,"./$.iterators":26,"./$.to-iobject":34}],38:[function(e,t,n){var o=e("./$.export");o(o.S,"Math",{trunc:function(e){return(e>0?Math.floor:Math.ceil)(e)}})},{"./$.export":14}],39:[function(e,t,n){"use strict";var o=e("./$.classof"),i={};i[e("./$.wks")("toStringTag")]="z",i+""!="[object z]"&&e("./$.redefine")(Object.prototype,"toString",function(){return"[object "+o(this)+"]"},!0)},{"./$.classof":7,"./$.redefine":31,"./$.wks":36}],40:[function(e,t,n){"use strict";var o=e("./$"),i=e("./$.global"),r=e("./$.has"),s=e("./$.descriptors"),a=e("./$.export"),c=e("./$.redefine"),u=e("./$.fails"),l=e("./$.shared"),f=e("./$.set-to-string-tag"),d=e("./$.uid"),h=e("./$.wks"),p=e("./$.keyof"),g=e("./$.get-names"),y=e("./$.enum-keys"),m=e("./$.is-array"),v=e("./$.an-object"),b=e("./$.to-iobject"),w=e("./$.property-desc"),k=o.getDesc,$=o.setDesc,_=o.create,j=g.get,S=i.Symbol,x=i.JSON,O=x&&x.stringify,C=!1,P=h("_hidden"),L=o.isEnum,E=l("symbol-registry"),T=l("symbols"),A="function"==typeof S,F=Object.prototype,N=s&&u(function(){return 7!=_($({},"a",{get:function(){return $(this,"a",{value:7}).a}})).a})?function(e,t,n){var o=k(F,t);o&&delete F[t],$(e,t,n),o&&e!==F&&$(F,t,o)}:$,I=function(e){var t=T[e]=_(S.prototype);return t._k=e,s&&C&&N(F,e,{configurable:!0,set:function(t){r(this,P)&&r(this[P],e)&&(this[P][e]=!1),N(this,e,w(1,t))}}),t},B=function(e){return"symbol"==typeof e},D=function(e,t,n){return n&&r(T,t)?(n.enumerable?(r(e,P)&&e[P][t]&&(e[P][t]=!1),n=_(n,{enumerable:w(0,!1)})):(r(e,P)||$(e,P,w(1,{})),e[P][t]=!0),N(e,t,n)):$(e,t,n)},M=function(e,t){v(e);for(var n,o=y(t=b(t)),i=0,r=o.length;r>i;)D(e,n=o[i++],t[n]);return e},H=function(e,t){return void 0===t?_(e):M(_(e),t)},q=function(e){var t=L.call(this,e);return t||!r(this,e)||!r(T,e)||r(this,P)&&this[P][e]?t:!0},W=function(e,t){var n=k(e=b(e),t);return!n||!r(T,t)||r(e,P)&&e[P][t]||(n.enumerable=!0),n},z=function(e){for(var t,n=j(b(e)),o=[],i=0;n.length>i;)r(T,t=n[i++])||t==P||o.push(t);return o},U=function(e){for(var t,n=j(b(e)),o=[],i=0;n.length>i;)r(T,t=n[i++])&&o.push(T[t]);return o},R=function(e){if(void 0!==e&&!B(e)){for(var t,n,o=[e],i=1,r=arguments;r.length>i;)o.push(r[i++]);return t=o[1],"function"==typeof t&&(n=t),!n&&m(t)||(t=function(e,t){return n&&(t=n.call(this,e,t)),B(t)?void 0:t}),o[1]=t,O.apply(x,o)}},J=u(function(){var e=S();return"[null]"!=O([e])||"{}"!=O({a:e})||"{}"!=O(Object(e))});A||(S=function(){if(B(this))throw TypeError("Symbol is not a constructor");return I(d(arguments.length>0?arguments[0]:void 0))},c(S.prototype,"toString",function(){return this._k}),B=function(e){return e instanceof S},o.create=H,o.isEnum=q,o.getDesc=W,o.setDesc=D,o.setDescs=M,o.getNames=g.get=z,o.getSymbols=U,s&&!e("./$.library")&&c(F,"propertyIsEnumerable",q,!0));var G={"for":function(e){return r(E,e+="")?E[e]:E[e]=S(e)},keyFor:function(e){return p(E,e)},useSetter:function(){C=!0},useSimple:function(){C=!1}};o.each.call("hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),function(e){var t=h(e);G[e]=A?t:I(t)}),C=!0,a(a.G+a.W,{Symbol:S}),a(a.S,"Symbol",G),a(a.S+a.F*!A,"Object",{create:H,defineProperty:D,defineProperties:M,getOwnPropertyDescriptor:W,getOwnPropertyNames:z,getOwnPropertySymbols:U}),x&&a(a.S+a.F*(!A||J),"JSON",{stringify:R}),f(S,"Symbol"),f(Math,"Math",!0),f(i.JSON,"JSON",!0)},{"./$":27,"./$.an-object":6,"./$.descriptors":12,"./$.enum-keys":13,"./$.export":14,"./$.fails":15,"./$.get-names":16,"./$.global":17,"./$.has":18,"./$.is-array":21,"./$.keyof":28,"./$.library":29,"./$.property-desc":30,"./$.redefine":31,"./$.set-to-string-tag":32,"./$.shared":33,"./$.to-iobject":34,"./$.uid":35,"./$.wks":36}],41:[function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var s=function(){function e(e,t){for(var n=0;n=3?s=2:-1>=s&&(s=0),a>=3?a=2:-1>=a&&(a=0),[i[s],r[a]]}},{key:"_networkFacebook",value:function(e){return this.config.networks.facebook.loadSdk?window.FB?FB.ui({method:"feed",name:this.config.networks.facebook.title,link:this.config.networks.facebook.url,picture:this.config.networks.facebook.image,caption:this.config.networks.facebook.caption,description:this.config.networks.facebook.description}):(console.error("The Facebook JS SDK hasn't loaded yet."),this._updateHref(e,"https://www.facebook.com/sharer/sharer.php",{u:this.config.networks.facebook.url})):this._updateHref(e,"https://www.facebook.com/sharer/sharer.php",{u:this.config.networks.facebook.url})}},{key:"_networkTwitter",value:function(e){this._updateHref(e,"https://twitter.com/intent/tweet",{text:this.config.networks.twitter.description,url:this.config.networks.twitter.url})}},{key:"_networkGooglePlus",value:function(e){this._updateHref(e,"https://plus.google.com/share",{url:this.config.networks.googlePlus.url})}},{key:"_networkPinterest",value:function(e){this._updateHref(e,"https://www.pinterest.com/pin/create/button",{url:this.config.networks.pinterest.url,media:this.config.networks.pinterest.image,description:this.config.networks.pinterest.description})}},{key:"_networkLinkedin",value:function(e){this._updateHref(e,"https://www.linkedin.com/shareArticle",{mini:"true",url:this.config.networks.linkedin.url,title:this.config.networks.linkedin.title,summary:this.config.networks.linkedin.description})}},{key:"_networkEmail",value:function(e){this._updateHref(e,"mailto:",{subject:this.config.networks.email.title,body:this.config.networks.email.description})}},{key:"_networkReddit",value:function(e){this._updateHref(e,"http://www.reddit.com/submit",{url:this.config.networks.reddit.url,title:this.config.networks.reddit.title})}},{key:"_networkWhatsapp",value:function(e){this._updateHref(e,"whatsapp://send",{text:this.config.networks.whatsapp.description+" "+this.config.networks.whatsapp.url})}},{key:"_injectStylesheet",value:function(e){if(!this.el.head.querySelector("link[href='"+e+"']")){var t=document.createElement("link");t.setAttribute("rel","stylesheet"),t.setAttribute("href",e),this.el.head.appendChild(t)}}},{key:"_injectHtml",value:function(e){var t=this.config.ui.networkOrder,n="",o=!0,i=!1,r=void 0;try{for(var s,a=t[Symbol.iterator]();!(o=(s=a.next()).done);o=!0){var c=s.value;n+="
  • "}}catch(u){i=!0,r=u}finally{try{!o&&a["return"]&&a["return"]()}finally{if(i)throw r}}e.innerHTML=this.config.ui.buttonText+"
      "+n+"
    "}},{key:"_injectFacebookSdk",value:function(){if(!window.FB&&this.config.networks.facebook.appId&&!this.el.body.querySelector("#fb-root")){var e=document.createElement("script");e.text="window.fbAsyncInit=function(){FB.init({appId:'"+this.config.networks.facebook.appId+"',status:true,xfbml:true})};(function(e,t,n){var r,i=e.getElementsByTagName(t)[0];if (e.getElementById(n)){return}r=e.createElement(t);r.id=n;r.src='//connect.facebook.net/en_US/all.js';i.parentNode.insertBefore(r,i)})(document,'script','facebook-jssdk');";var t=document.createElement("div");t.id="fb-root",this.el.body.appendChild(t),this.el.body.appendChild(e)}}},{key:"_hook",value:function(e,t,n){var o=this.config.networks[t][e];if("function"==typeof o){var i=o.call(this.config.networks[t],n);void 0!==i&&(i=this._normalizeFilterConfigUpdates(i),this.extend(this.config.networks[t],i,!0),this._normalizeNetworkConfiguration())}}},{key:"_defaultTitle",value:function(){var e=void 0;return(e=document.querySelector('meta[property="og:title"]')||document.querySelector('meta[name="twitter:title"]'))?e.getAttribute("content"):(e=document.querySelector("title"))?e.textContent||e.innerText:void 0}},{key:"_defaultImage",value:function(){var e=void 0;return(e=document.querySelector('meta[property="og:image"]')||document.querySelector('meta[name="twitter:image"]'))?e.getAttribute("content"):void 0}},{key:"_defaultDescription",value:function(){var e=void 0;return(e=document.querySelector('meta[property="og:description"]')||document.querySelector('meta[name="twitter:description"]')||document.querySelector('meta[name="description"]'))?e.getAttribute("content"):""}},{key:"_detectNetworks",value:function(){var e=!0,t=!1,n=void 0;try{for(var o,i=Object.keys(this.config.networks)[Symbol.iterator]();!(e=(o=i.next()).done);e=!0){var r=o.value,s=!0,a=!1,c=void 0;try{for(var u,l=Object.keys(this.config.networks[r])[Symbol.iterator]();!(s=(u=l.next()).done);s=!0){var f=u.value;null===this.config.networks[r][f]&&(this.config.networks[r][f]=this.config[f])}}catch(d){a=!0,c=d}finally{try{!s&&l["return"]&&l["return"]()}finally{if(a)throw c}}this.config.networks[r].enabled?(this["class"]="enabled",this.config.enabledNetworks+=1):this["class"]="disabled",this.config.networks[r]["class"]=this["class"]}}catch(d){t=!0,n=d}finally{try{!e&&i["return"]&&i["return"]()}finally{if(t)throw n}}}},{key:"_normalizeNetworkConfiguration",value:function(){this.config.networks.facebook.appId||(this.config.networks.facebook.loadSdk=!1),this.config.networks.twitter.description&&(this._isEncoded(this.config.networks.twitter.description)||(this.config.networks.twitter.description=encodeURIComponent(this.config.networks.twitter.description))),"number"==typeof this.config.networks.facebook.appId&&(this.config.networks.facebook.appId=this.config.networks.facebook.appId.toString())}},{key:"_normalizeFilterConfigUpdates",value:function(e){return this.config.networks.facebook.appId!==e.appId&&(console.warn("You are unable to change the Facebook appId after the button has been initialized. Please update your Facebook filters accordingly."),delete e.appId),this.config.networks.facebook.loadSdk!==e.loadSdk&&(console.warn("You are unable to change the Facebook loadSdk option after the button has been initialized. Please update your Facebook filters accordingly."),delete e.appId),e}}]),t}(u["default"]);t.exports=d},{"./share-utils":42,"./string-utils":43,"core-js/fn/array/iterator":1,"core-js/fn/math/trunc":2,"core-js/fn/symbol":3}],42:[function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n=0,i=e.getElementsByTagName("a")[0];if(i.setAttribute("href",this._getUrl(t,!o,n)),!(o||this.config.networks.facebook.loadSdk&&"facebook"===e.getAttribute("class"))){var r={width:500,height:350};r.top=screen.height/2-r.height/2,r.left=screen.width/2-r.width/2,window.open(i.href,"targetWindow","\n toolbar=no,\n location=no,\n status=no,\n menubar=no,\n scrollbars=yes,\n resizable=yes,\n left="+r.left+",\n top="+r.top+",\n width="+r.width+",\n height="+r.height+"\n ")}}},{key:"popup",value:function t(e){var n=this,o=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],t={width:500,height:350};t.top=screen.height/2-t.height/2,t.left=screen.width/2-t.width/2;var i=function(){var e=[],t=!0,i=!1,r=void 0;try{for(var s,a=Object.keys(o)[Symbol.iterator]();!(t=(s=a.next()).done);t=!0){var c=s.value,u=o[c];e.push(c+"="+n._encode(u))}}catch(l){i=!0,r=l}finally{try{!t&&a["return"]&&a["return"]()}finally{if(i)throw r}}return e.join("&")}();i&&(i="?"+i),window.open(e+i,"targetWindow","\n toolbar=no,\n location=no,\n status=no,\n menubar=no,\n scrollbars=yes,\n resizable=yes,\n left="+t.left+",\n top="+t.top+",\n width="+t.width+",\n height="+t.height+"\n ")}},{key:"_merge",value:function(e){function t(t,n){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(function(e,t){"object"!=typeof e&&(e={});for(var n in t)if(t.hasOwnProperty(n)){var o=t[n];if("object"==typeof o){e[n]=this._merge(e[n],o);continue}e[n]=o}for(var i=2,r=arguments.length;r>i;i++)_merge(e,arguments[i]);return e})},{key:"_objToArray",value:function(e){var t=[];for(var n in e)"object"==typeof e[n]&&t.push(e[n]);return t}},{key:"_isMobile",value:function(){return navigator.userAgent.match(/Android|iPhone|PhantomJS/i)&&!navigator.userAgent.match(/iPod|iPad/i)}}]),e}();n["default"]=c,t.exports=n["default"]},{"./string-utils":43}],43:[function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n Date: Mon, 7 Mar 2016 08:43:41 -0300 Subject: [PATCH 053/435] Add meta tag open graph --- delibera_init.php | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/delibera_init.php b/delibera_init.php index 184f5ea..3e73925 100644 --- a/delibera_init.php +++ b/delibera_init.php @@ -488,4 +488,42 @@ function delibera_register_required_plugins() { ); tgmpa( $plugins, $config ); -} \ No newline at end of file +} + +function doctype_opengraph($output) { + return $output . ' + xmlns:og="http://opengraphprotocol.org/schema/" + xmlns:fb="http://www.facebook.com/2008/fbml"'; +} +add_filter('language_attributes', 'doctype_opengraph'); + +function fb_opengraph() { + global $post; + + if(is_single()) { + if(has_post_thumbnail($post->ID)) { + $img_src = wp_get_attachment_image_src(get_post_thumbnail_id( $post->ID ), 'medium'); + } else { + $img_src = get_stylesheet_directory_uri() . '/img/delibera_icon.png'; + } + if($excerpt = $post->post_excerpt) { + $excerpt = strip_tags($post->post_excerpt); + $excerpt = str_replace("", "'", $excerpt); + } else { + $excerpt = get_bloginfo('description'); + } + ?> + + + + + + + + + Date: Mon, 7 Mar 2016 08:56:17 -0300 Subject: [PATCH 054/435] Add button share to pautas --- delibera_init.php | 2 ++ themes/creta/loop-pauta.php | 6 ++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/delibera_init.php b/delibera_init.php index 3e73925..b991667 100644 --- a/delibera_init.php +++ b/delibera_init.php @@ -279,6 +279,8 @@ function delibera_scripts() wp_enqueue_script('delibera', WP_CONTENT_URL.'/plugins/delibera/js/scripts.js', array('jquery-expander')); wp_enqueue_script('delibera-seguir', WP_CONTENT_URL . '/plugins/delibera/js/delibera_seguir.js', array('delibera')); wp_enqueue_script('delibera-concordar', WP_CONTENT_URL . '/plugins/delibera/js/delibera_concordar.js', array('delibera')); + wp_enqueue_script('share-js', WP_CONTENT_URL . '/plugins/delibera/js/share-button.min.js'); + wp_enqueue_style('share-css', WP_CONTENT_URL . '/plugins/delibera/css/share-button.min.css'); $situation = delibera_get_situacao($post->ID); diff --git a/themes/creta/loop-pauta.php b/themes/creta/loop-pauta.php index 52d1e3b..f7b69d9 100644 --- a/themes/creta/loop-pauta.php +++ b/themes/creta/loop-pauta.php @@ -26,10 +26,8 @@

    Discussão criada por em

    -
    - Facebook - Twitter - Google+ +
    +
    Imprimir
    '; - $post = $old; - - return ''; // Retornar código da representação -} -add_shortcode( 'delibera_lista_de_resolucoes', 'delibera_replace_resolucoes' ); - function delibera_replace_agendamentos($matches) { global $wp_filter; diff --git a/delibera_topic.php b/delibera_topic.php index df35e20..540cc02 100644 --- a/delibera_topic.php +++ b/delibera_topic.php @@ -241,16 +241,6 @@ function delibera_des_filtro_qtranslate($where) add_filter('posts_where_request', 'delibera_des_filtro_qtranslate', 11); -/** - * - * Retorna pautas já resolvidas - * @param array $filtro - */ -function delibera_get_resolucoes($filtro = array()) -{ - return delibera_get_pautas_em($filtro, 'comresolucao'); -} - /** * * Save o post da pauta diff --git a/delibera_topic_deadline.php b/delibera_topic_deadline.php index 05b6703..b3d59d8 100644 --- a/delibera_topic_deadline.php +++ b/delibera_topic_deadline.php @@ -47,15 +47,6 @@ function delibera_reabrir_pauta_action() require_once __DIR__.DIRECTORY_SEPARATOR.'delibera_cron.php'; -function delibera_marcar_naovalidada($postID) -{ - wp_set_object_terms($postID, 'naovalidada', 'situacao', false); - if(has_action('delibera_pauta_recusada')) - { - do_action('delibera_pauta_recusada', $postID); - } -} - function delibera_reabrir_pauta($postID) { wp_set_object_terms($postID, 'validacao', 'situacao', false); diff --git a/modules/result/result.php b/modules/result/result.php new file mode 100644 index 0000000..5a2b0b3 --- /dev/null +++ b/modules/result/result.php @@ -0,0 +1,221 @@ + method + */ + protected $shortcodes = array('delibera_lista_de_resolucoes' => 'replaceResolucoes' ); + + /** + * Register Tax for the module + */ + public function registerTax() + { + if(term_exists('comresolucao', 'situacao', null) == false) + { + delibera_insert_term('Resolução', 'situacao', array( + 'description'=> 'Pauta com resoluções aprovadas', + 'slug' => 'comresolucao', + ), + array( + 'qtrans_term_pt' => 'Resolução', + 'qtrans_term_en' => 'Resolution', + 'qtrans_term_es' => 'Resolución', + ) + ); + } + } + + /** + * + * {@inheritDoc} + * @see \Delibera\Modules\ModuleBase::initModule() + */ + public function initModule($post_id) + { + wp_set_object_terms($post_id, 'comresolucao', 'situacao', false); + } + + /** + * Append configurations + * @param array $opts + */ + public function getMainConfig($opts) + { + return $opts; + } + + /** + * Array to show on config page + * @param array $rows + */ + public function configPageRows($rows, $opt) + { + return $rows; + } + + /** + * Label to apply to button + * @param unknown $situation + */ + public function situationButtonText($situation) + { + if($situation == 'comresolucao') + { + return '';//__('', 'delibera'); + } + + return $situation; + } + + /** + * + * {@inheritDoc} + * @see \Delibera\Modules\ModuleBase::generateDeadline() + */ + public function generateDeadline($options_plugin_delibera) + { + //No deadline + return false; + } + + /** + * + * Post Meta Fields display + * + * @param \WP_Post $post + * @param array $custom post custom fields + * @param array $options_plugin_delibera Delibera options array + * @param WP_Term $situacao + * @param bool $disable_edicao + * + */ + public function topicMeta($post, $custom, $options_plugin_delibera, $situacao, $disable_edicao) + { + + } + + /** + * When the topic is published + * @param int $postID + * @param array $opt delibera configs + * @param bool $alterar has been altered + */ + public function publishPauta($postID, $opt, $alterar) + { + + } + + /** + * Validate topic required data + * @param array $erros erros report array + * @param array $opt Delibera configs + * @param bool $autosave is autosave? + * @return array erros report array append if needed + */ + public function checkPostData($erros, $opt, $autosave) + { + + return $erros; + } + + /** + * + * Retorna pautas já resolvidas + * @param array $filtro + */ + public static function getResolucoes($filtro = array()) + { + return self::getPautas($filtro); + } + + /** + * Shortcut for list of Results + * @param array $matches regext results + * @return string + */ + public function replaceResolucoes($matches) + { + $temp = explode(',', $matches[1]); // configurações da shorttag + $count = count($temp); + + $param = array(); // TODO Tratar Parametros + + $html = $this->getResolucoes($param); + $wp_posts = $html; + global $post; + $old = $post; + echo '
    '; + foreach ( $wp_posts as $wp_post ) + { + $post = $wp_post; + include 'delibera_loop_pauta.php'; + } + echo '
    '; + $post = $old; + + return ''; // Retornar código da representação + } + + /** + * Save topic metadata + * @param array $events_meta + * @param array $opt Delibera configs + * + * @return array events_meta to be save on the topic + */ + public function savePostMetas($events_meta, $opt) + { + return $events_meta; + } + + /** + * Treat postback of frotend topic + * @param array $opt Delibera configs + */ + public function createPautaAtFront($opt) + { + + } + + /** + * + * {@inheritDoc} + * @see \Delibera\Modules\ModuleBase::deadline() + */ + public function deadline($args) + { + $situacao = delibera_get_situacao($args['post_id']); + if($situacao->slug == 'validacao') + { + delibera_marcar_naovalidada($post_id); + } + } + +} +$DeliberaResult = new \Delibera\Modules\Result(); + + diff --git a/modules/validation/validation.php b/modules/validation/validation.php index 26436ba..5b03b39 100644 --- a/modules/validation/validation.php +++ b/modules/validation/validation.php @@ -334,7 +334,20 @@ public function deadline($args) $situacao = delibera_get_situacao($args['post_id']); if($situacao->slug == 'validacao') { - delibera_marcar_naovalidada($post_id); + $this->marcarNaovalidada($post_id); + } + } + + /** + * No min validation recived + * @param int $postID + */ + public function marcarNaovalidada($postID) + { + wp_set_object_terms($postID, 'naovalidada', 'situacao', false); + if(has_action('delibera_pauta_recusada')) + { + do_action('delibera_pauta_recusada', $postID); } } From ffa2c3459f8b2e0ad33e150501da709333315431 Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Mon, 7 Mar 2016 16:19:33 -0300 Subject: [PATCH 060/435] remove copied function --- modules/result/result.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/modules/result/result.php b/modules/result/result.php index 5a2b0b3..68af89c 100644 --- a/modules/result/result.php +++ b/modules/result/result.php @@ -208,11 +208,7 @@ public function createPautaAtFront($opt) */ public function deadline($args) { - $situacao = delibera_get_situacao($args['post_id']); - if($situacao->slug == 'validacao') - { - delibera_marcar_naovalidada($post_id); - } + } } From b7017240c6c3f677f163564cc3e35abe4d722172 Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Mon, 7 Mar 2016 21:58:14 -0300 Subject: [PATCH 061/435] recreate cron events ref #69 --- delibera_cron.php | 16 +++++++++-- delibera_flow.php | 21 ++++++++++++++ modules/discussion/discussion.php | 22 +-------------- modules/modulebase.php | 39 ++++++++++++++++++++++++++ modules/rapporteur/rapporteur.php | 46 +------------------------------ modules/validation/validation.php | 22 +-------------- modules/vote/vote.php | 28 +------------------ 7 files changed, 78 insertions(+), 116 deletions(-) diff --git a/delibera_cron.php b/delibera_cron.php index 712c07d..4096e35 100644 --- a/delibera_cron.php +++ b/delibera_cron.php @@ -99,10 +99,16 @@ function delibera_add_cron($data, $call_back, $args) } } -function delibera_del_cron($postID) +function delibera_del_cron($postID, $callback = false) { $crons = get_option('delibera-cron', array()); if(!is_array($crons)) $crons = array(); + + if( is_array($callback) ) + { + $callback = get_class($callback[0]).'_'.$callback[1]; + } + $crons_new = array(); foreach($crons as $cron_data => $cron_value) { @@ -111,7 +117,13 @@ function delibera_del_cron($postID) { if(isset($call['args']['post_ID'])) $call['args']['post_id'] = $call['args']['post_ID']; // precisa ser compatível com cron anteriores - if($call['args']['post_id'] != $postID) + $cron_callback = $call['call_back']; + if( is_array($call['call_back']) ) + { + $cron_callback = get_class($call[0]).'_'.$call['call_back'][1]; + } + + if($call['args']['post_id'] != $postID || ($callback !== false && $callback != $cron_callback )) { $new_cron[] = $call; } diff --git a/delibera_flow.php b/delibera_flow.php index efb4ff3..cd32374 100644 --- a/delibera_flow.php +++ b/delibera_flow.php @@ -159,6 +159,10 @@ public function savePostMetas($events_meta, $opt) $events_meta['delibera_flow'] = explode(',', trim($_POST['delibera_flow'])); } + $post_id = get_the_ID(); + $module = $this->getCurrentModule($post_id); + $module->newDeadline($post_id); + return $events_meta; } @@ -173,6 +177,23 @@ public function publishPauta($postID, $opt, $alterar) self::reabrirPauta($postID, false); } + /** + * Return Current Flow Module + * @param int $post_id + * @return \Delibera\Modules\ModuleBase + */ + public static function getCurrentModule($post_id) + { + global $DeliberaFlow; + + $flow = $DeliberaFlow->get($post_id); + $situacao = delibera_get_situacao($post_id); + $current = array_search($situacao, $flow); + $modules = $DeliberaFlow->getFlowModules(); //TODO cache? + + return $modules[$flow[$current]]; + } + /** * Go to the next module on flow * @param string $post_id diff --git a/modules/discussion/discussion.php b/modules/discussion/discussion.php index a2e7a51..63e7ee6 100644 --- a/modules/discussion/discussion.php +++ b/modules/discussion/discussion.php @@ -58,6 +58,7 @@ public function registerTax() public function initModule($post_id) { wp_set_object_terms($post_id, 'discussao', 'situacao', false); + $this->newDeadline($post_id); } /** @@ -174,27 +175,6 @@ public function publishPauta($postID, $opt, $alterar) } } - $prazo_discussao = get_post_meta($postID, 'prazo_discussao', true); - - if($prazo_discussao !== false) - { - delibera_add_cron( - delibera_tratar_data($prazo_discussao), - array($this, 'deadline'), - array( - 'post_id' => $postID, - 'prazo' => $prazo_discussao - ) - ); - delibera_add_cron( - strtotime("-1 day", delibera_tratar_data($prazo_discussao)), - 'delibera_notificar_fim_prazo', - array( - 'post_id' => $postID, - 'prazo_discussao' => $prazo_discussao - ) - ); - } } function checkPostData($erros, $opt, $autosave) diff --git a/modules/modulebase.php b/modules/modulebase.php index 3b0fec6..690deae 100644 --- a/modules/modulebase.php +++ b/modules/modulebase.php @@ -187,4 +187,43 @@ public static function getPautas($filtro = array()) */ abstract public function deadline($args); + /** + * Create new deadline events calendar + * @param int $post_id + */ + public function newDeadline($post_id) + { + $prazos = $this->prazo_meta; + if(is_string($this->prazo_meta)) + { + $prazos = array($this->prazo_meta); + } + foreach ($prazos as $prazo) + { + $prazo_date = get_post_meta($post_id, $prazo, true); + if( ! empty($prazo_date) ) + { + delibera_del_cron($post_id, array($this, 'deadline')); + delibera_del_cron($post_id, 'delibera_notificar_fim_prazo'); + + delibera_add_cron( + delibera_tratar_data($prazo_date), + array($this, 'deadline'), + array( + 'post_id' => $post_id, + 'prazo' => $prazo_date + ) + ); + delibera_add_cron( + strtotime("-1 day", delibera_tratar_data($prazo_date)), + 'delibera_notificar_fim_prazo', + array( + 'post_id' => $post_id, + 'prazo_validacao' => $prazo_date + ) + ); + } + } + } + } \ No newline at end of file diff --git a/modules/rapporteur/rapporteur.php b/modules/rapporteur/rapporteur.php index 9fcfe4a..c3ebced 100644 --- a/modules/rapporteur/rapporteur.php +++ b/modules/rapporteur/rapporteur.php @@ -80,6 +80,7 @@ public function initModule($post_id) { wp_set_object_terms($post_id, 'relatoria', 'situacao', false); //Mudar situação para Votação } + $this->newDeadline($post_id); } /** @@ -230,51 +231,6 @@ public function publishPauta($postID, $opt, $alterar) } } - - $prazo_eleicao_relator = get_post_meta($postID, 'prazo_eleicao_relator', true); - - if( ! empty($prazo_eleicao_relator) ) - { - delibera_add_cron( - delibera_tratar_data($prazo_eleicao_relator), - array($this, 'deadline'), - array( - 'post_id' => $postID, - 'prazo' => $prazo_eleicao_relator - ) - ); - delibera_add_cron( - strtotime("-1 day", delibera_tratar_data($prazo_eleicao_relator)), - 'delibera_notificar_fim_prazo', - array( - 'post_id' => $postID, - 'prazo_votacao' => $prazo_eleicao_relator - ) - ); - } - - $prazo_relatoria = get_post_meta($postID, 'prazo_relatoria', true); - - if( ! empty($prazo_relatoria) ) - { - delibera_add_cron( - delibera_tratar_data($prazo_relatoria), - array($this, 'deadline'), - array( - 'post_id' => $postID, - 'prazo' => $prazo_relatoria - ) - ); - delibera_add_cron( - strtotime("-1 day", delibera_tratar_data($prazo_relatoria)), - 'delibera_notificar_fim_prazo', - array( - 'post_id' => $postID, - 'prazo_votacao' => $prazo_relatoria - ) - ); - } - } function checkPostData($erros, $opt, $autosave) diff --git a/modules/validation/validation.php b/modules/validation/validation.php index 5b03b39..a4843d5 100644 --- a/modules/validation/validation.php +++ b/modules/validation/validation.php @@ -72,6 +72,7 @@ public function registerTax() public function initModule($post_id) { wp_set_object_terms($post_id, 'validacao', 'situacao', false); + $this->newDeadline($post_id); } /** @@ -205,27 +206,6 @@ public function publishPauta($postID, $opt, $alterar) } } - $prazo_validacao = get_post_meta($postID, 'prazo_validacao', true); - - if( ! empty($prazo_validacao) ) - { - delibera_add_cron( - delibera_tratar_data($prazo_validacao), - array($this, 'deadline'), - array( - 'post_id' => $postID, - 'prazo' => $prazo_validacao - ) - ); - delibera_add_cron( - strtotime("-1 day", delibera_tratar_data($prazo_validacao)), - 'delibera_notificar_fim_prazo', - array( - 'post_id' => $postID, - 'prazo_validacao' => $prazo_validacao - ) - ); - } } /** diff --git a/modules/vote/vote.php b/modules/vote/vote.php index 28ff262..ea23624 100644 --- a/modules/vote/vote.php +++ b/modules/vote/vote.php @@ -170,34 +170,8 @@ public function publishPauta($postID, $opt, $alterar) add_post_meta($postID, $key, $value, true); // Senão, cria } } - /* - * Faz agendamento das datas para seguir passos - * 1) Excluir ao atingir data de validação se não foi validade - * 2) Iniciar votação se tiver encaminhamento, ou novo prazo, caso contrário - * 3) Fim da votação - * - */ - $prazo_votacao = get_post_meta($postID, 'prazo_votacao', true); - if( ! empty($prazo_votacao) ) - { - delibera_add_cron( - delibera_tratar_data($prazo_votacao), - array($this, 'deadline'), - array( - 'post_id' => $postID, - 'prazo' => $prazo_votacao - ) - ); - delibera_add_cron( - strtotime("-1 day", delibera_tratar_data($prazo_votacao)), - 'delibera_notificar_fim_prazo', - array( - 'post_id' => $postID, - 'prazo_votacao' => $prazo_votacao - ) - ); - } + $this->newDeadline($post_id); } From 9433b09cd8cd929e4a149746a3cab72c0c8040be Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Mon, 7 Mar 2016 22:55:51 -0300 Subject: [PATCH 062/435] cron as class --- delibera_cron.php | 238 +++++++++++++++++------------- delibera_topic.php | 1 - modules/modulebase.php | 8 +- modules/validation/validation.php | 6 + 4 files changed, 147 insertions(+), 106 deletions(-) diff --git a/delibera_cron.php b/delibera_cron.php index 4096e35..b4b1270 100644 --- a/delibera_cron.php +++ b/delibera_cron.php @@ -1,143 +1,179 @@ $values) + add_action('admin_action_delibera_cron_action', array($this, 'action')); + add_action('wp', array($this, 'registry') ); + add_action('admin_action_delibera_cron_list', array($this, 'list')); + } + + /** + * Wordpress hook when cron is trigged + */ + function action() + { + ignore_user_abort(true); + define('DOING_DELIBERA_CRON', true); + try { - if($key <= $now) + $crons = get_option('delibera-cron', array()); + $new_crons = array(); + $now = time(); + $exec = 0; + foreach ($crons as $key => $values) { - foreach ($values as $value) + if($key <= $now) { - $exec++; - if(function_exists($value['call_back'])) + foreach ($values as $value) { - call_user_func($value['call_back'], $value['args']); + $exec++; + if(function_exists($value['call_back'])) + { + call_user_func($value['call_back'], $value['args']); + } } } + else + { + $new_crons[$key] = $values; + } } - else - { - $new_crons[$key] = $values; - } + update_option('delibera-cron', $new_crons); } - update_option('delibera-cron', $new_crons); - } - catch (Exception $e) - { - $error = __('Erro no cron Delibera: ','delibera').$e->getMessage()."\n".$e->getCode()."\n".$e->getTraceAsString()."\n".$e->getLine()."\n".$e->getFile(); - wp_mail("jacson@ethymos.com.br", get_bloginfo('name'), $error); + catch (Exception $e) + { + $error = __('Erro no cron Delibera: ','delibera').$e->getMessage()."\n".$e->getCode()."\n".$e->getTraceAsString()."\n".$e->getLine()."\n".$e->getFile(); + wp_mail("jacson@ethymos.com.br", get_bloginfo('name'), $error); + } + //wp_mail("jacson@ethymos.com.br", get_bloginfo('name'),"Foram executadas $exec tarefa(s)"); } - //wp_mail("jacson@ethymos.com.br", get_bloginfo('name'),"Foram executadas $exec tarefa(s)"); -} - -add_action('admin_action_delibera_cron_action', 'delibera_cron_action'); - -function delibera_cron_registry() -{ - if ( !wp_next_scheduled( 'admin_action_delibera_cron_action' ) ) + + /** + * Registry a cron event check hourly + */ + function registry() { - wp_schedule_event(time(), 'hourly', 'admin_action_delibera_cron_action'); + if ( !wp_next_scheduled( 'admin_action_delibera_cron_action' ) ) // if already been scheduled, will return a time + { + wp_schedule_event(time(), 'hourly', 'admin_action_delibera_cron_action'); + } } -} -add_action('wp', 'delibera_cron_registry'); - -function delibera_cron_list() -{ - $crons = get_option('delibera-cron', array()); - foreach ($crons as $key => $values) + + /** + * Simple text list of cron jobs + */ + function cronList() { - echo "\n
    [$key]: ".date("d/m/Y H:i:s", $key); - foreach ($values as $key2 => $value) + $crons = get_option('delibera-cron', array()); + foreach ($crons as $key => $values) { - echo "\n
    \t   [$key2]"; - foreach ($value as $ki => $item) + echo "\n
    [$key]: ".date("d/m/Y H:i:s", $key); + foreach ($values as $key2 => $value) { - echo "\n
    \t\t      [$ki]"; - if(is_array($item)) - { - echo "\n
    \t\t         ".print_r($item, true); - } - else + echo "\n
    \t   [$key2]"; + foreach ($value as $ki => $item) { - echo "\n
    \t\t         $item"; + echo "\n
    \t\t      [$ki]"; + if(is_array($item)) + { + echo "\n
    \t\t         ".print_r($item, true); + } + else + { + echo "\n
    \t\t         $item"; + } } } } } -} - -add_action('admin_action_delibera_cron_list', 'delibera_cron_list'); - -function delibera_add_cron($data, $call_back, $args) -{ - if(is_int($data) && $data > 0) + + /** + * Add cron trigger + * @param int $data date that will occur + * @param function $call_back + * @param array $args + */ + public static function add($data, $call_back, $args) { - $crons = get_option('delibera-cron', array()); - if(!is_array($crons)) $crons = array(); - - if(!array_key_exists($data, $crons)) + if(is_int($data) && $data > 0) { - $crons[$data] = array(); + $crons = get_option('delibera-cron', array()); + if(!is_array($crons)) $crons = array(); + + if(!array_key_exists($data, $crons)) + { + $crons[$data] = array(); + } + $crons[$data][] = array('call_back' => $call_back, "args" => $args); + ksort($crons); + update_option('delibera-cron', $crons); } - $crons[$data][] = array('call_back' => $call_back, "args" => $args); - ksort($crons); - update_option('delibera-cron', $crons); } -} - -function delibera_del_cron($postID, $callback = false) -{ - $crons = get_option('delibera-cron', array()); - if(!is_array($crons)) $crons = array(); - if( is_array($callback) ) + /** + * Remove a cron trigger + * @param int $postID + * @param function $callback function name or array($object, 'functio-name') + */ + static function del($postID, $callback = false) { - $callback = get_class($callback[0]).'_'.$callback[1]; - } + $crons = get_option('delibera-cron', array()); + if(!is_array($crons)) $crons = array(); - $crons_new = array(); - foreach($crons as $cron_data => $cron_value) - { - $new_cron = array(); - foreach ($cron_value as $call) + if( is_array($callback) ) { - if(isset($call['args']['post_ID'])) $call['args']['post_id'] = $call['args']['post_ID']; // precisa ser compatível com cron anteriores - - $cron_callback = $call['call_back']; - if( is_array($call['call_back']) ) + $callback = get_class($callback[0]).'_'.$callback[1]; + } + + $crons_new = array(); + foreach($crons as $cron_data => $cron_value) + { + $new_cron = array(); + foreach ($cron_value as $call) { - $cron_callback = get_class($call[0]).'_'.$call['call_back'][1]; + if(isset($call['args']['post_ID'])) $call['args']['post_id'] = $call['args']['post_ID']; // precisa ser compatível com cron anteriores + + $cron_callback = $call['call_back']; + if( is_array($call['call_back']) ) + { + $cron_callback = get_class($call[0]).'_'.$call['call_back'][1]; + } + + if($call['args']['post_id'] != $postID || ($callback !== false && $callback != $cron_callback )) + { + $new_cron[] = $call; + } } - - if($call['args']['post_id'] != $postID || ($callback !== false && $callback != $cron_callback )) + if(count($new_cron) > 0) { - $new_cron[] = $call; + $crons_new[$cron_data] = $new_cron; } } - if(count($new_cron) > 0) - { - $crons_new[$cron_data] = $new_cron; - } + + ksort($crons_new); + update_option('delibera-cron', $crons_new); } - ksort($crons_new); - update_option('delibera-cron', $crons_new); } -add_action('delibera_pauta_recusada', 'delibera_del_cron'); +$DeliberaCron = new \Delibera\Cron(); + +// Force cron exec +/*if(array_key_exists("delibera_cron_action", $_REQUEST) && !defined('DOING_DELIBERA_CRON')) + { + ignore_user_abort(true); + define('DOING_DELIBERA_CRON', true); + delibera_cron_action(); + }*/ ?> \ No newline at end of file diff --git a/delibera_topic.php b/delibera_topic.php index 540cc02..e49e3da 100644 --- a/delibera_topic.php +++ b/delibera_topic.php @@ -322,7 +322,6 @@ function delibera_save_post($post_id, $post) if($post->post_status == 'publish' && !$autosave) { - delibera_del_cron($post->ID); delibera_publish_pauta($post->ID, $post, true); } } diff --git a/modules/modulebase.php b/modules/modulebase.php index 690deae..574e06e 100644 --- a/modules/modulebase.php +++ b/modules/modulebase.php @@ -203,10 +203,10 @@ public function newDeadline($post_id) $prazo_date = get_post_meta($post_id, $prazo, true); if( ! empty($prazo_date) ) { - delibera_del_cron($post_id, array($this, 'deadline')); - delibera_del_cron($post_id, 'delibera_notificar_fim_prazo'); + \Delibera\Cron\del($post_id, array($this, 'deadline')); + \Delibera\Cron\del($post_id, 'delibera_notificar_fim_prazo'); - delibera_add_cron( + \Delibera\Cron\add( delibera_tratar_data($prazo_date), array($this, 'deadline'), array( @@ -214,7 +214,7 @@ public function newDeadline($post_id) 'prazo' => $prazo_date ) ); - delibera_add_cron( + \Delibera\Cron\add( strtotime("-1 day", delibera_tratar_data($prazo_date)), 'delibera_notificar_fim_prazo', array( diff --git a/modules/validation/validation.php b/modules/validation/validation.php index a4843d5..997f809 100644 --- a/modules/validation/validation.php +++ b/modules/validation/validation.php @@ -29,6 +29,12 @@ class Validation extends \Delibera\Modules\ModuleBase */ protected $shortcodes = array('delibera_lista_de_propostas' => 'replacePropostas' ); + public function __construct() + { + add_action('delibera_pauta_recusada', array('\Delibera\Cron', 'del')); + parent::__construct(); + } + /** * Register Tax for the module */ From 990970ac3105968803593eae56745ae8d1d5483c Mon Sep 17 00:00:00 2001 From: Maurilio Atila Date: Wed, 9 Mar 2016 07:56:30 -0300 Subject: [PATCH 063/435] oop on delibera_list_users.php --- delibera_list_users.php | 219 +++++++++++++++++++++++++++------------ delibera_member_path.php | 8 +- delibera_user_page.php | 8 +- 3 files changed, 161 insertions(+), 74 deletions(-) diff --git a/delibera_list_users.php b/delibera_list_users.php index c38abb5..b3a0424 100644 --- a/delibera_list_users.php +++ b/delibera_list_users.php @@ -1,75 +1,164 @@ $number_users_per_page , - 'offset' => get_query_var( 'paged' ), - 'fields' => array( 'display_name', 'user_login' , 'ID' ), - 'search' => $search, - 'search_columns' => array( 'display_name', 'user_login', 'user_email' ) - ) - ); - echo '
    '; - echo paginate_links( array( - 'base' => add_query_arg( 'paged', '%#%' ), - 'format' => '', - 'prev_text' => __('«'), - 'next_text' => __('»'), - 'show_all' => true , - 'total' => $blogusers->get_total()/$number_users_per_page, - 'current' => get_query_var( 'paged' ) - )); - //wp_reset_post_data(); - echo '
    '; - -?> - - -
    -results as $user ) - { - echo get_avatar( $user->email ); - echo '

    ' . esc_html( $user->display_name ) . '

    '; - echo '
    '; - $args = array( - 'author' => $user->ID, - 'post_type' => 'pauta', - 'orderby' => 'post_date', - 'posts_per_page' => 1 , - 'order' => 'ASC' - ); + //$this->html(); + } + function get_paginator($total, $page) + { + return paginate_links( array( + 'base' => add_query_arg( 'paged', '%#%' ), + 'format' => '', + 'prev_text' => __('«'), + 'next_text' => __('»'), + 'show_all' => true , + 'total' => $total, + 'current' => $page + )); + } - $current_user_posts = get_posts( $args ); - $last_content = $current_user_posts[0]; -?> -
    -

    post_title; ?>

    -

    post_content;?>

    -
    - 'post_count' , 'order' => 'DESC' ); + case "newest": + return array( 'orderby' => 'registered' , 'order' => 'DESC' ); + default: + return array( 'orderby' => 'display_name' , 'order' => 'ASC' ); } } - else + + function member_page( $per_page , $search , $order ) { - echo __('Nenhum usuário encontrado!' , 'delibera'); + $order_by = $this->get_order_by($order); + $blogusers = new WP_User_Query( array( + 'number' => $per_page , + 'offset' => get_query_var( 'paged' ), + 'fields' => array( 'display_name', 'user_login' , 'ID' ), + 'search' => $search . '*', + 'search_columns' => array( 'ID' , 'user_nicename' , 'user_login' , 'user_email' ), + 'orderby' => $order_by['orderby'], + 'order' => $order_by['order'], + ) + ); + ?> + + + +
    + + + + + +
    +

    + get_paginator( + $this->get_number_of_pages( $blogusers->get_total() , $per_page ), + get_query_var( 'paged' ) + ); + ?> +

    +
    + +
    + results as $user ) + { + echo '

    ' + . '

    ' . get_avatar( $user->ID ) . '

    ' + . '

    ' . esc_html( $user->display_name ) . ' - ' . get_usernumposts($user->ID) . ' posts

    '; + $args = array( + 'author' => $user->ID, + 'post_type' => 'pauta', + 'orderby' => 'post_date', + 'posts_per_page' => 1 , + 'order' => 'ASC' + ); + + $current_user_posts = get_posts( $args ); + $last_content = $current_user_posts[0]; + ?> +
    +

    post_title; ?>

    +

    post_content;?>

    +
    + +
    +

    + get_paginator( + $this->get_number_of_pages( $blogusers->get_total() , $per_page ), + get_query_var( 'paged' ) + ); + ?> +

    +
    + member_page($per_page , $search , $order); + wp_footer(); + ?> + + + '; - wp_footer(); -?> - - + public function html(){ + get_the_content(); + $per_page = isset( $_GET['per-page'] ) ? esc_html( $_GET['per-page'] ) : '20' ; + $search = isset( $_GET['search'] ) ? esc_html( $_GET['search'] ) : '' ; + $order = isset( $_GET['order-by'] ) ? esc_html( $_GET['order-by'] ) : '' ; + $this->member_page($per_page , $search , $order); + } +} +global $delibera_user_list; +$delibera_user_list = new Delibera_User_List(); diff --git a/delibera_member_path.php b/delibera_member_path.php index 1161b30..1df728d 100644 --- a/delibera_member_path.php +++ b/delibera_member_path.php @@ -11,13 +11,13 @@ function userpage_rewrite_add_var( $vars ) { function userpage_rewrite_rule() { add_rewrite_tag( '%member%', '([^&]+)' ); add_rewrite_rule( - '^member/([^/]*)/?', + '^delibera/membro/([^/]*)/?', 'index.php?member=$matches[1]', 'top' ); - add_rewrite_tag( '%members%', '([^&]+)' ); + add_rewrite_tag( '%members%', '' ); add_rewrite_rule( - '^members', + '^delibera/membros', 'index.php?members', 'top' ); @@ -32,8 +32,8 @@ function userpage_rewrite_catch() { exit; } if ( array_key_exists( 'members', $wp_query->query_vars ) ) { - echo "hello word!"; include ( ABSPATH . 'wp-content/plugins/delibera/delibera_list_users.php'); + $delibera_user_list->page(); exit; } } diff --git a/delibera_user_page.php b/delibera_user_page.php index aa5f388..7019ae5 100644 --- a/delibera_user_page.php +++ b/delibera_user_page.php @@ -3,11 +3,11 @@ get_header(); get_the_content(); - $user = $_GET['member']; + $user = $wp_query->query_vars['member']; $user = get_user_by( 'login' , $user ); ?>

    - email ); ?> + ID ); ?>
    first_name . ' produziu de pautas e comentários no Delibera'; ?> @@ -31,11 +31,9 @@ foreach( $author_posts->posts as $post ) { - echo ''; } echo '
    '; echo paginate_links( array( From aed55b235d98fb48385824295313e340edf0e2e1 Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Wed, 9 Mar 2016 22:53:19 -0300 Subject: [PATCH 064/435] fix vote init deadline --- modules/vote/vote.php | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/modules/vote/vote.php b/modules/vote/vote.php index ea23624..436e0e6 100644 --- a/modules/vote/vote.php +++ b/modules/vote/vote.php @@ -52,6 +52,7 @@ public function registerTax() public function initModule($post_id) { wp_set_object_terms($post_id, 'emvotacao', 'situacao', false); + $this->newDeadline($post_id); } /** @@ -140,22 +141,6 @@ public function topicMeta($post, $custom, $options_plugin_delibera, $situacao, $ public function publishPauta($postID, $opt, $alterar) { - if(!array_key_exists('relatoria', $opt) || $opt['relatoria'] == 'S' && $opt['delibera_flow'][0] == 'relatoria' ) - { - if(!$alterar) - { - if($opt['eleicao_relator'] == 'S') - { - wp_set_object_terms($postID, 'eleicaoredator', 'situacao', false); - } - else - { - wp_set_object_terms($postID, 'relatoria', 'situacao', false); - } - } - - } - $events_meta = array(); $events_meta['delibera_numero_comments_votos'] = 0; @@ -171,8 +156,6 @@ public function publishPauta($postID, $opt, $alterar) } } - $this->newDeadline($post_id); - } function checkPostData($erros, $opt, $autosave) From 871fc1af6ec20582bd83625e4f538553bd384c5a Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Wed, 9 Mar 2016 22:53:48 -0300 Subject: [PATCH 065/435] malformed static function call --- modules/modulebase.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/modulebase.php b/modules/modulebase.php index 574e06e..1be432d 100644 --- a/modules/modulebase.php +++ b/modules/modulebase.php @@ -203,10 +203,10 @@ public function newDeadline($post_id) $prazo_date = get_post_meta($post_id, $prazo, true); if( ! empty($prazo_date) ) { - \Delibera\Cron\del($post_id, array($this, 'deadline')); - \Delibera\Cron\del($post_id, 'delibera_notificar_fim_prazo'); + \Delibera\Cron::del($post_id, array($this, 'deadline')); + \Delibera\Cron::del($post_id, 'delibera_notificar_fim_prazo'); - \Delibera\Cron\add( + \Delibera\Cron::add( delibera_tratar_data($prazo_date), array($this, 'deadline'), array( @@ -214,7 +214,7 @@ public function newDeadline($post_id) 'prazo' => $prazo_date ) ); - \Delibera\Cron\add( + \Delibera\Cron::add( strtotime("-1 day", delibera_tratar_data($prazo_date)), 'delibera_notificar_fim_prazo', array( From a9c8306ea2ec70b58f24d4e8bb2049557fae89da Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Wed, 9 Mar 2016 22:56:58 -0300 Subject: [PATCH 066/435] get deadline to flow control, and use timezone based DateTime object --- delibera_admin_functions.php | 2 +- delibera_conf_roles.php | 2 +- delibera_flow.php | 31 +++++++++++++++++++++++++ delibera_topic_deadline.php | 6 ++--- themes/atenas/delibera-loop-archive.php | 4 ++-- themes/atenas/loop-pauta.php | 4 ++-- themes/creta/delibera-loop-archive.php | 4 ++-- themes/creta/loop-pauta.php | 4 ++-- widgets/WidgetListaPropostas/view.php | 4 ++-- 9 files changed, 46 insertions(+), 15 deletions(-) diff --git a/delibera_admin_functions.php b/delibera_admin_functions.php index 8d799ee..78f4251 100644 --- a/delibera_admin_functions.php +++ b/delibera_admin_functions.php @@ -188,7 +188,7 @@ function delibera_post_custom_column($column) break; case 'prazo': $data = ""; - $prazo = delibera_get_prazo($post->ID, $data); + $prazo = \Delibera\Flow::getDeadlineDays($post->ID, $data); if($prazo == -1) { echo __('Encerrado', 'delibera'); diff --git a/delibera_conf_roles.php b/delibera_conf_roles.php index 262ca1d..98d6a87 100644 --- a/delibera_conf_roles.php +++ b/delibera_conf_roles.php @@ -97,7 +97,7 @@ function delibera_current_user_can_participate($permissao = 'votar') { $options = delibera_get_config(); - if (is_singular('pauta') && delibera_get_prazo($post->ID) == -1) { + if (is_singular('pauta') && \Delibera\Flow::getDeadlineDays($post->ID) == -1) { return false; } else if (is_multisite() && $options['todos_usuarios_logados_podem_participar'] == 'S') { return is_user_logged_in(); diff --git a/delibera_flow.php b/delibera_flow.php index cd32374..6e1bfc9 100644 --- a/delibera_flow.php +++ b/delibera_flow.php @@ -264,6 +264,37 @@ public function filterFlowList($flow) } } + /** + * Return module deadline days for the current post (until 1 minute, we return 1) + * @param int $post_id + * @return mixed|string deadline date + */ + public static function getDeadlineDays($post_id = false) + { + $module = \Delibera\Flow::getCurrentModule($post_id); + + $deadline = $module->getDeadline($post_id); + + $dateTimeNow = new \DateTime(); + $deadlineDate = \DateTime::createFromFormat('d/m/Y', $deadline); + + $diff = $dateTimeNow->diff($deadlineDate); + + if($diff->d > 0) + { + return $diff->d; + } + if($diff->d < 1 && ($diff->i || $diff->h || $diff->s)) + { + return 1; + } + else + { + return -1; + } + + } + } global $DeliberaFlow; diff --git a/delibera_topic_deadline.php b/delibera_topic_deadline.php index b3d59d8..170f716 100644 --- a/delibera_topic_deadline.php +++ b/delibera_topic_deadline.php @@ -148,8 +148,8 @@ function delibera_set_novo_prazo_discussao_relatoria($postID, $inova_data, $opts * @param int $postID * @param string $data * @return int - */ -function delibera_get_prazo($postID, &$data = null) + * +function \Delibera\Flow::getDeadlineDays($postID, &$data = null) { $situacao = delibera_get_situacao($postID); $prazo = ""; @@ -193,4 +193,4 @@ function delibera_get_prazo($postID, &$data = null) if(!is_null($data)) $data = $prazo; return $dias; -} \ No newline at end of file +}*/ \ No newline at end of file diff --git a/themes/atenas/delibera-loop-archive.php b/themes/atenas/delibera-loop-archive.php index 0666c0d..4b0b139 100644 --- a/themes/atenas/delibera-loop-archive.php +++ b/themes/atenas/delibera-loop-archive.php @@ -35,10 +35,10 @@ ID ) == -1 ) + if ( \Delibera\Flow::getDeadlineDays( $post->ID ) == -1 ) _e( 'Prazo encerrado', 'delibera' ); else - printf( _n( 'Encerra em um dia', 'Encerra em %1$s dias', delibera_get_prazo( $post->ID ), 'delibera' ), number_format_i18n( delibera_get_prazo( $post->ID ) ) ); + printf( _n( 'Encerra em um dia', 'Encerra em %1$s dias', \Delibera\Flow::getDeadlineDays( $post->ID ), 'delibera' ), number_format_i18n( \Delibera\Flow::getDeadlineDays( $post->ID ) ) ); ?> diff --git a/themes/atenas/loop-pauta.php b/themes/atenas/loop-pauta.php index c79ae0f..d5ffb30 100644 --- a/themes/atenas/loop-pauta.php +++ b/themes/atenas/loop-pauta.php @@ -45,10 +45,10 @@
    ID ) == -1 ) + if ( \Delibera\Flow::getDeadlineDays( $post->ID ) == -1 ) _e( 'Prazo encerrado', 'delibera' ); else - printf( _n( 'Encerra em um dia', 'Encerra em %1$s dias', delibera_get_prazo( $post->ID ), 'delibera' ), number_format_i18n( delibera_get_prazo( $post->ID ) ) ); + printf( _n( 'Encerra em um dia', 'Encerra em %1$s dias', \Delibera\Flow::getDeadlineDays( $post->ID ), 'delibera' ), number_format_i18n( \Delibera\Flow::getDeadlineDays( $post->ID ) ) ); ?>
    diff --git a/themes/creta/delibera-loop-archive.php b/themes/creta/delibera-loop-archive.php index 5195085..787a62c 100644 --- a/themes/creta/delibera-loop-archive.php +++ b/themes/creta/delibera-loop-archive.php @@ -11,10 +11,10 @@
    name; ?>
    - ID) == -1) { + ID) == -1) { echo 'Prazo encerrado'; } else { - printf(_n('Encerra em um dia', 'Encerra em %1$s dias', delibera_get_prazo($post->ID), 'delibera'), number_format_i18n(delibera_get_prazo($post->ID))); + printf(_n('Encerra em um dia', 'Encerra em %1$s dias', \Delibera\Flow::getDeadlineDays($post->ID), 'delibera'), number_format_i18n(\Delibera\Flow::getDeadlineDays($post->ID))); } ?>
    diff --git a/themes/creta/loop-pauta.php b/themes/creta/loop-pauta.php index 52d1e3b..9a1c385 100644 --- a/themes/creta/loop-pauta.php +++ b/themes/creta/loop-pauta.php @@ -16,10 +16,10 @@
    ID)->name; ?> - ID) == -1) { + ID) == -1) { echo 'Prazo encerrado'; } else { - printf(_n('Encerra em um dia', 'Encerra em %1$s dias', delibera_get_prazo($post->ID), 'delibera'), number_format_i18n(delibera_get_prazo($post->ID))); + printf(_n('Encerra em um dia', 'Encerra em %1$s dias', \Delibera\Flow::getDeadlineDays($post->ID), 'delibera'), number_format_i18n(\Delibera\Flow::getDeadlineDays($post->ID))); } ?>
    diff --git a/widgets/WidgetListaPropostas/view.php b/widgets/WidgetListaPropostas/view.php index 811f504..43e1688 100644 --- a/widgets/WidgetListaPropostas/view.php +++ b/widgets/WidgetListaPropostas/view.php @@ -36,10 +36,10 @@ ?> ID ) == -1 ) + if ( \Delibera\Flow::getDeadlineDays( $post->ID ) == -1 ) _e( 'Prazo encerrado', 'delibera' ); else - printf( _n( 'Encerra em um dia', 'Encerra em %1$s dias', delibera_get_prazo( $post->ID ), 'delibera' ), number_format_i18n( delibera_get_prazo( $post->ID ) ) ); + printf( _n( 'Encerra em um dia', 'Encerra em %1$s dias', \Delibera\Flow::getDeadlineDays( $post->ID ), 'delibera' ), number_format_i18n( \Delibera\Flow::getDeadlineDays( $post->ID ) ) ); ?> Date: Thu, 10 Mar 2016 01:20:14 -0300 Subject: [PATCH 067/435] simple list cron for debug, delete cron when pauta is deleted or trashed and minor fix on var name --- delibera_cron.php | 80 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 55 insertions(+), 25 deletions(-) diff --git a/delibera_cron.php b/delibera_cron.php index b4b1270..e08225e 100644 --- a/delibera_cron.php +++ b/delibera_cron.php @@ -15,12 +15,15 @@ public function __construct() add_action('admin_action_delibera_cron_action', array($this, 'action')); add_action('wp', array($this, 'registry') ); add_action('admin_action_delibera_cron_list', array($this, 'list')); + add_action('delibera_menu_itens', array($this, 'addMenu')); + add_action('wp_trash_post', array($this, 'del') ); + add_action('before_delete_post', array($this, 'del') ); } /** * Wordpress hook when cron is trigged */ - function action() + public function action() { ignore_user_abort(true); define('DOING_DELIBERA_CRON', true); @@ -37,9 +40,19 @@ function action() foreach ($values as $value) { $exec++; - if(function_exists($value['call_back'])) + if(is_array($value['call_back'])) { - call_user_func($value['call_back'], $value['args']); + if(method_exists($value['call_back'][0], $value['call_back'][1])) + { + call_user_func($value['call_back'], $value['args']); + } + } + else + { + if(function_exists($value['call_back'])) + { + call_user_func($value['call_back'], $value['args']); + } } } } @@ -54,6 +67,7 @@ function action() { $error = __('Erro no cron Delibera: ','delibera').$e->getMessage()."\n".$e->getCode()."\n".$e->getTraceAsString()."\n".$e->getLine()."\n".$e->getFile(); wp_mail("jacson@ethymos.com.br", get_bloginfo('name'), $error); + file_put_contents('/tmp/delibera_cron.log', $error, FILE_APPEND); } //wp_mail("jacson@ethymos.com.br", get_bloginfo('name'),"Foram executadas $exec tarefa(s)"); } @@ -74,27 +88,33 @@ function registry() */ function cronList() { - $crons = get_option('delibera-cron', array()); - foreach ($crons as $key => $values) - { - echo "\n
    [$key]: ".date("d/m/Y H:i:s", $key); - foreach ($values as $key2 => $value) + ?> +
    + +
     $values)
     			{
    -				echo "\n
    \t   [$key2]"; - foreach ($value as $ki => $item) + echo "\n
    [$key]: ".date("d/m/Y H:i:s", $key); + foreach ($values as $key2 => $value) { - echo "\n
    \t\t      [$ki]"; - if(is_array($item)) + echo "\n
    \t   [$key2]"; + foreach ($value as $ki => $item) { - echo "\n
    \t\t         ".print_r($item, true); - } - else - { - echo "\n
    \t\t         $item"; + echo "\n
    \t\t      [$ki]"; + if(is_array($item)) + { + echo "\n
    \t\t         ".print_r($item, true); + } + else + { + echo "\n
    \t\t         $item"; + } } } - } - } + }?> +
    +
    cronList(); + } + } $DeliberaCron = new \Delibera\Cron(); @@ -175,5 +205,5 @@ static function del($postID, $callback = false) define('DOING_DELIBERA_CRON', true); delibera_cron_action(); }*/ - +//update_option('delibera-cron', array()); //delete cron ?> \ No newline at end of file From 6584d359ce1835d881fac60fce9e164aff8f23b5 Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Thu, 10 Mar 2016 01:22:14 -0300 Subject: [PATCH 068/435] fix datetime timezone errors, get correct situation prop, refactory of publish pauta --- delibera_flow.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/delibera_flow.php b/delibera_flow.php index 6e1bfc9..6990cb3 100644 --- a/delibera_flow.php +++ b/delibera_flow.php @@ -18,9 +18,10 @@ public function __construct() add_filter('delivera_config_page_rows', array($this, 'configPageRows'), 10, 2); add_filter('delibera-pre-main-config-save', array($this, 'preMainConfigSave')); add_action('delibera_topic_meta', array($this, 'topicMeta'), 10, 5); - add_filter('delibera_save_post_metas', array($this, 'savePostMetas'), 10, 2); - add_action('delibera_publish_pauta', array($this, 'publishPauta'), 10, 3); + add_filter('delibera_save_post_metas', array($this, 'savePostMetas'), 1000, 2); + add_action('delibera_publish_pauta', array($this, 'publishPauta'), 10, 2); add_filter('delibera_flow_list', array($this, 'filterFlowList')); + add_action('delibera_save_post', array($this, 'savePost'), 1000, 3); } /** @@ -159,11 +160,13 @@ public function savePostMetas($events_meta, $opt) $events_meta['delibera_flow'] = explode(',', trim($_POST['delibera_flow'])); } - $post_id = get_the_ID(); + return $events_meta; + } + + public function savePost($post_id, $post, $opt) + { $module = $this->getCurrentModule($post_id); $module->newDeadline($post_id); - - return $events_meta; } /** @@ -172,7 +175,7 @@ public function savePostMetas($events_meta, $opt) * @param array $opt delibera configs * @param bool $alterar has been altered */ - public function publishPauta($postID, $opt, $alterar) + public function publishPauta($postID, $opt) { self::reabrirPauta($postID, false); } @@ -188,7 +191,7 @@ public static function getCurrentModule($post_id) $flow = $DeliberaFlow->get($post_id); $situacao = delibera_get_situacao($post_id); - $current = array_search($situacao, $flow); + $current = array_search($situacao->slug, $flow); $modules = $DeliberaFlow->getFlowModules(); //TODO cache? return $modules[$flow[$current]]; @@ -276,13 +279,13 @@ public static function getDeadlineDays($post_id = false) $deadline = $module->getDeadline($post_id); $dateTimeNow = new \DateTime(); - $deadlineDate = \DateTime::createFromFormat('d/m/Y', $deadline); + $deadlineDate = \DateTime::createFromFormat('d/m/Y H:i:s', $deadline." 23:59:59"); $diff = $dateTimeNow->diff($deadlineDate); if($diff->d > 0) { - return $diff->d; + return $diff->format('%a'); } if($diff->d < 1 && ($diff->i || $diff->h || $diff->s)) { From ff0a48266a717c9f2891e0dd97bda1300fd79189 Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Thu, 10 Mar 2016 01:23:53 -0300 Subject: [PATCH 069/435] fix duplicated publish --- delibera_topic.php | 71 +++++++++++++--------------------------------- 1 file changed, 19 insertions(+), 52 deletions(-) diff --git a/delibera_topic.php b/delibera_topic.php index e49e3da..27db490 100644 --- a/delibera_topic.php +++ b/delibera_topic.php @@ -106,62 +106,33 @@ function delibera_pauta_meta() } -function delibera_publish_pauta($postID, $post, $alterar = false) +function delibera_publish_pauta($post) { + $postID = $post->ID; if(get_post_type( $postID ) != "pauta") { return $postID; } - - if ( - $alterar || ( - ($post->post_status == 'publish' || $_POST['publish'] == 'Publicar') && - ( - ( - array_key_exists('prev_status', $_POST) && - ( - $_POST['prev_status'] == 'draft' || - $_POST['prev_status'] == 'pending' - ) - ) || - ( - array_key_exists('original_post_status', $_POST) && ( - $_POST['original_post_status'] == 'draft' || - $_POST['original_post_status'] == 'auto-draft' || - $_POST['original_post_status'] == 'pending') - ) - ) - ) - ) + + $opt = delibera_get_config(); + + do_action('delibera_publish_pauta', $postID, $opt); + + $curtir = get_post_meta($postID, 'delibera_numero_curtir', true); + if($curtir == "" || $curtir === false || is_null($curtir)) { - $opt = delibera_get_config(); - - do_action('delibera_publish_pauta', $postID, $opt, $alterar); - - $curtir = get_post_meta($postID, 'delibera_numero_curtir', true); - if($curtir == "" || $curtir === false || is_null($curtir)) - { - $events_meta['delibera_numero_comments_padroes'] = 0; - $events_meta['delibera_numero_curtir'] = 0; - $events_meta['delibera_curtiram'] = array(); - $events_meta['delibera_numero_discordar'] = 0; - $events_meta['delibera_discordaram'] = array(); - $events_meta['delibera_numero_seguir'] = 0; - $events_meta['delibera_seguiram'] = array(); - } - - if($alterar) - { - //delibera_notificar_situacao($post); - } - else - { - delibera_notificar_nova_pauta($post); - } + $events_meta['delibera_numero_comments_padroes'] = 0; + $events_meta['delibera_numero_curtir'] = 0; + $events_meta['delibera_curtiram'] = array(); + $events_meta['delibera_numero_discordar'] = 0; + $events_meta['delibera_discordaram'] = array(); + $events_meta['delibera_numero_seguir'] = 0; + $events_meta['delibera_seguiram'] = array(); } -} -add_action ('publish_pauta', 'delibera_publish_pauta', 1, 2); + delibera_notificar_nova_pauta($postID); +} +add_action ('draft_to_publish', 'delibera_publish_pauta', 1, 1); /** * @@ -320,10 +291,6 @@ function delibera_save_post($post_id, $post) \Delibera\Flow::forcarFimPrazo($post->ID); } - if($post->post_status == 'publish' && !$autosave) - { - delibera_publish_pauta($post->ID, $post, true); - } } add_action ('save_post', 'delibera_save_post', 1, 2); From 2b915673ee7f8a0b66cd1a50d2b1be92d002703a Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Thu, 10 Mar 2016 01:24:54 -0300 Subject: [PATCH 070/435] parser date with corrent timezone --- delibera_utils.php | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/delibera_utils.php b/delibera_utils.php index ec9dae4..e5b3ca9 100644 --- a/delibera_utils.php +++ b/delibera_utils.php @@ -1,12 +1,25 @@ format( ($int ? 'U' : 'Y-m-d H:i:s')); } /** From f5176ba5e65393910bd382bd6c38eb34ee69694b Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Thu, 10 Mar 2016 01:25:57 -0300 Subject: [PATCH 071/435] fix function compatibility and lot of modules fixes --- modules/discussion/discussion.php | 10 +---- modules/modulebase.php | 67 +++++++++++++++++-------------- modules/rapporteur/rapporteur.php | 16 +------- modules/result/result.php | 2 +- modules/validation/validation.php | 2 +- modules/vote/vote.php | 2 +- 6 files changed, 42 insertions(+), 57 deletions(-) diff --git a/modules/discussion/discussion.php b/modules/discussion/discussion.php index 63e7ee6..3fdcd74 100644 --- a/modules/discussion/discussion.php +++ b/modules/discussion/discussion.php @@ -149,16 +149,8 @@ public function topicMeta($post, $custom, $options_plugin_delibera, $situacao, $ } - public function publishPauta($postID, $opt, $alterar) + public function publishPauta($postID, $opt) { - if(/*!array_key_exists('discussao', $opt) || $opt['discussao'] == 'S' && TODO check activation */ $opt['delibera_flow'][0] == 'discussao' ) - { - if(!$alterar) - { - wp_set_object_terms($postID, 'discussao', 'situacao', false); - } - - } $events_meta = array(); $events_meta['delibera_numero_comments_encaminhamentos'] = 0; $events_meta['delibera_numero_comments_discussoes'] = 0; diff --git a/modules/modulebase.php b/modules/modulebase.php index 1be432d..ca28629 100644 --- a/modules/modulebase.php +++ b/modules/modulebase.php @@ -39,7 +39,7 @@ public function __construct() add_filter('delivera_config_page_rows', array($this, 'configPageRows'), 10, 2); add_filter('delibera_situation_button_text', array($this, 'situationButtonText')); add_action('delibera_topic_meta', array($this, 'topicMeta'), 10, 5); - add_action('delibera_publish_pauta', array($this, 'publishPauta'), 10, 3); + add_action('delibera_publish_pauta', array($this, 'publishPauta'), 10, 2); add_filter('delibera_check_post_data', array($this, 'checkPostData'), 10, 3); add_filter('delibera_save_post_metas', array($this, 'savePostMetas'), 10, 2); add_action('delibera_create_pauta_frontend', array($this, 'createPautaAtFront')); @@ -109,9 +109,8 @@ abstract public function topicMeta($post, $custom, $options_plugin_delibera, $si * When the topic is published * @param int $postID * @param array $opt delibera configs - * @param bool $alterar has been altered */ - abstract public function publishPauta($postID, $opt, $alterar); + abstract public function publishPauta($postID, $opt); /** * Validate topic required data @@ -193,35 +192,43 @@ abstract public function deadline($args); */ public function newDeadline($post_id) { - $prazos = $this->prazo_meta; - if(is_string($this->prazo_meta)) + if(get_post_status($post_id) == 'publish') { - $prazos = array($this->prazo_meta); - } - foreach ($prazos as $prazo) - { - $prazo_date = get_post_meta($post_id, $prazo, true); - if( ! empty($prazo_date) ) + $prazos = $this->prazo_meta; + if(is_string($this->prazo_meta)) + { + $prazos = array($this->prazo_meta); + } + foreach ($prazos as $prazo) { - \Delibera\Cron::del($post_id, array($this, 'deadline')); - \Delibera\Cron::del($post_id, 'delibera_notificar_fim_prazo'); - - \Delibera\Cron::add( - delibera_tratar_data($prazo_date), - array($this, 'deadline'), - array( - 'post_id' => $post_id, - 'prazo' => $prazo_date - ) - ); - \Delibera\Cron::add( - strtotime("-1 day", delibera_tratar_data($prazo_date)), - 'delibera_notificar_fim_prazo', - array( - 'post_id' => $post_id, - 'prazo_validacao' => $prazo_date - ) - ); + $prazo_date = get_post_meta($post_id, $prazo, true); + if( ! empty($prazo_date) ) + { + \Delibera\Cron::del($post_id, array($this, 'deadline')); + \Delibera\Cron::del($post_id, 'delibera_notificar_fim_prazo'); + + \Delibera\Cron::add( + delibera_tratar_data($prazo_date), + array($this, 'deadline'), + array( + 'post_ID' => $post_id, + 'prazo' => $prazo_date + ) + ); + \Delibera\Cron::add( + strtotime("-1 day", delibera_tratar_data($prazo_date)), + 'delibera_notificar_fim_prazo', + array( + 'post_ID' => $post_id, + 'prazo_validacao' => $prazo_date + ) + ); + } + else + { + $msn = "empty date on $post_id: ".print_r($this, true)."Dates: ".print_r($prazos, true); + throw new \Exception($msn); + } } } } diff --git a/modules/rapporteur/rapporteur.php b/modules/rapporteur/rapporteur.php index c3ebced..978f2e6 100644 --- a/modules/rapporteur/rapporteur.php +++ b/modules/rapporteur/rapporteur.php @@ -214,23 +214,9 @@ public function topicMeta($post, $custom, $options_plugin_delibera, $situacao, $ } - public function publishPauta($postID, $opt, $alterar) + public function publishPauta($postID, $opt) { - if(!array_key_exists('relatoria', $opt) || $opt['relatoria'] == 'S' && $opt['delibera_flow'][0] == 'relatoria' ) - { - if(!$alterar) - { - if($opt['eleicao_relator'] == 'S') - { - wp_set_object_terms($postID, 'eleicaoredator', 'situacao', false); - } - else - { - wp_set_object_terms($postID, 'relatoria', 'situacao', false); - } - } - } } function checkPostData($erros, $opt, $autosave) diff --git a/modules/result/result.php b/modules/result/result.php index 68af89c..8ea1eed 100644 --- a/modules/result/result.php +++ b/modules/result/result.php @@ -124,7 +124,7 @@ public function topicMeta($post, $custom, $options_plugin_delibera, $situacao, $ * @param array $opt delibera configs * @param bool $alterar has been altered */ - public function publishPauta($postID, $opt, $alterar) + public function publishPauta($postID, $opt) { } diff --git a/modules/validation/validation.php b/modules/validation/validation.php index 997f809..35b1b03 100644 --- a/modules/validation/validation.php +++ b/modules/validation/validation.php @@ -194,7 +194,7 @@ public function topicMeta($post, $custom, $options_plugin_delibera, $situacao, $ * @param array $opt delibera configs * @param bool $alterar has been altered */ - public function publishPauta($postID, $opt, $alterar) + public function publishPauta($postID, $opt) { $events_meta = array(); $events_meta['delibera_numero_comments_validacoes'] = 0; diff --git a/modules/vote/vote.php b/modules/vote/vote.php index 436e0e6..8f04bf0 100644 --- a/modules/vote/vote.php +++ b/modules/vote/vote.php @@ -139,7 +139,7 @@ public function topicMeta($post, $custom, $options_plugin_delibera, $situacao, $ } - public function publishPauta($postID, $opt, $alterar) + public function publishPauta($postID, $opt) { $events_meta = array(); $events_meta['delibera_numero_comments_votos'] = 0; From 6f3274d180bb0b9b6618e7a9a07a8b6b684d9a87 Mon Sep 17 00:00:00 2001 From: Maurilio Atila Date: Thu, 10 Mar 2016 10:46:58 -0300 Subject: [PATCH 072/435] oop and new generic class delibera_user_display --- delibera_list_users.php | 178 +++++++--------------------------- delibera_member_path.php | 96 ++++++++++--------- delibera_user_display.php | 146 ++++++++++++++++++++++++++++ delibera_user_page.php | 197 +++++++++++++++++++++++--------------- 4 files changed, 354 insertions(+), 263 deletions(-) create mode 100644 delibera_user_display.php diff --git a/delibera_list_users.php b/delibera_list_users.php index b3a0424..5016d30 100644 --- a/delibera_list_users.php +++ b/delibera_list_users.php @@ -1,164 +1,56 @@ html(); - } - function get_paginator($total, $page) - { - return paginate_links( array( - 'base' => add_query_arg( 'paged', '%#%' ), - 'format' => '', - 'prev_text' => __('«'), - 'next_text' => __('»'), - 'show_all' => true , - 'total' => $total, - 'current' => $page - )); - } - - function get_number_of_pages( $total_users , $users_per_page ) - { - return ($total_users/$users_per_page); - } - function get_order_by($order) + public function html( $per_page , $search , $order ) { - switch( $order ) - { - case "active": - return array( 'orderby' => 'post_count' , 'order' => 'DESC' ); - case "newest": - return array( 'orderby' => 'registered' , 'order' => 'DESC' ); - default: - return array( 'orderby' => 'display_name' , 'order' => 'ASC' ); - } - } - - function member_page( $per_page , $search , $order ) - { - $order_by = $this->get_order_by($order); - $blogusers = new WP_User_Query( array( - 'number' => $per_page , - 'offset' => get_query_var( 'paged' ), - 'fields' => array( 'display_name', 'user_login' , 'ID' ), - 'search' => $search . '*', - 'search_columns' => array( 'ID' , 'user_nicename' , 'user_login' , 'user_email' ), - 'orderby' => $order_by['orderby'], - 'order' => $order_by['order'], - ) - ); - ?> - - - -
    - - - - - -
    -

    - get_paginator( - $this->get_number_of_pages( $blogusers->get_total() , $per_page ), - get_query_var( 'paged' ) - ); - ?> -

    -
    - -
    - results as $user ) - { - echo '

    ' - . '

    ' . get_avatar( $user->ID ) . '

    ' - . '

    ' . esc_html( $user->display_name ) . ' - ' . get_usernumposts($user->ID) . ' posts

    '; - $args = array( - 'author' => $user->ID, - 'post_type' => 'pauta', - 'orderby' => 'post_date', - 'posts_per_page' => 1 , - 'order' => 'ASC' - ); - - $current_user_posts = get_posts( $args ); - $last_content = $current_user_posts[0]; - ?> -
    -

    post_title; ?>

    -

    post_content;?>

    -
    - -
    -

    - get_paginator( - $this->get_number_of_pages( $blogusers->get_total() , $per_page ), - get_query_var( 'paged' ) - ); - ?> -

    -
    - getOrderBy($order); + $paged = get_query_var( 'paged' ); + $blogusers = $delibera_user_display->getUsers( $order_by , $search , $per_page , $paged ); + $number_of_pages = $delibera_user_display->getNumberOfPages( $blogusers->get_total() , $per_page ); + + $delibera_user_display->formSearch($search); + $delibera_user_display->formOrderAndPaginator( $order , $per_page ); + $delibera_user_display->displayPaginator( $number_of_pages , $paged ); + ?> +
    + results as $user ) + { + $delibera_user_display->avatarAndName($user); + $delibera_user_display->displayLastPauta($user); + } + } + else + { + echo __('Nenhum usuário encontrado!' , 'delibera'); + } + $delibera_user_display->displayPaginator( $number_of_pages , $paged ); + wp_reset_post_data(); + ?> +
    + member_page($per_page , $search , $order); + $this->html($per_page , $search , $order); wp_footer(); ?> member_page($per_page , $search , $order); - } } -global $delibera_user_list; -$delibera_user_list = new Delibera_User_List(); +global $delibera_list_users; +$delibera_list_users = new DeliberaListUsers(); diff --git a/delibera_member_path.php b/delibera_member_path.php index 1df728d..bd75a78 100644 --- a/delibera_member_path.php +++ b/delibera_member_path.php @@ -1,48 +1,58 @@ query_vars ) ) { - include ( ABSPATH . 'wp-content/plugins/delibera/delibera_user_page.php'); - exit; - } - if ( array_key_exists( 'members', $wp_query->query_vars ) ) { - include ( ABSPATH . 'wp-content/plugins/delibera/delibera_list_users.php'); - $delibera_user_list->page(); - exit; - } -} -add_action( 'template_redirect', 'userpage_rewrite_catch' ); - -function user_last_login( $user_login, $user ){ - update_user_meta( $user->ID, '_last_login', time() ); -} -add_action( 'wp_login', 'user_last_login', 10, 2 ); +require_once __DIR__ . DIRECTORY_SEPARATOR . 'delibera_user_page.php'; +require_once __DIR__ . DIRECTORY_SEPARATOR . 'delibera_list_users.php'; +class DeliberaMemberPath +{ + public function __construct() + { + add_filter( 'query_vars', array( $this , 'userpage_rewrite_add_var' ) ) ; + add_action( 'init', array( $this , 'userpage_rewrite_rule') ) ; + add_action( 'template_redirect', array( $this , 'userpage_rewrite_catch') ) ; + } + // Create the query var so that WP catches the custom /member/username url + public function userpage_rewrite_add_var( $vars ) { + $vars[] = 'login'; + $vars[] = 'merbers'; + return $vars; + } + + // Create the rewrites + public function userpage_rewrite_rule() { + add_rewrite_tag( '%login%', '([^&]+)' ); + add_rewrite_rule( + '^delibera/membro/([^/]*)/?', + 'index.php?login=$matches[1]', + 'top' + ); + add_rewrite_tag( '%members%', '' ); + add_rewrite_rule( + '^delibera/membros', + 'index.php?members', + 'top' + ); + } + + // Catch the URL and redirect it to a template file + public function userpage_rewrite_catch() { + global $wp_query; + if ( array_key_exists( 'login', $wp_query->query_vars ) ) { + $login = $wp_query->query_vars['login']; + $user = get_user_by( 'login' , $login ); + global $delibera_user_page; + $delibera_user_page->page($user); + exit; + } + if ( array_key_exists( 'members', $wp_query->query_vars ) ) { + global $delibera_list_users; + $delibera_list_users->page(); + exit; + } + } + +} +global $delibera_member_path; +$delibera_member_path= new DeliberaMemberPath(); diff --git a/delibera_user_display.php b/delibera_user_display.php new file mode 100644 index 0000000..6a9da7d --- /dev/null +++ b/delibera_user_display.php @@ -0,0 +1,146 @@ + 'post_count' , 'order' => 'DESC' ); + case "newest": + return array( 'orderby' => 'registered' , 'order' => 'DESC' ); + default: + return array( 'orderby' => 'display_name' , 'order' => 'ASC' ); + } + } + + public function getPaginator($total, $page) + { + return paginate_links( array( + 'base' => add_query_arg( 'paged', '%#%' ), + 'format' => '', + 'prev_text' => __('«'), + 'next_text' => __('»'), + 'show_all' => true , + 'total' => $total, + 'current' => $page + )); + } + + public function formSearch($seach) + { + ?> + + +
    + + + + + + +
    + + + + $per_page , + 'offset' => $paged, + 'fields' => array( 'display_name', 'user_login' , 'ID' ), + 'search' => $search . '*', + 'search_columns' => array( 'ID' , 'user_nicename' , 'user_login' , 'user_email' ), + 'orderby' => $order_by['orderby'], + 'order' => $order_by['order'], + ) + ); + } + + public function displayPaginator( $number_of_pages , $paged ){ + ?> +
    +

    + getPaginator( $number_of_pages, $paged ); ?> +

    +
    + +

    + +

    ID ); ?>

    +

    display_name ); ?> - ID);?> posts

    +
    +

    + $user->ID, + 'post_type' => 'pauta', + 'posts_per_page' => 1 , + 'orderby' => 'post_date', + 'order' => 'ASC' + ); + $current_user_posts = get_posts( $args ); + return $current_user_posts[0]; + } + public function displayLastPauta($user) + { + $last_content = $this->getLastPauta($user); + ?> +
    +

    post_title; ?>

    +

    post_content;?>

    +
    + query_vars['member']; - $user = get_user_by( 'login' , $user ); ?> -

    -

    - ID ); ?> -
    -
    - first_name . ' produziu de pautas e comentários no Delibera'; ?> -
    -
    - -
    - -
    -

    -
    - $user->ID, - 'status' => 'approve', - 'posts_per_page' => 5, - 'post_type' => 'pauta', - 'paged' => get_query_var( 'paged' ) - ); - $author_posts = new WP_Query( $args ); +require_once __DIR__ . DIRECTORY_SEPARATOR . 'delibera_user_display.php'; - foreach( $author_posts->posts as $post ) +class Delibera_User_page +{ + public function __construct() { - echo '

    ' . $post->post_title . '

    '; - echo '
    ' . $post->post_content . '
    '; - echo '
    '; } - echo '
    '; - echo paginate_links( array( - 'base' => add_query_arg( 'paged', '%#%' ), - 'format' => '', - 'prev_text' => __('«'), - 'next_text' => __('»'), - 'total' => $author_posts->max_num_pages, - 'current' => get_query_var( 'paged' ) - )); - //wp_reset_post_data(); - echo '
    '; - ?> - html( $user , $per_page ); + wp_footer(); + ?> + + + user_pautas( $user , $per_page ); + $this->user_comments($user); + wp_reset_post_data(); + } + + function user_pautas($user, $per_page) + { + global $delibera_user_display; + ?> +

    +

    + ID ); ?> +

    first_name ?>

    +
    +
    +

    +
    +

    + $user->ID, - 'number' => 1, // how many comments to retrieve + 'author' => $user->ID, + 'status' => 'approve', + 'posts_per_page' => $per_page, 'post_type' => 'pauta', - 'status' => 'approve' - ); - - $comments = get_comments( $args ); - - if ( $comments ) + 'paged' => get_query_var( 'paged' ) + ); + $author_posts = new WP_Query( $args ); + $delibera_user_display->formPaginator( $per_page ); + $delibera_user_display->displayPaginator($author_posts->max_num_pages , get_query_var( 'paged' ) ); + foreach( $author_posts->posts as $post ) { - $output.= '
    '; - $output.= '

    Comentários de ' . $user->first_name . '

    '; - $output.= '
    '; - $output.= "'; - $output.= '
    '; - - $output.= '
    '; - echo $output; - } else { echo "No comments made";} + echo '

    ' . $post->post_title . '

    '; + echo '
    ' . $post->post_content . '
    '; + echo '
    '; + } + $delibera_user_display->displayPaginator($author_posts->max_num_pages , get_query_var( 'paged' ) ); + } + + function user_comments($user) + { + $args = array( + 'user_id' => $user->ID, + 'number' => 2, + 'post_type' => 'pauta', + 'status' => 'approve', + 'offset' => get_query_var( 'pagec' ) + ); - ?> + $comments = get_comments( $args ); + echo '
    '; + echo $this->get_paginator( $comments[0]->comment_count/2 , get_query_var( 'pagec' ) ); + echo '
    '; + if ( $comments ) + { + $output.= '

    Comentários:

    '; + $output.= '
    '; + foreach ( $comments as $comment ) + { + $output.= '' . $this->parse_comment_type( $comment->comment_ID , 'tipo') . ':
    '; + $output.= $comment->comment_content . '
    '; + $output.= '' . wp_get_attachment_image(get_comment_meta( $comment->comment_ID , 'attachmentId', true)) . '
    '; + $output.= '

    Na pauta '; + $output.= get_the_title($comment->comment_post_ID); + $output.= ', em '. mysql2date('m/d/Y', $comment->comment_date, $translate); + if( $this->get_comment_meta( $comment->comment_ID , 'tipo') != discussao ) + { + $output.= '

    '; + $output.= 'Numero de votos: '; + $votaram = $this->get_comment_meta( $comment->comment_ID , 'numero_votos'); + $output.= $votaram ? $votaram : '0'; + $output.= '
    '; + } + $output.= '

    Concordaram: '; + $curtiram = $this->get_comment_meta( $comment->comment_ID , 'numero_curtir' ); + $output.= $curtiram ? $curtiram : '0'; + $output.= '
    Discordaram: '; + $discordaram = $this->get_comment_meta( $comment->comment_ID , 'numero_discordar' ); + $output.= $discordaram ? $discordaram : '0'; + $output.= '

    '; + } + $output.= '
    '; + echo $output; + } else { echo __('Usuário não possui nenhum comentário' , 'delibera'); } + } + + function get_comment_meta($id, $control) + { + $string = 'delibera_comment_' . $control; + return get_comment_meta( $id , $string , true); + } -
    - - - + function parse_comment_type($id, $control) + { + $type = $this->get_comment_meta( $id , $control ); + switch($type) + { + case 'encaminhamento': + return 'Proposta de Encaminhamento'; + case 'discussao': + return 'Discussão'; + } + } +} +global $delibera_user_page; +$delibera_user_page = new Delibera_User_Page(); From b859224f949c0b00daf6c802f6964c4d2eea74c2 Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Thu, 10 Mar 2016 12:44:48 -0300 Subject: [PATCH 073/435] fix cron is not adding deadline callback when pauta edited --- delibera_cron.php | 10 ++++-- delibera_flow.php | 11 ++++-- delibera_topic_deadline.php | 56 ------------------------------- delibera_utils.php | 10 ++++-- modules/discussion/discussion.php | 2 +- modules/modulebase.php | 13 ++++--- modules/rapporteur/rapporteur.php | 2 +- modules/result/result.php | 2 +- modules/validation/validation.php | 2 +- modules/vote/vote.php | 8 +++-- 10 files changed, 40 insertions(+), 76 deletions(-) diff --git a/delibera_cron.php b/delibera_cron.php index e08225e..6be68e4 100644 --- a/delibera_cron.php +++ b/delibera_cron.php @@ -125,6 +125,7 @@ function cronList() */ public static function add($data, $call_back, $args) { + $data = intval($data); if(is_int($data) && $data > 0) { $crons = get_option('delibera-cron', array()); @@ -136,7 +137,10 @@ public static function add($data, $call_back, $args) } $crons[$data][] = array('call_back' => $call_back, "args" => $args); ksort($crons); - update_option('delibera-cron', $crons); + if(!update_option('delibera-cron', $crons)) + { + throw new \Exception("Cron not updated on $data, values:".print_r($crons[$data],true)); + } } } @@ -152,7 +156,7 @@ static function del($postID, $callback = false) if( is_array($callback) ) { - $callback = get_class($callback[0]).'_'.$callback[1]; + $callback = $callback[0].'_'.$callback[1]; } $crons_new = array(); @@ -164,7 +168,7 @@ static function del($postID, $callback = false) $cron_callback = $call['call_back']; if( is_array($call['call_back']) ) { - $cron_callback = get_class($call['call_back'][0]).'_'.$call['call_back'][1]; + $cron_callback = $call['call_back'][0].'_'.$call['call_back'][1]; } if(array_key_exists('post_id', $call['args'])) $call['args']['post_ID'] = $call['args']['post_id']; diff --git a/delibera_flow.php b/delibera_flow.php index 6990cb3..574bea2 100644 --- a/delibera_flow.php +++ b/delibera_flow.php @@ -134,6 +134,10 @@ public function getFlowModules() public static function getLastDeadline($situacao, $post_id = false) { global $DeliberaFlow; + if(is_object($situacao)) + { + $situacao = $situacao->slug; + } if($post_id == false) { @@ -165,6 +169,7 @@ public function savePostMetas($events_meta, $opt) public function savePost($post_id, $post, $opt) { + $module = $this->getCurrentModule($post_id); $module->newDeadline($post_id); } @@ -207,7 +212,7 @@ public static function next($post_id = false) $flow = $DeliberaFlow->get($post_id); $situacao = delibera_get_situacao($post_id); - $current = array_search($situacao, $flow); + $current = array_search($situacao->slug, $flow); $modules = $DeliberaFlow->getFlowModules(); //TODO cache? if(array_key_exists($current+1, $flow)) @@ -228,12 +233,12 @@ public static function forcarFimPrazo($post_id) $flow = $DeliberaFlow->get($post_id); $situacao = delibera_get_situacao($post_id); - $current = array_search($situacao, $flow); + $current = array_search($situacao->slug, $flow); $modules = $DeliberaFlow->getFlowModules(); //TODO cache? if(array_key_exists($current, $flow)) { - $modules[$flow[$current]]->deadline(array('post_id' => $post_id, 'prazo' => date('d/m/Y'), 'force' => true)); + call_user_func(array(get_class($modules[$flow[$current]]), 'deadline'), array('post_id' => $post_id, 'prazo' => date('d/m/Y'), 'force' => true) ); } $DeliberaFlow->next($post_id); //delibera_notificar_situacao($postID); // Originaly comment, why? diff --git a/delibera_topic_deadline.php b/delibera_topic_deadline.php index 170f716..98e1274 100644 --- a/delibera_topic_deadline.php +++ b/delibera_topic_deadline.php @@ -138,59 +138,3 @@ function delibera_set_novo_prazo_discussao_relatoria($postID, $inova_data, $opts delibera_criar_agenda($postID, false, $nova_data, $nova_data_votacao, $nova_relatoria, $nova_eleicao_rel); } -/** - * Retorna um inteiro indicando quantos dias faltam para o fim do prazo - * de uma pauta. - * - * Se o parâmetro $data for passado por referência o prazo para o fim da - * pauta é associado a ele. - * - * @param int $postID - * @param string $data - * @return int - * -function \Delibera\Flow::getDeadlineDays($postID, &$data = null) -{ - $situacao = delibera_get_situacao($postID); - $prazo = ""; - $idata = strtotime(date('Y/m/d').' 23:59:59'); - $diff = -1; - - if(is_object($situacao)) - { - switch ($situacao->slug) - { - case 'validacao': - { - $prazo = get_post_meta($postID, 'prazo_validacao', true); - } break; - case 'discussao': - { - $prazo = get_post_meta($postID, 'prazo_discussao', true); - }break; - case 'elegerelator': - { - $prazo = get_post_meta($postID, 'prazo_eleicao_relator', true); - }break; - case 'relatoria': - { - $prazo = get_post_meta($postID, 'prazo_relatoria', true); - }break; - case 'emvotacao': - { - $prazo = get_post_meta($postID, 'prazo_votacao', true); - } break; - } - - $iprazo = strtotime(substr($prazo, 6).substr($prazo, 2, 4).substr($prazo, 0, 2).' 23:59:59'); - - $diff = $iprazo - $idata; - } - $dias = -1; - - if($diff >= 0) $dias = ceil($diff/(60*60*24)); - - if(!is_null($data)) $data = $prazo; - - return $dias; -}*/ \ No newline at end of file diff --git a/delibera_utils.php b/delibera_utils.php index e5b3ca9..b6ab464 100644 --- a/delibera_utils.php +++ b/delibera_utils.php @@ -18,8 +18,14 @@ function delibera_tratar_data($data, $int = true, $onlastsecond = true) { $dateTime = \DateTime::createFromFormat('d/m/Y', $data); } - - return $dateTime->format( ($int ? 'U' : 'Y-m-d H:i:s')); + if(is_object($dateTime)) + { + return $dateTime->format( ($int ? 'U' : 'Y-m-d H:i:s')); + } + else + { + return false; + } } /** diff --git a/modules/discussion/discussion.php b/modules/discussion/discussion.php index 3fdcd74..4e18203 100644 --- a/modules/discussion/discussion.php +++ b/modules/discussion/discussion.php @@ -229,7 +229,7 @@ public function createPautaAtFront($opt) * {@inheritDoc} * @see \Delibera\Modules\ModuleBase::deadline() */ - public function deadline($args) + public static function deadline($args) { $post_id = $args['post_id']; $situacao = delibera_get_situacao($post_id); diff --git a/modules/modulebase.php b/modules/modulebase.php index ca28629..cfe2da3 100644 --- a/modules/modulebase.php +++ b/modules/modulebase.php @@ -184,7 +184,7 @@ public static function getPautas($filtro = array()) * Trigger module deadline event * @param array $args in form: array('post_id' => $post_id, 'prazo' => $prazo) */ - abstract public function deadline($args); + abstract public static function deadline($args); /** * Create new deadline events calendar @@ -204,12 +204,15 @@ public function newDeadline($post_id) $prazo_date = get_post_meta($post_id, $prazo, true); if( ! empty($prazo_date) ) { - \Delibera\Cron::del($post_id, array($this, 'deadline')); + \Delibera\Cron::del($post_id, array(get_class($this), 'deadline')); \Delibera\Cron::del($post_id, 'delibera_notificar_fim_prazo'); - + + $cron = get_option('delibera-cron'); + var_dump($cron); + \Delibera\Cron::add( delibera_tratar_data($prazo_date), - array($this, 'deadline'), + array(get_class($this), 'deadline'), array( 'post_ID' => $post_id, 'prazo' => $prazo_date @@ -220,7 +223,7 @@ public function newDeadline($post_id) 'delibera_notificar_fim_prazo', array( 'post_ID' => $post_id, - 'prazo_validacao' => $prazo_date + $prazo => $prazo_date ) ); } diff --git a/modules/rapporteur/rapporteur.php b/modules/rapporteur/rapporteur.php index 978f2e6..81cbb70 100644 --- a/modules/rapporteur/rapporteur.php +++ b/modules/rapporteur/rapporteur.php @@ -284,7 +284,7 @@ public function createPautaAtFront($opt) * {@inheritDoc} * @see \Delibera\Modules\ModuleBase::deadline() */ - public function deadline($args) + public static function deadline($args) { $situacao = delibera_get_situacao($args['post_ID']); if($situacao->slug == 'relatoria') diff --git a/modules/result/result.php b/modules/result/result.php index 8ea1eed..89d94f7 100644 --- a/modules/result/result.php +++ b/modules/result/result.php @@ -206,7 +206,7 @@ public function createPautaAtFront($opt) * {@inheritDoc} * @see \Delibera\Modules\ModuleBase::deadline() */ - public function deadline($args) + public static function deadline($args) { } diff --git a/modules/validation/validation.php b/modules/validation/validation.php index 35b1b03..fea8093 100644 --- a/modules/validation/validation.php +++ b/modules/validation/validation.php @@ -315,7 +315,7 @@ public function createPautaAtFront($opt) * {@inheritDoc} * @see \Delibera\Modules\ModuleBase::deadline() */ - public function deadline($args) + public static function deadline($args) { $situacao = delibera_get_situacao($args['post_id']); if($situacao->slug == 'validacao') diff --git a/modules/vote/vote.php b/modules/vote/vote.php index 8f04bf0..fd563fc 100644 --- a/modules/vote/vote.php +++ b/modules/vote/vote.php @@ -305,12 +305,14 @@ public function validaVotos($postID) * {@inheritDoc} * @see \Delibera\Modules\ModuleBase::deadline() */ - public function deadline($args) + public static function deadline($args) { - $situacao = delibera_get_situacao($args['post_id']); + $post_id = $args['post_id']; + $situacao = delibera_get_situacao($post_id); if($situacao->slug == 'emvotacao') { - $this->computaVotos($args['post_id']); + $current = \Delibera\Flow::getCurrentModule($post_id); + $current->computaVotos($post_id); } } From ddb95fe83f7ee3015068d6e3650c949fb716f1a6 Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Thu, 10 Mar 2016 12:49:43 -0300 Subject: [PATCH 074/435] revert error when deadline is not configured/activated --- modules/modulebase.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/modulebase.php b/modules/modulebase.php index cfe2da3..0f1c93a 100644 --- a/modules/modulebase.php +++ b/modules/modulebase.php @@ -229,8 +229,9 @@ public function newDeadline($post_id) } else { - $msn = "empty date on $post_id: ".print_r($this, true)."Dates: ".print_r($prazos, true); - throw new \Exception($msn); + /*$msn = "empty date on $post_id: ".print_r($this, true)."Dates: ".print_r($prazos, true); + throw new \Exception($msn);*/ + // empty date! Meaning: no activated deadline, then do nothing } } } From 111b831e41fdcb75433b9805b3d9972fd116fd05 Mon Sep 17 00:00:00 2001 From: Maurilio Atila Date: Thu, 10 Mar 2016 17:36:52 -0300 Subject: [PATCH 075/435] user list template --- delibera_list_users.php | 56 --------------------- delibera_member_path.php | 5 +- delibera_user_display.php | 89 ++------------------------------- delibera_user_page.php | 8 +-- themes/creta/page-authors.php | 93 +++++++++++++++++++++++++++++++++++ 5 files changed, 104 insertions(+), 147 deletions(-) delete mode 100644 delibera_list_users.php create mode 100644 themes/creta/page-authors.php diff --git a/delibera_list_users.php b/delibera_list_users.php deleted file mode 100644 index 5016d30..0000000 --- a/delibera_list_users.php +++ /dev/null @@ -1,56 +0,0 @@ -getOrderBy($order); - $paged = get_query_var( 'paged' ); - $blogusers = $delibera_user_display->getUsers( $order_by , $search , $per_page , $paged ); - $number_of_pages = $delibera_user_display->getNumberOfPages( $blogusers->get_total() , $per_page ); - - $delibera_user_display->formSearch($search); - $delibera_user_display->formOrderAndPaginator( $order , $per_page ); - $delibera_user_display->displayPaginator( $number_of_pages , $paged ); - ?> -
    - results as $user ) - { - $delibera_user_display->avatarAndName($user); - $delibera_user_display->displayLastPauta($user); - } - } - else - { - echo __('Nenhum usuário encontrado!' , 'delibera'); - } - $delibera_user_display->displayPaginator( $number_of_pages , $paged ); - wp_reset_post_data(); - ?> -
    - html($per_page , $search , $order); - wp_footer(); - ?> - - - query_vars ) ) { - global $delibera_list_users; - $delibera_list_users->page(); + load_template(__DIR__ . DIRECTORY_SEPARATOR . 'themes/creta/page-authors.php' , true); exit; } } diff --git a/delibera_user_display.php b/delibera_user_display.php index 6a9da7d..b040d2f 100644 --- a/delibera_user_display.php +++ b/delibera_user_display.php @@ -1,6 +1,6 @@ - - -
    - - - - - - -
    - - - - -
    -

    - getPaginator( $number_of_pages, $paged ); ?> -

    -
    - -

    - -

    ID ); ?>

    -

    display_name ); ?> - ID);?> posts

    -
    -

    - $user->ID, @@ -130,17 +60,8 @@ protected function getLastPauta($user) $current_user_posts = get_posts( $args ); return $current_user_posts[0]; } - public function displayLastPauta($user) - { - $last_content = $this->getLastPauta($user); - ?> -
    -

    post_title; ?>

    -

    post_content;?>

    -
    -

    @@ -51,15 +51,15 @@ function user_pautas($user, $per_page) 'paged' => get_query_var( 'paged' ) ); $author_posts = new WP_Query( $args ); - $delibera_user_display->formPaginator( $per_page ); - $delibera_user_display->displayPaginator($author_posts->max_num_pages , get_query_var( 'paged' ) ); + $user_display->formPaginator( $per_page ); + $user_display->displayPaginator($author_posts->max_num_pages , get_query_var( 'paged' ) ); foreach( $author_posts->posts as $post ) { echo '

    ' . $post->post_title . '

    '; echo '
    ' . $post->post_content . '
    '; echo '
    '; } - $delibera_user_display->displayPaginator($author_posts->max_num_pages , get_query_var( 'paged' ) ); + $user_display->displayPaginator($author_posts->max_num_pages , get_query_var( 'paged' ) ); } function user_comments($user) diff --git a/themes/creta/page-authors.php b/themes/creta/page-authors.php new file mode 100644 index 0000000..64bf464 --- /dev/null +++ b/themes/creta/page-authors.php @@ -0,0 +1,93 @@ +getOrderBy($order); + $paged = get_query_var( 'paged' ); + $blogusers = $user_display->getUsers( $order_by , $search , $per_page , $paged ); + + $number_of_pages = $user_display->getNumberOfPages( $blogusers->get_total() , $per_page ); + + ?> + + +
    + + + + + + +
    +

    + getPaginator( $number_of_pages, $paged ); ?> +

    +
    +
    + results as $user ) + { + ?> +

    + +

    + ID ); ?> +

    +

    + display_name ); ?> + - + ID);?> + posts +

    +
    +

    + + getLastPauta($user); ?> + +
    +

    post_title; ?>

    +

    post_content;?>

    +
    + + getPaginator( $number_of_pages , $paged ); + wp_reset_post_data(); + ?> +
    + + + From 9613e35ab660836465dbf7d64b4f7c81fb72ae8a Mon Sep 17 00:00:00 2001 From: Maurilio Atila Date: Thu, 10 Mar 2016 22:24:34 -0300 Subject: [PATCH 076/435] inserted templates author pautas and author comments --- delibera_member_path.php | 67 +++++++++---- delibera_user_display.php | 20 ++++ delibera_user_page.php | 132 -------------------------- themes/creta/page-author-comments.php | 131 +++++++++++++++++++++++++ themes/creta/page-author-pautas.php | 85 +++++++++++++++++ themes/creta/page-authors.php | 23 +++-- 6 files changed, 293 insertions(+), 165 deletions(-) delete mode 100644 delibera_user_page.php create mode 100644 themes/creta/page-author-comments.php create mode 100644 themes/creta/page-author-pautas.php diff --git a/delibera_member_path.php b/delibera_member_path.php index b3274c3..3b9737e 100644 --- a/delibera_member_path.php +++ b/delibera_member_path.php @@ -1,49 +1,62 @@ query_vars ) ) { - $login = $wp_query->query_vars['login']; - $user = get_user_by( 'login' , $login ); - global $delibera_user_page; - $delibera_user_page->page($user); + if ( array_key_exists( 'pautasfor', $wp_query->query_vars ) ) { + load_template(__DIR__ . DIRECTORY_SEPARATOR . 'themes/creta/page-author-pautas.php' , true); + exit; + } + if ( array_key_exists( 'commentsfor', $wp_query->query_vars ) ) { + load_template(__DIR__ . DIRECTORY_SEPARATOR . 'themes/creta/page-author-comments.php' , true); exit; } if ( array_key_exists( 'members', $wp_query->query_vars ) ) { @@ -51,7 +64,19 @@ public function userpage_rewrite_catch() { exit; } } - + + // Changing excerpt length + public function new_excerpt_length($length) + { + return 100; + } + + // Changing excerpt more + public function new_excerpt_more($more) + { + return '...'; + } + } -global $delibera_member_path; -$delibera_member_path= new DeliberaMemberPath(); +global $member_path; +$member_path= new MemberPath(); diff --git a/delibera_user_display.php b/delibera_user_display.php index b040d2f..4b4aeae 100644 --- a/delibera_user_display.php +++ b/delibera_user_display.php @@ -61,7 +61,27 @@ public function getLastPauta($user) return $current_user_posts[0]; } + public function get_comment_meta($id, $control) + { + $string = 'delibera_comment_' . $control; + return get_comment_meta( $id , $string , true); + } + + public function parse_comment_type($id, $control) + { + $type = $this->get_comment_meta( $id , $control ); + switch($type) + { + case 'encaminhamento': + return 'Proposta de Encaminhamento'; + case 'discussao': + return 'Discussão'; + case 'validacao': + return 'Validação'; + } + } } + global $user_display; $user_display = new UserDisplay(); diff --git a/delibera_user_page.php b/delibera_user_page.php deleted file mode 100644 index 17856f1..0000000 --- a/delibera_user_page.php +++ /dev/null @@ -1,132 +0,0 @@ -html( $user , $per_page ); - wp_footer(); - ?> - - - user_pautas( $user , $per_page ); - $this->user_comments($user); - wp_reset_post_data(); - } - - function user_pautas($user, $per_page) - { - global $user_display; - ?> -

    -

    - ID ); ?> -

    first_name ?>

    -
    -
    -

    -
    -

    - $user->ID, - 'status' => 'approve', - 'posts_per_page' => $per_page, - 'post_type' => 'pauta', - 'paged' => get_query_var( 'paged' ) - ); - $author_posts = new WP_Query( $args ); - $user_display->formPaginator( $per_page ); - $user_display->displayPaginator($author_posts->max_num_pages , get_query_var( 'paged' ) ); - foreach( $author_posts->posts as $post ) - { - echo '

    ' . $post->post_title . '

    '; - echo '
    ' . $post->post_content . '
    '; - echo '
    '; - } - $user_display->displayPaginator($author_posts->max_num_pages , get_query_var( 'paged' ) ); - } - - function user_comments($user) - { - $args = array( - 'user_id' => $user->ID, - 'number' => 2, - 'post_type' => 'pauta', - 'status' => 'approve', - 'offset' => get_query_var( 'pagec' ) - ); - - $comments = get_comments( $args ); - echo '
    '; - echo $this->get_paginator( $comments[0]->comment_count/2 , get_query_var( 'pagec' ) ); - echo '
    '; - if ( $comments ) - { - $output.= '

    Comentários:

    '; - $output.= '
    '; - foreach ( $comments as $comment ) - { - $output.= '' . $this->parse_comment_type( $comment->comment_ID , 'tipo') . ':
    '; - $output.= $comment->comment_content . '
    '; - $output.= '' . wp_get_attachment_image(get_comment_meta( $comment->comment_ID , 'attachmentId', true)) . '
    '; - $output.= '

    Na pauta '; - $output.= get_the_title($comment->comment_post_ID); - $output.= ', em '. mysql2date('m/d/Y', $comment->comment_date, $translate); - if( $this->get_comment_meta( $comment->comment_ID , 'tipo') != discussao ) - { - $output.= '

    '; - $output.= 'Numero de votos: '; - $votaram = $this->get_comment_meta( $comment->comment_ID , 'numero_votos'); - $output.= $votaram ? $votaram : '0'; - $output.= '
    '; - } - $output.= '

    Concordaram: '; - $curtiram = $this->get_comment_meta( $comment->comment_ID , 'numero_curtir' ); - $output.= $curtiram ? $curtiram : '0'; - $output.= '
    Discordaram: '; - $discordaram = $this->get_comment_meta( $comment->comment_ID , 'numero_discordar' ); - $output.= $discordaram ? $discordaram : '0'; - $output.= '

    '; - } - $output.= '
    '; - echo $output; - } else { echo __('Usuário não possui nenhum comentário' , 'delibera'); } - } - - function get_comment_meta($id, $control) - { - $string = 'delibera_comment_' . $control; - return get_comment_meta( $id , $string , true); - } - - function parse_comment_type($id, $control) - { - $type = $this->get_comment_meta( $id , $control ); - switch($type) - { - case 'encaminhamento': - return 'Proposta de Encaminhamento'; - case 'discussao': - return 'Discussão'; - } - } -} - -global $delibera_user_page; -$delibera_user_page = new Delibera_User_Page(); diff --git a/themes/creta/page-author-comments.php b/themes/creta/page-author-comments.php new file mode 100644 index 0000000..626ce64 --- /dev/null +++ b/themes/creta/page-author-comments.php @@ -0,0 +1,131 @@ +query_vars['commentsfor']; +$user = get_user_by( 'login' , $login ); + +$per_page = isset( $_GET['per-page'] ) ? esc_html( $_GET['per-page'] ) : '20' ; +$search = isset( $_GET['search'] ) ? esc_html( $_GET['search'] ) : '' ; +$order = isset( $_GET['order-by'] ) ? esc_html( $_GET['order-by'] ) : '' ; + + global $user_display; + ?> + +
    + + + +

    +

    + ID ); ?> +

    first_name ?>

    +
    +
    +

    +
    +

    + + $user->ID, + 'number' => $per_page, + 'post_type' => 'pauta', + 'status' => 'approve', + 'offset' => get_query_var( 'paged' ) + ); + + $comments = get_comments( $args ); + //var_dump($comments); + + ?> +
    +

    + getPaginator( + $user_display->getNumberOfPages($comments[0]->comment_count,$per_page) + , get_query_var( 'paged' ) ); + ?> +

    +
    + +

    Comentários:

    +
    + + + parse_comment_type( $comment->comment_ID , 'tipo'); ?> + +
    + comment_content;?> +
    + comment_ID , 'attachmentId', true)); ?> +
    +

    Na pauta + + comment_post_ID); ?>, em + + comment_date, $translate); + echo $user_display->get_comment_meta( $comment->comment_ID , 'tipo'); + ?> + get_comment_meta( $comment->comment_ID , 'tipo') === 'validacao') + { + ?> +

    + Numero de votos: + get_comment_meta( $comment->comment_ID , 'numero_votos'); + echo $votaram ? $votaram : '0'; + ?> +
    + +

    Concordaram: + get_comment_meta( $comment->comment_ID , 'numero_curtir' ); + echo $curtiram ? $curtiram : '0'; + ?> +
    Discordaram: + get_comment_meta( $comment->comment_ID , 'numero_discordar' ); + echo $discordaram ? $discordaram : '0'; + ?> +

    + +
    + +
    +

    + getPaginator( + $user_display->getNumberOfPages($comments[0]->comment_count,$per_page) + , get_query_var( 'paged' ) ); + ?> +

    +
    + + + \ No newline at end of file diff --git a/themes/creta/page-author-pautas.php b/themes/creta/page-author-pautas.php new file mode 100644 index 0000000..c9d2852 --- /dev/null +++ b/themes/creta/page-author-pautas.php @@ -0,0 +1,85 @@ +query_vars['pautasfor']; +$user = get_user_by( 'login' , $login ); + +$per_page = isset( $_GET['per-page'] ) ? esc_html( $_GET['per-page'] ) : '20' ; +$search = isset( $_GET['search'] ) ? esc_html( $_GET['search'] ) : '' ; +$order = isset( $_GET['order-by'] ) ? esc_html( $_GET['order-by'] ) : '' ; + + global $user_display; + ?> + +
    + + + +

    +

    + ID ); ?> +

    first_name ?>

    +
    +
    +

    +
    +

    + + $user->ID, + 'status' => 'approve', + 's' => $search, + 'posts_per_page' => $per_page, + 'post_type' => 'pauta', + 'paged' => get_query_var( 'paged' ) + ); + + $author_posts = new WP_Query( $args ); + ?> +
    +

    + getPaginator( $author_posts->max_num_pages, $paged ); ?> +

    +
    + posts as $post ) + { + ?> +

    + + ', ''); ?> + +

    + +
    +

    + getPaginator( $author_posts->max_num_pages , $per_page ); ?> +

    +
    + + + \ No newline at end of file diff --git a/themes/creta/page-authors.php b/themes/creta/page-authors.php index 64bf464..7faaa35 100644 --- a/themes/creta/page-authors.php +++ b/themes/creta/page-authors.php @@ -3,15 +3,14 @@ Template Name: Authors Page */ get_header(); - global $user_display; - $per_page = isset( $_GET['per-page'] ) ? esc_html( $_GET['per-page'] ) : '20' ; - $search = isset( $_GET['search'] ) ? esc_html( $_GET['search'] ) : '' ; - $order = isset( $_GET['order-by'] ) ? esc_html( $_GET['order-by'] ) : '' ; - $order_by = $user_display->getOrderBy($order); - $paged = get_query_var( 'paged' ); - $blogusers = $user_display->getUsers( $order_by , $search , $per_page , $paged ); - - $number_of_pages = $user_display->getNumberOfPages( $blogusers->get_total() , $per_page ); +global $user_display; +$per_page = isset( $_GET['per-page'] ) ? esc_html( $_GET['per-page'] ) : '20' ; +$search = isset( $_GET['search'] ) ? esc_html( $_GET['search'] ) : '' ; +$order = isset( $_GET['order-by'] ) ? esc_html( $_GET['order-by'] ) : '' ; +$order_by = $user_display->getOrderBy($order); +$paged = get_query_var( 'paged' ); +$blogusers = $user_display->getUsers( $order_by , $search , $per_page , $paged ); +$number_of_pages = $user_display->getNumberOfPages( $blogusers->get_total() , $per_page ); ?> -
    + +
    '; - ?> - -
    -
    +
    +
    + +
    + +
    + +
    + '; + $opt = delibera_get_config(); + + $rows = array(); + $rows[] = array( + "id" => "notificacoes", + "label" => __('Permitir notificações por e-mail?','delibera'), + "content" => $content_notif + ); + $table .= delibera_form_table($rows); + $rows_lang = array(); + + if(function_exists('qtrans_enableLanguage')) + { + $head = "
    "; + global $q_config; + foreach ($q_config['enabled_languages'] as $lang) + { + $display = "none"; + $ativa = ""; + + if($lang == $q_config['default_language']) + { + $display = "block"; + $ativa = "active"; + } + + $onclick="switch_mensagem_box('".$lang."');"; + $head.= ''; + + $rows_lang[$lang] = delibera_nofiticar_config_page_campos($opt, $lang); + + if($lang == $q_config['default_language']) + { + $rows_lang[$lang]['default'] = true; + } + } + $table .= $head."
    "; + } + else + { + + $lang = get_locale(); + + $display = "block"; + $ativa = "active"; + + $rows_lang[$lang] = delibera_nofiticar_config_page_campos($opt, $lang); + + $rows_lang[$lang]['default'] = true; + + $table; + } + + $table .= '
    '; + $rows = array(); + $i = 0; + + foreach (delibera_nofiticar_get_tipos() as $notif) + { + delibera_nofiticar_config_page_create_checkbox($rows, + "{$notif['mensagem']}-enabled", + $notif['dica_permicao'], + $opt, + $rows_lang, $i++ + ); + } + echo $table; + echo '
    +
    ', + esc_html__( 'Upgrade message from the plugin author:', 'tgmpa' ), + ' ', wp_kses_data( $item['upgrade_notice'] ), ' +
    +
    '; + $row = current($rows); + + echo ''; + + $row = next($rows); + echo ''; + + $row = next($rows); + echo ''; + + $row = next($rows); + echo ''; + + $row = next($rows); + echo ''; + + $row = next($rows); + echo ''; + + $row = next($rows); + echo ''; + + $row = next($rows); + echo ''; + + $row = next($rows); + echo ''; + + $row = next($rows); + echo ''; + + + $row = next($rows); + echo ''; + + $row = next($rows); + echo ''; + + $row = next($rows); + echo ''; + + $row = next($rows); + echo ''; + + $row = next($rows); + echo ''; + + $row = next($rows); + echo ''; + + $row = next($rows); + echo ''; + + $row = next($rows); + echo ''; + + $row = next($rows); + echo ''; + + $row = next($rows); + echo ''; + + $row = next($rows); + echo ''; + + $row = next($rows); + echo ''; + + $row = next($rows); + echo ''; + + $row = next($rows); + echo ''; + + $row = next($rows); + echo ''; + + $row = next($rows); + echo ''; + + $row = next($rows); + echo ''; + + $row = next($rows); + echo ''; + + $row = next($rows); + echo ''; + + $row = next($rows); + echo ''; + + $row = next($rows); + echo ''; + + $row = next($rows); + echo ''; + + $row = next($rows); + echo ''; + + $row = next($rows); + echo ''; + + $row = next($rows); + echo ''; + + $row = next($rows); + echo ''; + + $row = next($rows); + echo ''; + + $row = next($rows); + echo ''; + + $row = next($rows); + echo ''; + echo '
    '; + + if (isset($row['id']) && $row['id'] != '') { + echo ''; + } else { + echo $row['label']; + } + + if (isset($row['desc']) && $row['desc'] != '') { + echo '
    '.$row['desc'].''; + } + + echo '
    '; + echo array_key_exists('type', $row) ? wp_editor( $row['content'] , $row['id'] , array( 'editor_class' => 'delibera-config-mensagem') ): $row['content']; + echo '
    '; + + if (isset($row['id']) && $row['id'] != '') { + echo ''; + } else { + echo $row['label']; + } + + if (isset($row['desc']) && $row['desc'] != '') { + echo '
    '.$row['desc'].''; + } + + echo '
    '; + echo array_key_exists('type', $row) ? wp_editor( $row['content'] , $row['id'] , array( 'editor_class' => 'delibera-config-mensagem') ): $row['content']; + echo '
    '; + + if (isset($row['id']) && $row['id'] != '') { + echo ''; + } else { + echo $row['label']; + } + + if (isset($row['desc']) && $row['desc'] != '') { + echo '
    '.$row['desc'].''; + } + + echo '
    '; + echo array_key_exists('type', $row) ? wp_editor( $row['content'] , $row['id'] , array( 'editor_class' => 'delibera-config-mensagem') ): $row['content']; + echo '
    '; + + if (isset($row['id']) && $row['id'] != '') { + echo ''; + } else { + echo $row['label']; + } + + if (isset($row['desc']) && $row['desc'] != '') { + echo '
    '.$row['desc'].''; + } + + echo '
    '; + echo array_key_exists('type', $row) ? wp_editor( $row['content'] , $row['id'] , array( 'editor_class' => 'delibera-config-mensagem') ): $row['content']; + echo '
    '; + + if (isset($row['id']) && $row['id'] != '') { + echo ''; + } else { + echo $row['label']; + } + + if (isset($row['desc']) && $row['desc'] != '') { + echo '
    '.$row['desc'].''; + } + + echo '
    '; + echo array_key_exists('type', $row) ? wp_editor( $row['content'] , $row['id'] , array( 'editor_class' => 'delibera-config-mensagem') ): $row['content']; + echo '
    '; + + if (isset($row['id']) && $row['id'] != '') { + echo ''; + } else { + echo $row['label']; + } + + if (isset($row['desc']) && $row['desc'] != '') { + echo '
    '.$row['desc'].''; + } + + echo '
    '; + echo array_key_exists('type', $row) ? wp_editor( $row['content'] , $row['id'] , array( 'editor_class' => 'delibera-config-mensagem') ): $row['content']; + echo '
    '; + + if (isset($row['id']) && $row['id'] != '') { + echo ''; + } else { + echo $row['label']; + } + + if (isset($row['desc']) && $row['desc'] != '') { + echo '
    '.$row['desc'].''; + } + + echo '
    '; + echo array_key_exists('type', $row) ? wp_editor( $row['content'] , $row['id'] , array( 'editor_class' => 'delibera-config-mensagem') ): $row['content']; + echo '
    '; + + if (isset($row['id']) && $row['id'] != '') { + echo ''; + } else { + echo $row['label']; + } + + if (isset($row['desc']) && $row['desc'] != '') { + echo '
    '.$row['desc'].''; + } + + echo '
    '; + echo array_key_exists('type', $row) ? wp_editor( $row['content'] , $row['id'] , array( 'editor_class' => 'delibera-config-mensagem') ): $row['content']; + echo '
    '; + + if (isset($row['id']) && $row['id'] != '') { + echo ''; + } else { + echo $row['label']; + } + + if (isset($row['desc']) && $row['desc'] != '') { + echo '
    '.$row['desc'].''; + } + + echo '
    '; + echo array_key_exists('type', $row) ? wp_editor( $row['content'] , $row['id'] , array( 'editor_class' => 'delibera-config-mensagem') ): $row['content']; + echo '
    '; + + if (isset($row['id']) && $row['id'] != '') { + echo ''; + } else { + echo $row['label']; + } + + if (isset($row['desc']) && $row['desc'] != '') { + echo '
    '.$row['desc'].''; + } + + echo '
    '; + echo array_key_exists('type', $row) ? wp_editor( $row['content'] , $row['id'] , array( 'editor_class' => 'delibera-config-mensagem') ): $row['content']; + echo '
    '; + + if (isset($row['id']) && $row['id'] != '') { + echo ''; + } else { + echo $row['label']; + } + + if (isset($row['desc']) && $row['desc'] != '') { + echo '
    '.$row['desc'].''; + } + + echo '
    '; + echo array_key_exists('type', $row) ? wp_editor( $row['content'] , $row['id'] , array( 'editor_class' => 'delibera-config-mensagem') ): $row['content']; + echo '
    '; + + if (isset($row['id']) && $row['id'] != '') { + echo ''; + } else { + echo $row['label']; + } + + if (isset($row['desc']) && $row['desc'] != '') { + echo '
    '.$row['desc'].''; + } + + echo '
    '; + echo array_key_exists('type', $row) ? wp_editor( $row['content'] , $row['id'] , array( 'editor_class' => 'delibera-config-mensagem') ): $row['content']; + echo '
    '; + + if (isset($row['id']) && $row['id'] != '') { + echo ''; + } else { + echo $row['label']; + } + + if (isset($row['desc']) && $row['desc'] != '') { + echo '
    '.$row['desc'].''; + } + + echo '
    '; + echo array_key_exists('type', $row) ? wp_editor( $row['content'] , $row['id'] , array( 'editor_class' => 'delibera-config-mensagem') ): $row['content']; + echo '
    '; + + if (isset($row['id']) && $row['id'] != '') { + echo ''; + } else { + echo $row['label']; + } + + if (isset($row['desc']) && $row['desc'] != '') { + echo '
    '.$row['desc'].''; + } + + echo '
    '; + echo array_key_exists('type', $row) ? wp_editor( $row['content'] , $row['id'] , array( 'editor_class' => 'delibera-config-mensagem') ): $row['content']; + echo '
    '; + + if (isset($row['id']) && $row['id'] != '') { + echo ''; + } else { + echo $row['label']; + } + + if (isset($row['desc']) && $row['desc'] != '') { + echo '
    '.$row['desc'].''; + } + + echo '
    '; + echo array_key_exists('type', $row) ? wp_editor( $row['content'] , $row['id'] , array( 'editor_class' => 'delibera-config-mensagem') ): $row['content']; + echo '
    '; + + if (isset($row['id']) && $row['id'] != '') { + echo ''; + } else { + echo $row['label']; + } + + if (isset($row['desc']) && $row['desc'] != '') { + echo '
    '.$row['desc'].''; + } + + echo '
    '; + echo array_key_exists('type', $row) ? wp_editor( $row['content'] , $row['id'] , array( 'editor_class' => 'delibera-config-mensagem') ): $row['content']; + echo '
    '; + + if (isset($row['id']) && $row['id'] != '') { + echo ''; + } else { + echo $row['label']; + } + + if (isset($row['desc']) && $row['desc'] != '') { + echo '
    '.$row['desc'].''; + } + + echo '
    '; + echo array_key_exists('type', $row) ? wp_editor( $row['content'] , $row['id'] , array( 'editor_class' => 'delibera-config-mensagem') ): $row['content']; + echo '
    '; + + if (isset($row['id']) && $row['id'] != '') { + echo ''; + } else { + echo $row['label']; + } + + if (isset($row['desc']) && $row['desc'] != '') { + echo '
    '.$row['desc'].''; + } + + echo '
    '; + echo array_key_exists('type', $row) ? wp_editor( $row['content'] , $row['id'] , array( 'editor_class' => 'delibera-config-mensagem') ): $row['content']; + echo '
    '; + + if (isset($row['id']) && $row['id'] != '') { + echo ''; + } else { + echo $row['label']; + } + + if (isset($row['desc']) && $row['desc'] != '') { + echo '
    '.$row['desc'].''; + } + + echo '
    '; + echo array_key_exists('type', $row) ? wp_editor( $row['content'] , $row['id'] , array( 'editor_class' => 'delibera-config-mensagem') ): $row['content']; + echo '
    '; + + if (isset($row['id']) && $row['id'] != '') { + echo ''; + } else { + echo $row['label']; + } + + if (isset($row['desc']) && $row['desc'] != '') { + echo '
    '.$row['desc'].''; + } + + echo '
    '; + echo array_key_exists('type', $row) ? wp_editor( $row['content'] , $row['id'] , array( 'editor_class' => 'delibera-config-mensagem') ): $row['content']; + echo '
    '; + + if (isset($row['id']) && $row['id'] != '') { + echo ''; + } else { + echo $row['label']; + } + + if (isset($row['desc']) && $row['desc'] != '') { + echo '
    '.$row['desc'].''; + } + + echo '
    '; + echo array_key_exists('type', $row) ? wp_editor( $row['content'] , $row['id'] , array( 'editor_class' => 'delibera-config-mensagem') ): $row['content']; + echo '
    '; + + if (isset($row['id']) && $row['id'] != '') { + echo ''; + } else { + echo $row['label']; + } + + if (isset($row['desc']) && $row['desc'] != '') { + echo '
    '.$row['desc'].''; + } + + echo '
    '; + echo array_key_exists('type', $row) ? wp_editor( $row['content'] , $row['id'] , array( 'editor_class' => 'delibera-config-mensagem') ): $row['content']; + echo '
    '; + + if (isset($row['id']) && $row['id'] != '') { + echo ''; + } else { + echo $row['label']; + } + + if (isset($row['desc']) && $row['desc'] != '') { + echo '
    '.$row['desc'].''; + } + + echo '
    '; + echo array_key_exists('type', $row) ? wp_editor( $row['content'] , $row['id'] , array( 'editor_class' => 'delibera-config-mensagem') ): $row['content']; + echo '
    '; + + if (isset($row['id']) && $row['id'] != '') { + echo ''; + } else { + echo $row['label']; + } + + if (isset($row['desc']) && $row['desc'] != '') { + echo '
    '.$row['desc'].''; + } + + echo '
    '; + echo array_key_exists('type', $row) ? wp_editor( $row['content'] , $row['id'] , array( 'editor_class' => 'delibera-config-mensagem') ): $row['content']; + echo '
    '; + + if (isset($row['id']) && $row['id'] != '') { + echo ''; + } else { + echo $row['label']; + } + + if (isset($row['desc']) && $row['desc'] != '') { + echo '
    '.$row['desc'].''; + } + + echo '
    '; + echo array_key_exists('type', $row) ? wp_editor( $row['content'] , $row['id'] , array( 'editor_class' => 'delibera-config-mensagem') ): $row['content']; + echo '
    '; + + if (isset($row['id']) && $row['id'] != '') { + echo ''; + } else { + echo $row['label']; + } + + if (isset($row['desc']) && $row['desc'] != '') { + echo '
    '.$row['desc'].''; + } + + echo '
    '; + echo array_key_exists('type', $row) ? wp_editor( $row['content'] , $row['id'] , array( 'editor_class' => 'delibera-config-mensagem') ): $row['content']; + echo '
    '; + + if (isset($row['id']) && $row['id'] != '') { + echo ''; + } else { + echo $row['label']; + } + + if (isset($row['desc']) && $row['desc'] != '') { + echo '
    '.$row['desc'].''; + } + + echo '
    '; + echo array_key_exists('type', $row) ? wp_editor( $row['content'] , $row['id'] , array( 'editor_class' => 'delibera-config-mensagem') ): $row['content']; + echo '
    '; + + if (isset($row['id']) && $row['id'] != '') { + echo ''; + } else { + echo $row['label']; + } + + if (isset($row['desc']) && $row['desc'] != '') { + echo '
    '.$row['desc'].''; + } + + echo '
    '; + echo array_key_exists('type', $row) ? wp_editor( $row['content'] , $row['id'] , array( 'editor_class' => 'delibera-config-mensagem') ): $row['content']; + echo '
    '; + + if (isset($row['id']) && $row['id'] != '') { + echo ''; + } else { + echo $row['label']; + } + + if (isset($row['desc']) && $row['desc'] != '') { + echo '
    '.$row['desc'].''; + } + + echo '
    '; + echo array_key_exists('type', $row) ? wp_editor( $row['content'] , $row['id'] , array( 'editor_class' => 'delibera-config-mensagem') ): $row['content']; + echo '
    '; + + if (isset($row['id']) && $row['id'] != '') { + echo ''; + } else { + echo $row['label']; + } + + if (isset($row['desc']) && $row['desc'] != '') { + echo '
    '.$row['desc'].''; + } + + echo '
    '; + echo array_key_exists('type', $row) ? wp_editor( $row['content'] , $row['id'] , array( 'editor_class' => 'delibera-config-mensagem') ): $row['content']; + echo '
    '; + + if (isset($row['id']) && $row['id'] != '') { + echo ''; + } else { + echo $row['label']; + } + + if (isset($row['desc']) && $row['desc'] != '') { + echo '
    '.$row['desc'].''; + } + + echo '
    '; + echo array_key_exists('type', $row) ? wp_editor( $row['content'] , $row['id'] , array( 'editor_class' => 'delibera-config-mensagem') ): $row['content']; + echo '
    '; + + if (isset($row['id']) && $row['id'] != '') { + echo ''; + } else { + echo $row['label']; + } + + if (isset($row['desc']) && $row['desc'] != '') { + echo '
    '.$row['desc'].''; + } + + echo '
    '; + echo array_key_exists('type', $row) ? wp_editor( $row['content'] , $row['id'] , array( 'editor_class' => 'delibera-config-mensagem') ): $row['content']; + echo '
    '; + + if (isset($row['id']) && $row['id'] != '') { + echo ''; + } else { + echo $row['label']; + } + + if (isset($row['desc']) && $row['desc'] != '') { + echo '
    '.$row['desc'].''; + } + + echo '
    '; + echo array_key_exists('type', $row) ? wp_editor( $row['content'] , $row['id'] , array( 'editor_class' => 'delibera-config-mensagem') ): $row['content']; + echo '
    '; + + if (isset($row['id']) && $row['id'] != '') { + echo ''; + } else { + echo $row['label']; + } + + if (isset($row['desc']) && $row['desc'] != '') { + echo '
    '.$row['desc'].''; + } + + echo '
    '; + echo array_key_exists('type', $row) ? wp_editor( $row['content'] , $row['id'] , array( 'editor_class' => 'delibera-config-mensagem') ): $row['content']; + echo '
    '; + + if (isset($row['id']) && $row['id'] != '') { + echo ''; + } else { + echo $row['label']; + } + + if (isset($row['desc']) && $row['desc'] != '') { + echo '
    '.$row['desc'].''; + } + + echo '
    '; + echo array_key_exists('type', $row) ? wp_editor( $row['content'] , $row['id'] , array( 'editor_class' => 'delibera-config-mensagem') ): $row['content']; + echo '
    '; + + if (isset($row['id']) && $row['id'] != '') { + echo ''; + } else { + echo $row['label']; + } + + if (isset($row['desc']) && $row['desc'] != '') { + echo '
    '.$row['desc'].''; + } + + echo '
    '; + echo array_key_exists('type', $row) ? wp_editor( $row['content'] , $row['id'] , array( 'editor_class' => 'delibera-config-mensagem') ): $row['content']; + echo '
    '; + + if (isset($row['id']) && $row['id'] != '') { + echo ''; + } else { + echo $row['label']; + } + + if (isset($row['desc']) && $row['desc'] != '') { + echo '
    '.$row['desc'].''; + } + + echo '
    '; + echo array_key_exists('type', $row) ? wp_editor( $row['content'] , $row['id'] , array( 'editor_class' => 'delibera-config-mensagem') ): $row['content']; + echo '
    '; + + if (isset($row['id']) && $row['id'] != '') { + echo ''; + } else { + echo $row['label']; + } + + if (isset($row['desc']) && $row['desc'] != '') { + echo '
    '.$row['desc'].''; + } + + echo '
    '; + echo array_key_exists('type', $row) ? wp_editor( $row['content'] , $row['id'] , array( 'editor_class' => 'delibera-config-mensagem') ): $row['content']; + echo '
    '; + + if (isset($row['id']) && $row['id'] != '') { + echo ''; + } else { + echo $row['label']; + } + + if (isset($row['desc']) && $row['desc'] != '') { + echo '
    '.$row['desc'].''; + } + + echo '
    '; + echo array_key_exists('type', $row) ? wp_editor( $row['content'] , $row['id'] , array( 'editor_class' => 'delibera-config-mensagem') ): $row['content']; + echo '
    '; + echo '
    '; + echo '
    '; + ?> + + + - - + ".$label."
    "; - + $rows2 = array(); - + $rows2[] = array( - "id" => "mensagem_{$tipo}_assunto".$lang, - "row-id" => "row-mensagem_{$tipo}_assunto".$lang, - "label" => __('Assunto da mensagem padrão de notificação de ' . $label . ':', 'delibera'), - "content" => '' - ); + "id" => "mensagem_{$tipo}_assunto".$lang, + "row-id" => "row-mensagem_{$tipo}_assunto".$lang, + "label" => __('Assunto da mensagem padrão de notificação de ' . $label . ':', 'delibera'), + "content" => '' + ); $rows2[] = array( - "id" => "mensagem_{$tipo}".$lang, - "row-id" => "row-mensagem_{$tipo}".$lang, - "label" => __('Mensagem padrão de notificação de ' . $label . ':', 'delibera'), - "content" => '' - ); - + "id" => "mensagem_{$tipo}".$lang, + "row-id" => "row-mensagem_{$tipo}".$lang, + "label" => __('Mensagem padrão de notificação de ' . $label . ':', 'delibera'), + "content" => htmlspecialchars_decode($opt['mensagem_'.$tipo.$lang]), + "type" => 'wp_editor' + ); + $rows[] = $rows2; } function delibera_nofiticar_config_page_campos($opt, $lang = '') { if($lang != '') $lang = "-".$lang; - + $rows = array(); - + foreach (delibera_nofiticar_get_tipos() as $notif) { delibeta_nofiticar_config_page_row($rows, $opt, $notif['tipo'], $notif['dica'], $lang); } - + return $rows; } @@ -238,37 +981,37 @@ function delibera_nofiticar_config_page() { $table = ''; $opt = delibera_get_config(); - + $rows = array(); $rows[] = array( - "id" => "notificacoes", - "label" => __('Permitir notificações por e-mail?','delibera'), - "content" => '' - ); + "id" => "notificacoes", + "label" => __('Permitir notificações por e-mail?','delibera'), + "content" => '' + ); $table .= delibera_form_table($rows); $rows_lang = array(); - + if(function_exists('qtrans_enableLanguage')) { $head = "
    "; global $q_config; - + foreach ($q_config['enabled_languages'] as $lang) { $display = "none"; $ativa = ""; - + if($lang == $q_config['default_language']) { $display = "block"; $ativa = "active"; } - + $onclick="switch_mensagem_box('".$lang."');"; $head .= ''; - + $rows_lang[$lang] = delibera_nofiticar_config_page_campos($opt, $lang); - + if($lang == $q_config['default_language']) { $rows_lang[$lang]['default'] = true; @@ -278,48 +1021,50 @@ function delibera_nofiticar_config_page() } else { - + $lang = get_locale(); - + $display = "block"; $ativa = "active"; - + $rows_lang[$lang] = delibera_nofiticar_config_page_campos($opt, $lang); - + $rows_lang[$lang]['default'] = true; - + $table; } $table .= '
    '; $rows = array(); $i = 0; - + foreach (delibera_nofiticar_get_tipos() as $notif) { delibera_nofiticar_config_page_create_checkbox($rows, - "{$notif['mensagem']}-enabled", - $notif['dica_permicao'], - $opt, - $rows_lang, $i++ - ); + "{$notif['mensagem']}-enabled", + $notif['dica_permicao'], + $opt, + $rows_lang, $i++ + ); } - + echo '
    ';	
    +	print_r($rows);
    +	echo '
    '; $table .= delibera_form_table($rows); $table .= '
    '; - + return $table; } function delibera_nofiticar_config_page_create_checkbox(&$rows, $id, $label, $opt, $rows_lang, $index) { $rows[] = array( - "id" => $id, - "label" => $label, - "content" => '' - ); - - + "id" => $id, + "label" => $label, + "content" => '' + ); + + foreach($rows_lang as $lang => $row_lang) { $active = false; @@ -354,31 +1099,31 @@ function delibera_notificar_get_mensagem_link($post, $link = false) function delibera_notificar_nova_pauta($post = false) { - $message = ''; - delibera_notificar_representantes($message, 'mensagem_criacao_pauta', $post); + $message = ''; + delibera_notificar_representantes($message, 'mensagem_criacao_pauta', $post); } function delibera_notificar_situacao($post = false) { - /*$message = 'Situação: '.delibera_get_situacao($post)->name; - delibera_notificar_representantes($message, 'mensagem_mudanca_situacao', $post);*/ + /*$message = 'Situação: '.delibera_get_situacao($post)->name; + delibera_notificar_representantes($message, 'mensagem_mudanca_situacao', $post);*/ } function delibera_notificar_nova_validacao($post = false) { - delibera_notificar_representantes('', 'validacao', $post); + delibera_notificar_representantes('', 'validacao', $post); } add_action('delibera_validacao', 'delibera_notificar_nova_validacao'); function delibera_notificar_pauta_recusada($post = false) { - delibera_notificar_representantes('', 'pauta_recusada', $post); + delibera_notificar_representantes('', 'pauta_recusada', $post); } add_action('delibera_pauta_recusada', 'delibera_notificar_pauta_recusada'); function delibera_notificar_validacao_concluida($post = false) { - delibera_notificar_representantes('', 'validacao_concluida', $post); + delibera_notificar_representantes('', 'validacao_concluida', $post); } add_action('delibera_validacao_concluida', 'delibera_notificar_validacao_concluida'); @@ -415,10 +1160,10 @@ function delibera_notificar_fim_prazo($args) { $post = get_post($post); } - $message = ''; - $situacao = delibera_get_situacao($post->ID); - - delibera_notificar_representantes($message, "mensagem_fim_prazo_{$situacao->slug}", $post); + $message = ''; + $situacao = delibera_get_situacao($post->ID); + + delibera_notificar_representantes($message, "mensagem_fim_prazo_{$situacao->slug}", $post); } function delibera_notificar_representantes($mensage, $tipo, $post = false, $users = false, $link = false) { @@ -429,62 +1174,62 @@ function delibera_notificar_representantes($mensage, $tipo, $post = false, $user { $post = get_post(); } - + if(is_numeric($post)) { $post = get_post($post); } - + if($post->post_status == 'publish') { - + $options_plugin_delibera = delibera_get_config(); - + if( - $options_plugin_delibera["notificacoes"] == "N" || // Notificações estão desabilitadas OU - !array_key_exists("$tipo-enabled", $options_plugin_delibera) || - $options_plugin_delibera["$tipo-enabled"] == "N" // Esse tipo de notificação está desabilitada - ) + $options_plugin_delibera["notificacoes"] == "N" || // Notificações estão desabilitadas OU + !array_key_exists("$tipo-enabled", $options_plugin_delibera) || + $options_plugin_delibera["$tipo-enabled"] == "N" // Esse tipo de notificação está desabilitada + ) { return false; } $subject_default = htmlspecialchars_decode($options_plugin_delibera["{$tipo}_assunto"]); $mensage_default = htmlspecialchars_decode($options_plugin_delibera[$tipo]).$mensage.delibera_notificar_get_mensagem_link($post, $link); - + if(!is_array($users)) { $users = get_users(); } - + if(!is_array($users)) { $users = array(); } - + $autor_id = get_current_user_id(); - + $seguiram = delibera_get_quem_seguiu($post->ID, 'ids'); - + foreach ($users as $user) { if(user_can($user->ID, 'votar') && isset($user->user_email) && $user->ID != $autor_id) { $segue = array_search($user->ID, $seguiram); - + $user_notificacoes = get_user_meta($user->ID, 'delibera_notificacoes_email', true); - + if(!$segue && ($user_notificacoes == "N" || get_user_meta($user->ID, "$tipo-enabled", true) == "N")) { continue; } - + $mensage_tmp = $mensage_default; $subject_tmp = $subject_default; - + $lang = get_user_meta($user->ID, 'user_idioma', true); - + if(strlen($lang) == 0) $lang = defined('WPLANG') && strlen(WPLANG) > 0 ? WPLANG : get_locale(); - + if(array_key_exists("$tipo-$lang", $options_plugin_delibera)) { $mensage_tmp = htmlspecialchars_decode($options_plugin_delibera["$tipo-$lang"]).$mensage; @@ -493,14 +1238,14 @@ function delibera_notificar_representantes($mensage, $tipo, $post = false, $user { $subject_tmp = htmlspecialchars_decode($options_plugin_delibera["{$tipo}_assunto-$lang"]); } - + $subject_tmp = delibera_notificar_replace_vars($subject_tmp, $user, $post); $mensage_tmp = delibera_notificar_replace_vars($mensage_tmp, $user, $post); wp_mail($user->user_email, $subject_tmp, $mensage_tmp); } } } - + } function delibera_notificar_novo_comentario($comment) @@ -512,9 +1257,9 @@ function delibera_notificar_novo_comentario($comment) } $seguiram = get_post_meta($comment->comment_post_ID, 'delibera_seguiram', true); $users = array(); - + if(!is_array($seguiram)) $seguiram = array(); // Ops, não tem o plugin ou não tem seguidores - + foreach ($seguiram as $hora => $seguiram) { foreach ($seguiram as $user) @@ -525,16 +1270,16 @@ function delibera_notificar_novo_comentario($comment) } } } - + $autor = get_user_by('id', $post->post_author); - + $users = is_array($users) ? array_merge($users, array($autor)) : array($autor); - + $mensage = '
    '.__('Autor', 'delibera').": ".$autor->display_name.'
    '; $mensage .= get_comment_text($comment->comment_ID)."
    "; - + $link = delibera_get_comment_link($comment); - + delibera_notificar_representantes($mensage, "mensagem_novo_comentario", $post, $users, $link); } @@ -546,13 +1291,13 @@ function delibera_notificar_replace_vars($subject, $user, $postReport) { $postReport = get_post($postReport); } - + $post = $postReport; - + $opt = delibera_get_config(); - + $author = get_user_by('id', $post->post_author); - + $subject = str_ireplace("{first_name}", $user->user_firstname, $subject); $subject = str_ireplace("{last_name}", $user->user_lastname, $subject); $subject = str_ireplace("{display_name}", $user->display_name, $subject); @@ -566,7 +1311,7 @@ function delibera_notificar_replace_vars($subject, $user, $postReport) $subject = str_ireplace("{post_author}", $author->user_firstname, $subject); $subject = str_ireplace("{post_content}", get_the_content(), $subject); $subject = str_ireplace("{post_excerpt}", get_the_excerpt(), $subject); - + $campos = delibera_get_user_campos_form_registro(); if($campos > 0) { @@ -599,7 +1344,7 @@ function delibera_notificar_replace_vars($subject, $user, $postReport) $valor_replace = $desc; } } - break; + break; case 'CheckBox': $valor = true; if(is_array($campo['dados']) && count($campo['dados']) > 0) @@ -629,11 +1374,11 @@ function delibera_notificar_replace_vars($subject, $user, $postReport) { $valor_replace = __("Não", 'delibera'); } - break; + break; case 'Texto': default: - $valor_replace = ( get_user_meta( $user->ID,$campo['id'], true ) ); - break; + $valor_replace = ( get_user_meta( $user->ID,$campo['id'], true ) ); + break; } } $subject = str_ireplace("{".$campo['id']."}", $valor_replace, $subject); @@ -645,143 +1390,143 @@ function delibera_notificar_replace_vars($subject, $user, $postReport) function delibera_nofiticar_get_tipos() { return array( - array( - 'tipo' => 'criacao_pauta', - 'mensagem' => 'mensagem_criacao_pauta', - 'dica' => __('criação de pauta', 'delibera'), - 'dica_permicao' => __('Permitir notificações na criação de uma pauta?', 'delibera'), - 'user_panel_text' => __('Receber mensagem de criação de novas pautas?', 'delibera') - ), - array( - 'tipo' => 'validacao', - 'mensagem' => 'mensagem_validacao', - 'dica' => __('quando a pauta recebe uma validação', 'delibera'), - 'dica_permicao' => __('Permitir notificações de cada validação de uma pauta?', 'delibera'), - 'user_panel_text' => __('Receber mensagem para cada validação de uma pauta?', 'delibera') - ), - array( - 'tipo' => 'validacao_concluida', - 'mensagem' => 'mensagem_validacao_concluida', - 'dica' => __('quando a pauta é validada', 'delibera'), - 'dica_permicao' => __('Permitir notificações quando a pauta é validada?', 'delibera'), - 'user_panel_text' => __('Receber mensagem quando uma pauta for aprovada?', 'delibera') - ), - array( - 'tipo' => 'pauta_recusada', - 'mensagem' => 'mensagem_pauta_recusada', - 'dica' => __('quando a pauta é recusada (não obteve validações necessárias)', 'delibera'), - 'dica_permicao' => __('Permitir notificações quando a pauta é recusada?', 'delibera'), - 'user_panel_text' => __('Receber mensagem quando uma pauta for recusada?', 'delibera') - ), - array( - 'tipo' => 'fim_prazo_validacao', - 'mensagem' => 'mensagem_fim_prazo_validacao', - 'dica' => __('', 'delibera'), - 'dica_permicao' => __('Permitir notificações quando o fim do prazo para validações estiver próximo?', 'delibera'), - 'user_panel_text' => __('Receber mensagem quando o fim do prazo para validações estiver próximo?', 'delibera') - ), - array( - 'tipo' => 'novo_comentario', - 'mensagem' => 'mensagem_novo_comentario', - 'dica' => __('novo comentário', 'delibera'), - 'dica_permicao' => __('Permitir notificações quando houver interações na discussão de uma pauta?', 'delibera'), - 'user_panel_text' => __('Receber mensagem quando houver interações na discussão de uma pauta?', 'delibera') - ), - array( - 'tipo' => 'discussao_concluida', - 'mensagem' => 'mensagem_discussao_concluida', - 'dica' => __('', 'delibera'), - 'dica_permicao' => __('Permitir notificações quando a discussão for encerrada?', 'delibera'), - 'user_panel_text' => __('Receber mensagem quando a discussão for encerrada?', 'delibera') - ), - array( - 'tipo' => 'fim_prazo_discussao', - 'mensagem' => 'mensagem_fim_prazo_discussao', - 'dica' => __('', 'delibera'), - 'dica_permicao' => __('Permitir notificações quando o fim do prazo para discussão estiver próximo?', 'delibera'), - 'user_panel_text' => __('Receber mensagem quando o fim do prazo para discussão estiver próximo?', 'delibera') - ), - array( - 'tipo' => 'discussao_concluida_rel', - 'mensagem' => 'mensagem_discussao_concluida_rel', - 'dica' => __('', 'delibera'), - 'dica_permicao' => __('Permitir notificações quando a discussão for encerrada?', 'delibera'), - 'user_panel_text' => __('Receber mensagem quando a discussão for encerrada?', 'delibera') - ), - array( - 'tipo' => 'relatoria_concluida', - 'mensagem' => 'mensagem_relatoria_concluida', - 'dica' => __('', 'delibera'), - 'dica_permicao' => __('Permitir notificações quando a relatoria for encerrada?', 'delibera'), - 'user_panel_text' => __('Receber mensagem quando a relatoria for encerrada?', 'delibera') - ), - array( - 'tipo' => 'fim_prazo_relatoria', - 'mensagem' => 'mensagem_fim_prazo_relatoria', - 'dica' => __('', 'delibera'), - 'dica_permicao' => __('Permitir notificações quando o fim do prazo para relatoria estiver próximo?', 'delibera'), - 'user_panel_text' => __('Receber mensagem quando o fim do prazo para relatoria estiver próximo?', 'delibera') - ), - array( - 'tipo' => 'fim_prazo_votacao', - 'mensagem' => 'mensagem_fim_prazo_votacao', - 'dica' => __('', 'delibera'), - 'dica_permicao' => __('Permitir notificações quando o fim do prazo para votação estiver próximo?', 'delibera'), - 'user_panel_text' => __('Receber mensagem quando o fim do prazo para votação estiver próximo?', 'delibera') - ), - array( - 'tipo' => 'votacao_concluida', - 'mensagem' => 'mensagem_votacao_concluida', - 'dica' => __('', 'delibera'), - 'dica_permicao' => __('Permitir notificações quando a votação for encerrada?', 'delibera'), - 'user_panel_text' => __('Receber mensagem quando a votação for encerrada?', 'delibera') - ) - ); + array( + 'tipo' => 'criacao_pauta', + 'mensagem' => 'mensagem_criacao_pauta', + 'dica' => __('criação de pauta', 'delibera'), + 'dica_permicao' => __('Permitir notificações na criação de uma pauta?', 'delibera'), + 'user_panel_text' => __('Receber mensagem de criação de novas pautas?', 'delibera') + ), + array( + 'tipo' => 'validacao', + 'mensagem' => 'mensagem_validacao', + 'dica' => __('quando a pauta recebe uma validação', 'delibera'), + 'dica_permicao' => __('Permitir notificações de cada validação de uma pauta?', 'delibera'), + 'user_panel_text' => __('Receber mensagem para cada validação de uma pauta?', 'delibera') + ), + array( + 'tipo' => 'validacao_concluida', + 'mensagem' => 'mensagem_validacao_concluida', + 'dica' => __('quando a pauta é validada', 'delibera'), + 'dica_permicao' => __('Permitir notificações quando a pauta é validada?', 'delibera'), + 'user_panel_text' => __('Receber mensagem quando uma pauta for aprovada?', 'delibera') + ), + array( + 'tipo' => 'pauta_recusada', + 'mensagem' => 'mensagem_pauta_recusada', + 'dica' => __('quando a pauta é recusada (não obteve validações necessárias)', 'delibera'), + 'dica_permicao' => __('Permitir notificações quando a pauta é recusada?', 'delibera'), + 'user_panel_text' => __('Receber mensagem quando uma pauta for recusada?', 'delibera') + ), + array( + 'tipo' => 'fim_prazo_validacao', + 'mensagem' => 'mensagem_fim_prazo_validacao', + 'dica' => __('', 'delibera'), + 'dica_permicao' => __('Permitir notificações quando o fim do prazo para validações estiver próximo?', 'delibera'), + 'user_panel_text' => __('Receber mensagem quando o fim do prazo para validações estiver próximo?', 'delibera') + ), + array( + 'tipo' => 'novo_comentario', + 'mensagem' => 'mensagem_novo_comentario', + 'dica' => __('novo comentário', 'delibera'), + 'dica_permicao' => __('Permitir notificações quando houver interações na discussão de uma pauta?', 'delibera'), + 'user_panel_text' => __('Receber mensagem quando houver interações na discussão de uma pauta?', 'delibera') + ), + array( + 'tipo' => 'discussao_concluida', + 'mensagem' => 'mensagem_discussao_concluida', + 'dica' => __('', 'delibera'), + 'dica_permicao' => __('Permitir notificações quando a discussão for encerrada?', 'delibera'), + 'user_panel_text' => __('Receber mensagem quando a discussão for encerrada?', 'delibera') + ), + array( + 'tipo' => 'fim_prazo_discussao', + 'mensagem' => 'mensagem_fim_prazo_discussao', + 'dica' => __('', 'delibera'), + 'dica_permicao' => __('Permitir notificações quando o fim do prazo para discussão estiver próximo?', 'delibera'), + 'user_panel_text' => __('Receber mensagem quando o fim do prazo para discussão estiver próximo?', 'delibera') + ), + array( + 'tipo' => 'discussao_concluida_rel', + 'mensagem' => 'mensagem_discussao_concluida_rel', + 'dica' => __('', 'delibera'), + 'dica_permicao' => __('Permitir notificações quando a discussão for encerrada?', 'delibera'), + 'user_panel_text' => __('Receber mensagem quando a discussão for encerrada?', 'delibera') + ), + array( + 'tipo' => 'relatoria_concluida', + 'mensagem' => 'mensagem_relatoria_concluida', + 'dica' => __('', 'delibera'), + 'dica_permicao' => __('Permitir notificações quando a relatoria for encerrada?', 'delibera'), + 'user_panel_text' => __('Receber mensagem quando a relatoria for encerrada?', 'delibera') + ), + array( + 'tipo' => 'fim_prazo_relatoria', + 'mensagem' => 'mensagem_fim_prazo_relatoria', + 'dica' => __('', 'delibera'), + 'dica_permicao' => __('Permitir notificações quando o fim do prazo para relatoria estiver próximo?', 'delibera'), + 'user_panel_text' => __('Receber mensagem quando o fim do prazo para relatoria estiver próximo?', 'delibera') + ), + array( + 'tipo' => 'fim_prazo_votacao', + 'mensagem' => 'mensagem_fim_prazo_votacao', + 'dica' => __('', 'delibera'), + 'dica_permicao' => __('Permitir notificações quando o fim do prazo para votação estiver próximo?', 'delibera'), + 'user_panel_text' => __('Receber mensagem quando o fim do prazo para votação estiver próximo?', 'delibera') + ), + array( + 'tipo' => 'votacao_concluida', + 'mensagem' => 'mensagem_votacao_concluida', + 'dica' => __('', 'delibera'), + 'dica_permicao' => __('Permitir notificações quando a votação for encerrada?', 'delibera'), + 'user_panel_text' => __('Receber mensagem quando a votação for encerrada?', 'delibera') + ) + ); } function delibera_nofitica_user_panel($forms) { /*$campos = array( - array( - 'novo' => true, - 'id' => 'mensagem_criacao_pauta-enabled', - 'nome' => __('Receber mensagem de criação de novas pauta?', 'delibera'), - 'registro' => false, - 'tipo_painel' => 'CheckBox', - 'dados' => array("S" => "S", "N" => "N") - ), - array( - 'novo' => true, - 'id' => 'mensagem_mudanca_situacao-enabled', - 'nome' => __('Receber mensagem nova situação das pautas?', 'delibera'), - 'registro' => false, - 'tipo_painel' => 'CheckBox', - 'dados' => array("S" => "S", "N" => "N") - ), - array( - 'novo' => true, - 'id' => 'mensagem_fim_prazo-enabled', - 'nome' => __('Receber mensagem fim de prazo próximo?', 'delibera'), - 'registro' => false, - 'tipo_painel' => 'CheckBox', - 'dados' => array("S" => "S", "N" => "N") - ) - );*/ + array( + 'novo' => true, + 'id' => 'mensagem_criacao_pauta-enabled', + 'nome' => __('Receber mensagem de criação de novas pauta?', 'delibera'), + 'registro' => false, + 'tipo_painel' => 'CheckBox', + 'dados' => array("S" => "S", "N" => "N") + ), + array( + 'novo' => true, + 'id' => 'mensagem_mudanca_situacao-enabled', + 'nome' => __('Receber mensagem nova situação das pautas?', 'delibera'), + 'registro' => false, + 'tipo_painel' => 'CheckBox', + 'dados' => array("S" => "S", "N" => "N") + ), + array( + 'novo' => true, + 'id' => 'mensagem_fim_prazo-enabled', + 'nome' => __('Receber mensagem fim de prazo próximo?', 'delibera'), + 'registro' => false, + 'tipo_painel' => 'CheckBox', + 'dados' => array("S" => "S", "N" => "N") + ) + );*/ if(!is_array($forms)) $forms = array(); - + foreach (delibera_nofiticar_get_tipos() as $notif) { $forms[] = array( - 'novo' => true, - 'id' => $notif['mensagem'].'-enabled', - 'nome' => $notif['user_panel_text'], - 'registro' => false, - 'tipo_painel' => 'CheckBox', - 'dados' => array("S" => "S", "N" => "N"), - 'default' => 'S' - ); - } - + 'novo' => true, + 'id' => $notif['mensagem'].'-enabled', + 'nome' => $notif['user_panel_text'], + 'registro' => false, + 'tipo_painel' => 'CheckBox', + 'dados' => array("S" => "S", "N" => "N"), + 'default' => 'S' + ); + } + return $forms; } add_filter('delibera_user_painel_campos', 'delibera_nofitica_user_panel', 10, 1) diff --git a/delibera_utils.php b/delibera_utils.php index ec9dae4..c042b2e 100644 --- a/delibera_utils.php +++ b/delibera_utils.php @@ -185,4 +185,4 @@ function delibera_ultimas($tipo = 'pauta', $args = array(), $count = 5) return delibera_wp_get_comments($filtro); break; } -} \ No newline at end of file +} From 14f7127c89903059f2617e65a8c582c968c75e0c Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Mon, 14 Mar 2016 02:22:42 -0300 Subject: [PATCH 093/435] fontrello example to use in delibera --- css/fonts/fontello-051a52f4/LICENSE.txt | 30 ++ css/fonts/fontello-051a52f4/README.txt | 75 ++++ css/fonts/fontello-051a52f4/config.json | 118 +++++++ css/fonts/fontello-051a52f4/css/animation.css | 85 +++++ .../fontello-051a52f4/css/delibera-codes.css | 19 + .../css/delibera-embedded.css | 72 ++++ .../css/delibera-ie7-codes.css | 19 + .../fontello-051a52f4/css/delibera-ie7.css | 30 ++ css/fonts/fontello-051a52f4/css/delibera.css | 75 ++++ css/fonts/fontello-051a52f4/demo.html | 334 ++++++++++++++++++ css/fonts/fontello-051a52f4/font/delibera.eot | Bin 0 -> 9012 bytes css/fonts/fontello-051a52f4/font/delibera.svg | 46 +++ css/fonts/fontello-051a52f4/font/delibera.ttf | Bin 0 -> 8844 bytes .../fontello-051a52f4/font/delibera.woff | Bin 0 -> 5536 bytes .../fontello-051a52f4/font/delibera.woff2 | Bin 0 -> 4652 bytes 15 files changed, 903 insertions(+) create mode 100644 css/fonts/fontello-051a52f4/LICENSE.txt create mode 100644 css/fonts/fontello-051a52f4/README.txt create mode 100644 css/fonts/fontello-051a52f4/config.json create mode 100644 css/fonts/fontello-051a52f4/css/animation.css create mode 100644 css/fonts/fontello-051a52f4/css/delibera-codes.css create mode 100644 css/fonts/fontello-051a52f4/css/delibera-embedded.css create mode 100644 css/fonts/fontello-051a52f4/css/delibera-ie7-codes.css create mode 100644 css/fonts/fontello-051a52f4/css/delibera-ie7.css create mode 100644 css/fonts/fontello-051a52f4/css/delibera.css create mode 100644 css/fonts/fontello-051a52f4/demo.html create mode 100644 css/fonts/fontello-051a52f4/font/delibera.eot create mode 100644 css/fonts/fontello-051a52f4/font/delibera.svg create mode 100644 css/fonts/fontello-051a52f4/font/delibera.ttf create mode 100644 css/fonts/fontello-051a52f4/font/delibera.woff create mode 100644 css/fonts/fontello-051a52f4/font/delibera.woff2 diff --git a/css/fonts/fontello-051a52f4/LICENSE.txt b/css/fonts/fontello-051a52f4/LICENSE.txt new file mode 100644 index 0000000..2e7737a --- /dev/null +++ b/css/fonts/fontello-051a52f4/LICENSE.txt @@ -0,0 +1,30 @@ +Font license info + + +## Fontelico + + Copyright (C) 2012 by Fontello project + + Author: Crowdsourced, for Fontello project + License: SIL (http://scripts.sil.org/OFL) + Homepage: http://fontello.com + + +## Font Awesome + + Copyright (C) 2012 by Dave Gandy + + Author: Dave Gandy + License: SIL () + Homepage: http://fortawesome.github.com/Font-Awesome/ + + +## Entypo + + Copyright (C) 2012 by Daniel Bruce + + Author: Daniel Bruce + License: SIL (http://scripts.sil.org/OFL) + Homepage: http://www.entypo.com + + diff --git a/css/fonts/fontello-051a52f4/README.txt b/css/fonts/fontello-051a52f4/README.txt new file mode 100644 index 0000000..beaab33 --- /dev/null +++ b/css/fonts/fontello-051a52f4/README.txt @@ -0,0 +1,75 @@ +This webfont is generated by http://fontello.com open source project. + + +================================================================================ +Please, note, that you should obey original font licenses, used to make this +webfont pack. Details available in LICENSE.txt file. + +- Usually, it's enough to publish content of LICENSE.txt file somewhere on your + site in "About" section. + +- If your project is open-source, usually, it will be ok to make LICENSE.txt + file publicly available in your repository. + +- Fonts, used in Fontello, don't require a clickable link on your site. + But any kind of additional authors crediting is welcome. +================================================================================ + + +Comments on archive content +--------------------------- + +- /font/* - fonts in different formats + +- /css/* - different kinds of css, for all situations. Should be ok with + twitter bootstrap. Also, you can skip style and assign icon classes + directly to text elements, if you don't mind about IE7. + +- demo.html - demo file, to show your webfont content + +- LICENSE.txt - license info about source fonts, used to build your one. + +- config.json - keeps your settings. You can import it back into fontello + anytime, to continue your work + + +Why so many CSS files ? +----------------------- + +Because we like to fit all your needs :) + +- basic file, .css - is usually enough, it contains @font-face + and character code definitions + +- *-ie7.css - if you need IE7 support, but still don't wish to put char codes + directly into html + +- *-codes.css and *-ie7-codes.css - if you like to use your own @font-face + rules, but still wish to benefit from css generation. That can be very + convenient for automated asset build systems. When you need to update font - + no need to manually edit files, just override old version with archive + content. See fontello source code for examples. + +- *-embedded.css - basic css file, but with embedded WOFF font, to avoid + CORS issues in Firefox and IE9+, when fonts are hosted on the separate domain. + We strongly recommend to resolve this issue by `Access-Control-Allow-Origin` + server headers. But if you ok with dirty hack - this file is for you. Note, + that data url moved to separate @font-face to avoid problems with + + + + + + + +
    +

    + delibera + font demo +

    + +
    +
    +
    +
    delibera-icon-spin20xe800
    +
    delibera-icon-ok0xe801
    +
    delibera-icon-plus0xe802
    +
    delibera-icon-thumbs-up-alt0xe803
    +
    +
    +
    delibera-icon-thumbs-down-alt0xe804
    +
    delibera-icon-print0xe805
    +
    delibera-icon-down-open0xe806
    +
    delibera-icon-left-open0xe807
    +
    +
    +
    delibera-icon-right-open0xe808
    +
    delibera-icon-up-open0xe809
    +
    delibera-icon-reply0xe80a
    +
    delibera-icon-trash0xe80b
    +
    +
    +
    delibera-icon-attach0xe80c
    +
    delibera-icon-users0xe80d
    +
    delibera-icon-chat0xe80e
    +
    delibera-icon-calendar0xe80f
    +
    +
    +
    delibera-icon-newspaper0xe810
    +
    delibera-icon-key0xe811
    +
    +
    + + + \ No newline at end of file diff --git a/css/fonts/fontello-051a52f4/font/delibera.eot b/css/fonts/fontello-051a52f4/font/delibera.eot new file mode 100644 index 0000000000000000000000000000000000000000..e6a64fd43d6c8cd27eec15ef8ebbc7537f097ef8 GIT binary patch literal 9012 zcmd^EeQ+Dcb>F=^96kwvAaJAz54ZL{b#V zkd!Q?QIbiVjKe0D)5*AQ-8g2)X){im9w^62I{w4cIvF>e{*h)zacA02(ljm7PMS_8 z?WC#&_P2*4^5c25|A(U{0{WxOcbpV*>D1*i)s{K2) zjz*Wh^6Fc6u)C0(%#c~KL>9<7v}>e@0VkORe4bnaz6cy45;>)hu7hrcEEAb@lQ`+Z z$b;qs%@%c$j}o4&j-EJ~(JD873e3AGnMY4_CI;n)RS>1oKQ(=^xcWN>fBISUU%-ye zPG8=TfyYn!94gz~>iLV$Joj84{g(-`ubwZiuLAEz|I=tK=a;U|efdYF&lAG`l8~BT z&d(NStWW;S2MDSCPmHJLfiQoV{{kVNcJy24FK%4P+}`;)`s3)2FRe@$TUtZg=wp4- zezACEm3+tHNB>Rq<>lhV*{Oxk{xAAJfP84vmaY5epH3XFsMDy0mb<2%OQw7#pR)P$C*w^!ZQH=ZFdGeUN(t z*iTnm`UBEUVfs6E$Jjl;iMin!k}i{SEkC)lNKW%P@;nIG%GDou!YTyP5wce} z%cxYeHXSdJA)Q8G_;T&e4r;<`^s6#+pcNpcNX(Gmig|Y8AT@9x7wl6@JRoIz`v3lO z=n5zsYJgT4sCSuWjlx2@Y!qgpvQe0>%SK@yQ8o(mma2r*R_yCeELh zpNl$aL=kn0P$!MkzP9cjkYZN7B$^|kaK!j`n1WqhcUQM)u9Am4IeiVVO7+wyBp+pi zN+`k>PadWz#s>fT5-k+0Lj(XBD^!f#b|}-r}g^%@cx^r&oOYnx*Uu$8EHQ zT7>pSXU~)EyoG;Mpgeb+HZ-~e{o`&7e)o1qX#*Q;NI^| zobR%j`gsn54bnP~*B)-Ma(3>lAW)98M1vf6fU^l1r^nHl{N%XFOsPpQxA?7R`vvP6 z!NlDz2mEsV$Opn4Sez9soXubJ@OcXrO_eoXupaK^t-?W$@@}(J>=Z3$Kmo_ZAJWAu z+zZ4<#2d8&jYX-~OvO-y>NTwq*N$!g5a#4wO z-R>{a6*pSO7QA=|q%>TMzNHQ{t~-Jqu|dCyDLrM-W<<~;DazS`s<$DEYw8{~Tu0YR+y!i$}p z8I!I{&0dOf+UtJV1<3ibOX5D)Vx{}6R;y%^TaO)WJC*1du5(G$>p##G_Sl@FNf6yW z*S?MhuSMiIhs6Om<6n%XXBY>@kE)dyb#8RliFvLrWuK=bB!^mjhr?0oak?6?l0KGJ zx;?g#w?S$MNe)kAV^f3Gr%GPI;S|$`9v1m)++XT?H~~G3#(gy+2R+nz#W(+b(cKh(+szz3d+x@DL4B-8-Z~+NXOaDkaD~ zQ}iU50mFGdpNH+A90# zQ}rp=Nmx#a4VtgtyeUih%2O^c*U;D?xNFO18wC#_9b#EcQ`#lT4bGG9lyrR%dtmYN zul(!We&R*^Aiu<-*1ICJ-dc@JFaPDrIa|P1IcK+@u?K9lownPX9B1tGdS%*fr=JJz zjNM*&2WSv9>3rYhUf{DjUzeHjh%vmW(*23zhkdsFO;H+>0Vg1Sflwo$hBl zuwwy6XymBZxsj^8jBlG6vNC1p%pox2%YT_|AJV;JaDR#MddYs_3?$tTnIU~uT%E11 zhZ0}r<0K0GDohV;UKfX>0>+2Gr+Sldlb*8n^diCha=pZtM@2JS+GC-}sNPWj;Hgu6 z*SxZ|@*`}j+1}K^U8B#Q4*c+mFVxgp1e?QR^77%9{?qBMfJeOUlB7m{N&3j+>|8yOPIg5Vf1RDjx!Q)Hjna_lL(n2yrjVn4WuNvSc5$|v z;LuTu#HV|8t?u(I-{O4kgEO~KR1n3|YO(3n^*i9RHggqgwpG4+%P*KpqCo%MW=SR6 zDqU?!+RLVVC1O>jZArC6{?uZdq@QBA%2TXdVT8=`7$-C0ApR!|8EtS^ZJ3kl7Oqspth1&)*+<`%pw zcVw);a{Tazv^1SGh1_E0tLnxi?Vu$k-WsQ^l{cJqZpry$vDIbzv67B;hv;zMBS&(5 zbUXcLA39w5s>vNP(G$_BOVP@stzAl7p+in7hcu+=%+rceU$sqYagW9!T8uir(=9uTX3jd7#=mo z&+z(N$y4)Cxw&!nI`V~LB?>Z^0WMhxeva6 zMSS{u(KsFAj~sXVY8o1-F$`Vd9=xORWt>rMWQJ^u9g_|t!%y&Q2$wjjb&v{BAtqk^fv+j@*obS6J} zEZPydf~~T_XT$7plMqgz{Bt=rq%ty{O>+PcN6)@|Cgr8C>Y z0cxv+F}AgJ;VzVVyO*)z{<^s%)s{@QrK)uY`}W!SLtf_Pd$b!tX77ZK_ob!ou9&*N zy{$DUH#hBT@Of+9BC)~Y@ZE5i3VLX5u(r*o^r9T%dVCRp^{n*vG;_h;w%#5e_eRHo z10A=&)IKoK&gE`@iJrYhpL_f5ThGtTJb$aQO4S)&#`usv4%&Brz`b#M=vE@}b|R6O znVA78fJEYXy=MNw;hSoeZ{$yreI$lh=xATs zuLw!uSyQX&55#ftRquU^@xZzsjzxUR_%_KffWjXZOpAuI`k4?y9^3 z)WULcNiJU6m|t02m(%jx%JRnS($Y$NdgbEG?9#%y*|p;2?D&)>bacBL-i2b!}yFc6uW|zp=4;ptJMt^+*;k zk*nk?-X|BJs(G?OWYP}oezXa^O?KmIAmdf@D(V%3Y5{MTMZ9Xts4rp0ygssyei~&? zf7{&9-$R!G$H_G6i|=_Mz4vwW{`b@S`wxCOy`O3nt1jzrtVPH*i#2y;UniHbzXY%w zkdR5arb{K0k^AJ8p$|5;i22i?j_X?40QLaVT<81l4_>t!kL+&spkE!k$Wnots7TG! zLao$B?bJbQ@Y(F5Zdyw{w2pd-X?=BJIl--55LTBit=DYKU%Gg1J$7j|R$SU}8NHd6 zr$;`+Q;+}J2i&zml- z!>NSn`QnCUy0|pEJX2h=F3&!-zFJ(JUE?pzUajtg5{g&LY9t$b(}*f-OGac#wKS`d=c)5pq9@2Wv!n<{rS9HsuC4vw05A3 zo~(7T@h(RB=0r}05Sv9=vrXg*z{qUO#-J2~QU!k@pU?X>8qMbwjZEZb^ZA&@tMag{ z32j9PWXewDG?S9iL?r|9^BOJ0G(lA$mpoH4oy*8bBWVvcs8<;GVLr>b=UhRk_e8M95;t z1$lT=DKbOonj(ItO-=Sg$XzKlzD+3(RhO{8&vdO7voLvYYj;m_FrQH}+jbj2oD2Gu zV7?<5(`wWb#|>*U#i5wyRIveB)*RVmY+nGBOkS&Dy-D}lOv%Bj8dMsUUHs2JWfxJ@b5y`fGeCBh9)ExZ9pYjP4qVqqy>Tmz(9r|tPMgC)`lPmYZVB>+Exg{+BOKn+AsuRZ3Kd_ zwjF}7cE2hQ=ziXzV*l=foP`kz%xFcl+J5F#QB~`RY8?m{6`nc@mwI5lD8+t-<*Hvv z0e^{Uu{|45NmDyC>g&?A9KTyD_YQTca<49D7ij44d&3o3;DKT>Jds}0Q|-{8(qHPN zKJ26$`-Y$ooKk?-7W-pbLXFoC#I&AYM+y&{26+;uAX1wgmq%G-LWK`+ZjLIW$OJj$ zY~(zIYY)YfCD!jn3X$Ob_|r)=Yc@K&8CPU^U=zGjcZTJ7m4_yPC#Yntz=ApbSndWV z^RoX27v>xD8J6HINR?O*D=H%hEm-m1I6+X;Xf=~_*}{yX@!8@GatxO(`T-a62+aHE z6d@9_t};^W_bXUo1p7jxuL6D#SOkKwOei3_p?eb?33>ZINx-p)$!)q2sBw(26n1AV zcu61AfsEBnVM7PX094bjqcsbnSC&VVQMMSf)BrJBsP#>c1Pu6 z8+s38XzysP8tT2yRlqxnZW+iJ(+(ICWOq$dU}x|BTii9}K~<6COlu>^x&!%m3GW67 zyn#J5ta%50Xb-JZ?@qmkW>D37qq`&bFg>hlspuvoWzMpRaD30gFiTvEV*RwPF6Mx{ z+GWnAAS&VrlB$eHkSvg(_dIoXzrWrUM<3)EzlrxTy|KJ9p!EBLciB6bH)PB(W$Y?7 z%l02+nr9*!``Fv^5Vq{A1}Bbk#9>`r>qaaNzYl%{xt4nCv;=5IRV|6;DAU?7^eT_w z%-Yq{!zyz}?I_fGOvQiQ9|151fHGiQ-KIL`5db>oIHSp6=ut+)fC)y!fX5gO111^G zAb=B$h5=KIh5;uT4FgUwnlymlVl)iMF&YNs84UwYGny=b#~BR+&M+DVJi%xfaF)>= z2Jj@KVL*Y=Frdh27;sM2`u5a3%{tmapl5Vw0MM-NPe30+XHM1n_o&aaj!r$VLyUSs zhZyOisy(zvdVzIx(j^^Yq!)FFkuIy+fj!a{*3n5FEK!+IVntB8OZ@POk%0xBG ztj4!aTwzB|jNp>}_9QMK^jRe3>a}{cL`)f67&@x0<(~GNI6bU7#(;P-RBENqJci5S sGr1B!GgJz*-k)1Oitpm|Gt;;+fdqHre2F+ZzCm|Bp$VVC=`ck84=y)ONB{r; literal 0 HcmV?d00001 diff --git a/css/fonts/fontello-051a52f4/font/delibera.svg b/css/fonts/fontello-051a52f4/font/delibera.svg new file mode 100644 index 0000000..515a919 --- /dev/null +++ b/css/fonts/fontello-051a52f4/font/delibera.svg @@ -0,0 +1,46 @@ + + + +Copyright (C) 2016 by original authors @ fontello.com + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/css/fonts/fontello-051a52f4/font/delibera.ttf b/css/fonts/fontello-051a52f4/font/delibera.ttf new file mode 100644 index 0000000000000000000000000000000000000000..621a415e4e470e281ce330a06693a2bafa7d9c2c GIT binary patch literal 8844 zcmd^EeQ+Dcb>F=^96kwvAaJAz54ZL{b#V zkd!Q^QIbiVjKe0D)5*AQ-8g2)X){Th9w^62I{w4cCK)%K{*h)zacA02(ljm7PMS_8 z?WC#&_P2*4E!lE1lYa|wci+B!`}XboTtI{pLR{p-gePlbr%q?J>dl`5^A=k6;Zt47 zA^Aa-5SqdK%*^G|+V33x>8CM&o)GT*%+*a9czmSKptH@dUA+ACv(FYVe~A$L+Qrhw z8t`t+KZ((Darw#lFa4ofeg}KtK_3?jsA0hSsiS_gX5ati^pCiQ6fqDDF z<;`o^JG(!}d;;@{<<*%|TYG2+bDU2)E|;#Yk?%PCn7@v>yi&S6H@*1j|Hb?VkneBS zRyQ{PSz^L@@8@0v_LH@d{($sQ4p?I1fxXXXa(-l%WGbXm&rj_x zk+XcBJO?s%a_s}2unK{6gq=*U8f$C7GAb3LO~(slSf>#fzEZ!ti=MC^^P0>YXaz_q z5;NqtVxOHjNF8y)_HI&7JRoIv`v3lM=nAM9YJgT4s85+@jRvEViqV*bDn?_vt{9DZ zM8#;#TPj9_{z=7X%(p5=gH1@qXw0e=qrpz3Vl-HcRE!4Ok&4k^MN%;u>`5v{W06-e z8f*;Ds5NG7V%ojEyTtzlUe`vBkhA0(d7ij3j;F70%ok4dcld3lc&xuiNziB{-9JPd zlfK3PH9M(Ulo}-$6(iA5Uqeq{x?f+Fd@kywQAN}#LR~aL`@=oGAjPgmNi;`8k*M+S zC_!{yv5PLnPugf3wFn)}&fdp6cnklqKzZ&YZEAK01}5B`Xqp#9 zO6_*ByI|(psMYk}qSavwF6IOqM+1}>+`+o>X5MnaBvwxZ0-*yBed>@POyLBtLvoy7 zvhuB*V4~c!O@poD&yNW_M-Our!F|x1yx46q4e%TU8=?&!uRYRcpEqL$#5AWgaL;>$+E933+ictlf zSqVk@`_M)EQtAF)bcbnDYV`FcCEg=T6r&v=$ z%z5B-{q?CKjyWmUKg9PY1A^G-g%>+HGdA6jTD=tQtk?aL3y||Am&ARh%}Nhgtyak- zx1Ts3K9lSmX>du@>p#>I@z|WANf6yW*MZI^uSMiIhs6Om<6nqnW*G;@kE+!dbZ&Ic ziG8ka<$$L%B!}93Mi6iJu7a8-N}(Qgh+4$7y;E|!L-qqskBv%l zv()Gf*&4drGaN*n$A%`C(?dI>L%wWVD28-}%D1}DYE!`Nx9a#MQEB`8Yka!V4$S?7j^{&WlwALci%YUhQ!4|Mp zFWBwp>;W6?pdI!W$2mK_QJt~d>1TmEXSY}11R4Y_I^Wm1=lPt@*JWmWImwIctVeyn z!It~f{uVpqO<%+z=j_}Ut8Z4n5AZRYjeZUz@PGp~d0*!?_xSF~+l5ThZ#B|MBbB_| z64)^T?X;u%rXlo;Ho90Xfs?((P7ksh*l_?OG;-9d+-OZ+#y4z+tV|g?a|q1%@?T=t zhjecm++Sq8UbJ622T2b?W=LNXS7)p1q0CqK1c^bv3e!W_>*7!J1GHojKEg-78zGKfoNQur+Ev{FUWO7bW(S?20M?s z8b;8@Xh`%SXpt?`$Wgy?PJ0o%sI4YAbc`bL>0Vv0`#j6HsL%ay<~E8BqFCB3Hod#? zHu#LqT*I1e)$iW+3#PIt(0{jC(y4H@JDj3@Y|EFUR#n=OR7>BHEZk68p5-J zN=RV+DHJRuG%re(S9c4PlwRf*yeoffe4u*r=m)e6oic^oV)ZNP<`nIuWhK#`pzYPy zoDFWt`D3x&W%{v_iT8x)NdH5}^8Iut^JgD8TK$U29Wv2VvFR(Z>cj2bNNLc#`+phFz$73yas3fGL{+U$W9-6t78duTkK zp(8?PHW&%>+()N!)u!P|DmdJ7kxuL}P183uWI2;`A5Jtv~_4E9&s(wpqrgc8|$?BuolP9x*f$TskA~m%%bCSE+ z#z~RXK(>XuahNfjuKuj>LGJypUK5}CUMxX}`C}*DzPhF+YAi!ncn9xld<8WsOvZ`j zs}H6_HjceLoD@c8PdvD3AFkealuMgg8Af4F4N<795fwauSDMtud+~0Bk4K`+Gjul? z0#y|6FwfE}m%5Xqr+t1-bRb9to~JD)r&Aa?Nta%^^~%z%$zhYj;!2kM#tf>`Hz7M65G<4OeAvYrL7a;TJsK@hrj{NF(th&K1&&NIy)D zl84C#Q8IGz)cEkw;GuzZs;eU;2U?n&B(KNqbl5B+>Xr+2tG7>KEqd2Tjrrcl_Zh|A z=amrP={-E#*Ke$~(%M?Tkrr5iKTM5hSSxni^&lJD-u~9k&bRh@`ohhdw{~{um$$cX z-MslthuDrXR_kBTQMb0YJvNKN5&*jIt1WN+M{8$i>+w{$J)F9gZdZ^v##%cc-rnAB z-`Uw|-@fzB?c1zt-=W>xIedCSW&&|$0ce}bq)mdJ~ z`mnwZ+P8kdy>@5#b~5=!GMSv6odqd?Wb!$^Xa2$AJJlNB%%33#NF1@y+1lh_vB18x zL{X2}*Cy1tehN=VRg%o<1X73-A;7{Qz#$FrqPIAo&0HN_aLN-7FXy&+Dc9umJhQ&E zvmEeD&ju`bf^m{L=XN$Zy>4!H^V=SW?JpdE+#)yyxAQ`vnSLZWy7Wh0??+x!mxjEm zL$bQfUQ>_5;^y!rk$q1<`{oy4rjNS@|BKjp{p;=b?BAVZS70OiW{B*U$JD~&TmN8> z{yPN`y0HFpp-bmvEb2o8l6XJc^fJNXRH((n)^P&OUkq>?s zxq%A!CQp{g=M9(=H+2~>M__LQ=7EnJumJdo0h@?KA2MJO_!$GXku!9|fbAqg|0=h- z_T>8F#f43|BX>|vcK4*^3s1_cKrOD6mgUlw&4tzV4LKvvudZy)EibPoW>zoH&Mhxq zm|HJR&0V~*Tw33o?u}>W);AVcSLB{V_a16&ZUyw4bF+;5#?_0-&CPjvetq?_JZkWj z*Vb2;=4Lh%3!9s3hq}7%K9A(cDp?~>l6A5ORV|QBB9jha4`NJ`ZqkFNflMxdLI!1x zYLTpv5?KbOM6O`Rg1)kWc?NABvlU?HK(P!sL1xfjCbK$b5xnNWr$nYOUc~-o!0Yc? zeJAx9eb)x0WZY%Qm4I~bq#6U&iou^rFbm3>>>K1NPD?_rO-RV3T-T+N$*9ipZFyzr zgRL!L{|u-Tx>h!UJ%lvZ^`7^GSM9|kdt2S_)4(3GRG=m*QZuzsE45KObNXdyT)waozp@rDEpNJv+3e~QD{O9BTVGt+wCdB< zwYe4R^4$DpoIy6-`*hHZy$of-udK^Ynl{%<8w+A-bF(zFV7jsarxIosN}HCM((>HO zY-!!PGWW#BT4`-=oxe2qWbG!DQ2c6Hi)7<&8c}79oX(FFWO@AS#QDg$CZ0N**HV71 zqfnfew@&9ZE?oMC1tB>zqg?O@gBmGlB&Q7TAS!dkY+R$NCKu=98mG#$viAC|fP$j27_$yzsC?`D**Pv&I^ zu~m{a+ho27jLg<-3`#R7UGx_Vg@RwBu|h%7$Yg%5P>5^1Dv!vT5H3L=Q*JV^nUt(1 zDp`nM&}cEP3916QbdV#&-sR&&gZz7I>GtO<`Q?k$iE|Uz#f9 zl>$~Xr}9|xvr8E#$2F6xnRBrnxRI_J5mP0rK*dV7q;VJKH9CXyHB)C?GpjNa(w>|7 zx~1Y%~21x8XF)`hgFJ7zn{jbuB6`^vVe_bT63<3eK)A%`0m<&iC=#0;Tpiujo} zHQ5g#_oUSLuu>YX9btcu?OHo_Ve|gg?%w2JKBHuJ>^6QRAM`81LT50p)v0BU8_{M< z!*R{2;sUa)IdUi1y#OfLf>y_7Q<&9Z7S~*0WsSoKRX^bF1Ui z`LZxOTxi$o=9Fu3tzI2}BtL$thV%!4Z_x1`wM<;O)A_Q?mD6Y`tGQy#N#VNLvV(PX z=rk(95`1_vUuK>QWo5TuUUqC}P{Fo6*k4;`Tj2X_wSb$9LH@BKjChZ!-ot=pLK+mP z7~V9rLn+n0p+O~O!i`MlHJ6f=M>IQ}(gwQ~vvLu~f7R`#_^mmc-71znVoY0)`9n~X z7k6uj#WkN=rfig;XErvfWuA>qYFS|80kv#mW3yTo+2~ixW;V8{WeXcy)v}e10hMTV zvEM+DHV6^`0~vy_F$h7}7=j>dR3Hc&+aU-W!w`gx5eUM@CDbVN&^bZRlkw~{u0;X`!=AGrgm!7 z*R5+gakp0PUFuThK3&dk(9n^0hbywceZ^vUBE6!g+TkH(pxi}$xJeK04MFd_r3kMr z4aBvinrIx1YrVgY6dpDM@)S%#q_CWj$5>=Sg%56RjVWWu1bO6aFFXQ5i*O!HW0B34)r&YMGqN6=xNV&y{A8W4K(&54c!BV7_xt2_hluDx;+Vzk(A+ zaW4$|Dd2aXLm&vtgaV=)x;Md*khk9<2{@LpIjjqT9%Y23u(!{Gm-I6o$T-~;F?65| zLNxhFv4I4$w^c5NF?$e8`=zyJsCPS8 z5x=A8mVu0M?T{fsZqGDDR(s!h#XVCVRuwtHv^I*YJ6K4R@w)*6Z*U(CYrc&>vX9oO z_qN_cGo)&LvAvahm>yNNbZiTfGH2OBIKJy(m?fdbaDGNt7jwWp?K0<55ETgoNlnIM zNES%Y`<}XY-(T;FWA}56-^BZv-dJ84R0jOPyX+k-7&2y=GWL|3WA_g-%`*{=d+c9% z7+3byf)k}2aoCX1dJu~v?|~mhuBF}vEeV=2RZC$w&a^fHy~?AgS$leVP-X6@9fw*^ zsQ9n@V*thhPzFq>J5S5I}2E>!$ayxzc5j+;3&X@Vw;c|q{{@n6m fd@s&CJ%bk$Nbn{ul!>GB>vZ>Hn(!%9hhg%6JPSP8 literal 0 HcmV?d00001 diff --git a/css/fonts/fontello-051a52f4/font/delibera.woff b/css/fonts/fontello-051a52f4/font/delibera.woff new file mode 100644 index 0000000000000000000000000000000000000000..58cf05dda82925729419161a52adb6ad3bf6b64c GIT binary patch literal 5536 zcmY*d1yCGammMJZAi-sD2n;$%aQEPDK?WJz-C^(m!96$x4K6`~ySoKKu;36RK@w!= z`}W_h-CK3K-#LBmeXqM-Rd-(>b$NLJ5&#jzg#f&N&h+vB&Howy|4`7@l?DKi3=k?W z0@C$QO=s%bTs#OZ9>HZ0&=aS9!*1zh?uyW65j-0JKsJpNIZL+m_M}CO9T6JVe*my{ zwQ)jdz5oDf8UTRp8k3Y{Xk+ey$i)C6JQ)80zKx@wHG&c$QeOiAICs^%4SBXOb1MLV zKn3AJ%n#tlG~0KxMTiJ36v1f`U_=i_DX?|&MARoJL~w2dRHPrDuN+-0|M4v%ILkkv zVWe+#GWSKyOYnf;wEtopNa<|u1OosFL5O<^MXYm5$1eG=tBZ#x06>(B@Z=z{RvtpJ z>*@|e6>c_wSq#oERrl|&7q!d*O=y8P^ft*APH!xX6;X}0USpe zZwR%+rL_)^K?cM!pr`}>&2hHO?d=`!?bR7-j)udF(4~3Bp%5!8C@ z=)ZE_@Vl_GzMO|YXZ!1RzyeO4m?(2!VZjuO8ueHLu+*qf4-&&v3!%&`X}YKZ(nZ~B zedikWazv+us2}9|5*}?F>mLBrKiS0)59a@dZ*GmAod=-;e%_M#1iyF~9sxhxaM(TG zTQ6$@1Aq8biDV0Om3}InV501O9;g0*_LyUutds2W(ENp(Y8A??tHYx7Say4+a(j|* znmU^@XljsHx)BI2Yvs4II(VZf;AoVvBeS-K4c1n9;*1HiZCUI-6J(?(fLD1%GKH<) zj?Odg$|Uj_wK8?tYdIgi@mZt5JFfY2voNcf@C}pc^@k#vlVpy{{t5y)p0nf>evW}9 zvo}WD2W*ppOF*WuL&lWh59YwcJ)7NlJ@T4iZ;)KFY6hiTtSql+41Hpwkwt+qx0K|4 zA-R_6JzsHP1Wht=K-vP9+n9IG_gf~3BdX~h#vT8-Mke$pNpCCkfO58b`uVR|yJdNf z3PrIOo>h))Cwx^9A1rvohPWp6rN}17Oh(TX}jC)GGQmBdoe1Q@jF4O4PPE?-ju`W^g<{m zrBN<@(O*F&_ez*!hr_%_?d(w5ruj{U2zP!>bV5yT#hx!;<$_9?+F9xTTpF6Dk}#p@ z{t8kW%^YK0YeUZ9c!`}OuO(x$Mq#9f9cv7XIfD;%PBdrkL#KI;!%DGSj;O|rn7_J< zbL0mRvGTKC35N$8FV?c~E=XQJ?x<2=j(7W;xsG7}sE}8eGRw%U$sGIxX+tut!RSAJ zSSlyw9-+se1$``$1ZIZa}W#3>DI_)@f#5Zvhl()Yc zT(}^*el1L8?r`Fnb`~wnQU9n|Zt2KnE0uaK^1}Tk+_)Ew0ABBfkFlqz<% zW1Sw^yfZ>_H8@^!m6HL#HM8YYPB5z-NQ7_#AQyvDB6L0qb7s}o9{Wg88z*1RzXx`& zE-m)edt^g-+({Pr1aFb-kX?R=eN!8#lfIi+YwNc#*p8f_8xr7QTtJ8i>oK^~zUcXy zQ&p<}$(zi(N%ku!pd`8EUp7Q808~Awwz%GPIq?Fg=YDJ29EI$ zd|pakyp`V_u&J5thYw_Q*oVOn0z?$p8{uk(Zw$|%bxSLWu=daBKkAtcQY^YBPu_0F z#ZM~zm9qv1h+p~j5<^(i&8u;YYqq8W2(FWkRIgOA~@sUa@iskDqL zCN1!<;M{un7w9B-^=E{Pj!W7P*MOoR>i20O4*I8~C`iHLbx_(z70!y20bI(8iK&mX$1vlRO>aC1JEZV?5i#Yn{;k`csD2ez z$*y8oUIk6bj0NxtPcTH`H|pU5w@Q0d+Ce}jVS)3;z#5OqkjbZlo$tM$TK27vC|qS0 zaI&I58BukN;{=wY35(5dB>cj^XgJ5Z1V9OUEiT@j8x3EBLoWk|K{Q()`w&~6=spq; zGDlt;9B8x<&^vnonkWS9hE5CjW=@*p^F&Jxg3#2n2mzun-0-@rfh~u9$X%4sEmAjv zX9)ob_93e)o(?P?aipH46;2w&hrPcDNp9-}7j?)Rdv+tuLtOBiLLf1f680TprB8#{ zGLLJtWlt9P+96AxHj0n$Nu&OBN~t^!(3XiWa1Fa>_nFCeD@US?bMhBl-wyso@28M# zMZEWso}U4DzPXY5E{<=Ph(iuGZ)awv17>cnTXqF+;-1S|cLkp)Q&4 zJhQ{Sv76T@5=vo};#{|Fr8UNk+$}sT9A%#bCN;HNi3w`C@O{%H;gO6sR`PzGGN2J= zZCx5$b*Gaxro@>&<<&zNiuXccoT0JtV?NcZa}dT-MHCzRi$F;FRyL~t(hwv(KC{t2AmvjGWyO{MeH;|7^D#iK&8TwfF-I^`uZv@VhqA#_a$eH)2f&m*VYIVnFD_Mxv3D{ z?gBFs?-S~LZ6#hZ(Q+xY-p=F|5QE`v#j*SR)mIvZ>GEKy0V8~%!KP!s%$L137Gyem z^Ux&j;&-Y3y`(i_5?o+FN(JK|(Gdl?8BI<450sbUBBIxi>{2ni#Y)ZH`JFUcQW?1l zm513C+KGZ{p*gXfcoWB(ivX$K0@_*Sy)XC#du+ikqp+Z0T4s-}KlnihSn^!t2~H%c z2QE?EiMPrZCTZ7b=98X|1AyV@oc)svF~Xl9k_MNjIJ63VMLO@rfd-k3T;(DStue=@ z1bY3t*EzaGyBg-(8ZG^{z1EccB14X=k`!A7zIR0Y{PnwHn}3A{HfIk$2efx|0&{=z zh{au3O3Mne*#115G!(=7s5oYX`Hm!7ezxbe&$O9Cgd5M8mO%^{C^S^3lah*Vxbkbo zC?YkD?`^ZuyEyk%>G>nszGywe9#mhdhRGG6<53-X`~%B2+%$1yfKjB&#%EuHsfW!L zQvYYzVlA|6B8BAxU5NlqgHASn!Ldxv9CqYQauS8bx&}Z?QK58VY%;HHY zb0*72qCU1ba;B#d_YBSAya!@$A8WD0#j&=fx!K>PuqT6_8runKN;-3he+>&lWx-_g zDh*H7l+@~y)xPlAiaiF|>T+NwbTEW6Jn@@o6nxtQHs3nXI$IZ7EW_2|_$Zg;)-aA5j7`p1enAODGf&k@0>#E$oa1r?9eo*{PT!blL)k$XA48 zVFeyiU;GH$XQenb`l2^B>3%i0xQp8Q%hAWkL|#bdg(PE&Kmo?y5EUj)Ud>W8L0*#t z_x!EnY82uX5v=k<;lQK2tqCS;5ziNG_^D|1U7?BMI-M`i1_XC! z`eT&Q`0<~Psf=7^oH*Iymvg^dSSZ-to;dIK-dj)>PM*dD&pOsG=?MfsDSc;Je}TP= zem$Yl=b>N~CH6MiZcZSN(8$>UV$DHAfw3aBPr5m+679cZu}m z&?AnJdbzQ&%ywIZp*(5lS|k(KX7J!d!*=m7e3UEqWSV(Zw9M{;b+dtH-K{7t;19_; zM?kbt*+Iq}$QO0H4Q@*2S?lw@yP|Jk8YL#8sgJ)KnMJ#hAUAl`X$97{{M5ZPLXP3WtzXNBK#qu6wT+t*+hcIoMUWrdvr>VTG!y4W1` zboLz8cxt=MT_itU8`Bt%nW5Jc29KV&nau627shr_7!^rQf7h2I11H z52v`47E+lAJZ(fsVx=~O%e>k{(kXO^DcS_6eP%dJH{2Lnz1P2`F;cUInj$+6ROmoV9E?e-{`3Siq#9

    3BIK{J{ zOYD|)PWm7%M@Cu}DbpVm)>A|C)+jg6{+sS+j>u7i7oV%la3-*zTIn(*p0{PoDfNUW z5>ZNoacX4fDS>@i)ISKCF_zgr6|8}@c%vuw(LZfCrMEL!ddN7fGVL>?Hw60w}F3@ z=hbrt_oec8Ycl8?R%;wXYr?hF z;!+e?TmuGK4jhu1k=zO+mubTUi~Zq+0m6Heu6DE1HK6EbT(denIPF4^Q71` zX_a{|w-w}1#wI--jomIrSCv83ngn2c)iZ3W+{(0&hnO=7cRTkL(O;*g5i3811b&iZ zDi@als0S+IY2CmC5Oj5Qj@%Cg61O9j%tMChz{Klg5UI{aO=E#Viq%vO>({4 zbdAQY+M>Czk**Xr6;XVhHej7)_S;^9yu#*q3BNsqhH}ECo4YOOFRjp*do)lF5?9Et zx%c`RnP%g7n-cOcnRhgOTX~wU zcqjaCjNCrLh=V3ASu^-{v{j3-pV5xp+}RL6_y6g60CpIvm4LhVPTf4Nygh(ei1B`R z7FNmg^PhsD;u#Rqo;w5rmqoH>1y22M4ld$aZ*TGQ^UAY2`yZg>OCnkzAUzI^5m7U^ zuebMM=b6hIp95nM8+!K~l0>!u#z31GSOjp#iOW)d(nE^zdwNC&U^x-e{ZEtO5Qzjy z4QU=(2e}n_2L%^J7{wap(+j>A38;*yIcO?qRcH^0?_ETD2hpSYx9;j%VV7AVo!yT@8 zJlA%UuXRqWPHxi1&-{&zT+C4IKq=_sH}_h@t`9 zVDV^SvuwuL8b_QutGb1=i6bR@r8oQK^JZTSK1kzQRq$5N>jc0}Cv|dE(l19?jmo;$ zNNK@s5UYx>)@^DGxFq@g2?u8TOFF^WESpkHAO73I;kwiN?`;s7G{XoM z8fF1&RHSU&F|j2cmFFC@sv(_Wd#zGZpMuiRNDA|geK}No3z!YlA!gHRj1E0PZc=)) zs@(8(B#V3JKF#sz)cGKll|*O!Jf&N-W4+ejY7&%*Yb~*f{pGTiT30#xqq25;3YpV= zdSIfviyBkmxo(|BoBVRVjK5)<>y;l5CKmrS9ty= z-glKnMZzjGuU*HL{XKum!3+j4TfBeN6xK@5uiCZSPEMcL$^P(E({i2{Yxd%PKLY3N z$*=S%U?N8mx=qY)#)ra<$o>N8#dx3p-M1H;eXjH@77PrQW_xJEc_1JNIEG3|Zji^% z1F@B|#U=7*MnOSg=84PhgOy-eDnJL(q7!1?Pl7oqmn6TKfN+5E?6_28bT4U{k|pbt a;R+7uyU)uw>|K=EWX1sW1^PC`9{ew-BoXrf literal 0 HcmV?d00001 diff --git a/css/fonts/fontello-051a52f4/font/delibera.woff2 b/css/fonts/fontello-051a52f4/font/delibera.woff2 new file mode 100644 index 0000000000000000000000000000000000000000..2b57bf0f476f4263a39afb33d19d6354dba9bcd9 GIT binary patch literal 4652 zcmV+{64UK>Pew8T0RR9101_+!4*&oF03wV401?&z0RR9100000000000000000000 z0000SLIzdMH{ ze>mP4j_QXaoW_{V9*S%%g>O?12hDxMk6d3ke3zo_s@^Cgf$ugy^XykYQGu0xzGXux zdEmL+zvg}(wE@Sbw)mt8oIwN$ga?%7+qU1^#%~~yh}cX)2-)j0JZ|gXHloLz3`!H=ps=Cex)Vo9DqX>j_f#+Y_ zx9mEd$sjL0{7(k64@JI#?|On}cDz?m{@d zjVRJHKnw*}<;aUcLhK1`s*yC?Ov)T#Iz^!n?1I_?E)&Y#{1-2X5|b5|s_6zZJ_ZB{ z33QHvu(t9LL@_v58zX|kh@voJD2zA?BZ0z5qA*e@j5G=(gTlz7Fmfo2JPM6&MkgWY7e%K?r&&jliDlzEEr*8Tj~#W>aw%&-Xpo3+>_ zGhZW+`_|~ylVA(A@v?PT$gGxdU-un0pi~5tPknjctUhAJcp0~*bvPh6yQ4{d3OQxI zHEbqnt_54YI-Gd66tXD$@hn!QpByecn-9+xC8n?!d7kQSWT3OT=0fhcCWQHBXrV~Ew|Y$CP+OS5KEv!9V=Hh}cN{5}Figubc-P1PRqaCr z87&cv(-+`@X$LQs0uJ>uz)+8_po^CTW#62WF{xhPTxWO7>2-=T(J_DwyyF-|Cc%aT zW5a^85h2*9kl2`z*|<>HgizU}(1uUJXhVA?_%xSsFL>w!KtBKm05AxEApi^mU<3f8 z0OMnj?p$JVH{ndBr%~PO?<}RnCe)M!h%00owd_VYSH?P0{XaLY zNbaHK)rPH>?vW+P$7dk7>Nq?LqqQVC?;Y|2L6rsZ6+z_uk>1Uju)OTZwRu})RL3d6 zSl`uI%A-2cbrkGEi0igDC?Yc%=cJMmkWbkuPn!Nn-PRIbukSNL>f1sH%Y&C4B>)0p z>p&lg#?EGwR*`PwW|guoBh^{6Ak?QAAzVL^XYbC3FYJ2ay6Bt4iPPx43M!=uq&!X? zCIp`&tw|t%6^~#{8wzK=p$i%7;y~%eWr^wiT1601hvSCoJRHJoAC$1wB+FWT8MA^( zgh*CzmS`cJL2I;CK<;YiUcMG7CmS7=_NRo=NRer@d)HBwg{bP)siB}C7%5%rE~vcf zO&_*UNmp%=NL#Y^TI#G-qay1!+EFjPp2I@veRqk?OAKRk11eRI z-EFuKq#LW82#b!RDH~{R4Xu<*Hy^tVN}i+B0cCFrg^40-x)kp!2v#KA(Vbn1o`s1u zqe@pQy_?tRJyT}2VSXC^5~G<1RfpFU)76)aMaO!GjrF71j!3j!%nh-6qS}ybE}yRz zJu%ZQo`YxPKt*ovSWx+kWd>9`K>iRel@#}E*#|LDsbtvHK%J&n%Bg5rzIIm27GQGE z*964YH6?I^0NOP3sn`OKwgG4dfOg?Su?NsT0386(A$%;306GSs6977e&%_x(=Kyp8 zK$q~5xB}=JfNlUL-EmMwoZcoBClcNsqVKV?#A1JrSUvLqNX(x9qj3MsIfk z`rQZg2LSsls?*n9fd2LY{R1#lul%AlYM+X7_zr3XU(bDdFUjEy1b<2s=<1F)E-^A7 zwlg5UHDDk8`351=8nV(F#sP)(*ujMj*H4{1C5O-MnLG^V!DP3)Jrop|d#^aVzO&!% z>CX1V^OFnGYuaX5Sz7!R=Wr@Sp}RSruUZyQfy@|ZjATu?^^B7YQ_$f$2qU$TO5c|m zxOi=bfM&S&PM@I*ifM}bAfBye)qh->8Jwba+%GFp%YG$H_;gZL&n` znOKU0Wy-*2gFl1x3eOudHP14Bc9nHi%DZt4bc%4BOVC?2QbOCdHQ6aZ7AjDUGNgxd zVT~N9MJjO(jH#UsuA^$f9*5BvW;P0lF~VgT3-`;$@K7ix{4pUsaP#k680P=LB2^zf@-cS%Zxq>X z){Q(OC&MI|+=2-ZCLO4esWtHSf^CCx@DXTIw8=;72akbX)u;`V5zD1NP6Gvh}zMk=(A>0$j zpR4ec_efV}T{)`nD_TK{5g4M)s)`uY4!aU+-PK(;IK#y5TXjp?I#pc&ZlK1H=O|5o z31hWa825&pA47qVchPCdWT~A~q#v6F_hi!(yNal0A870#x88uk$I_ zk(@;m(Sb6_m=lyx?Y6s$*Mw+Sy5)IJoe|)9W)H)^44b9%R{bRa=WACdFH5ru7g-H_ z5(z`aDWn)5yk0((+bdSpqc~AJQ4YZ)(g9?cc)Ze}TrMkQE#yM78l+aEUU*g2DPl+n zE2JoyWXlWn0CFz;`M=gO6}9;OmDLl_YzSlP#){aQip1`IvMOYX{<9bWP&4cBvS4$c zAqFM65Qn5Sh>HBqxsadh-%G{n3g~wF&ba{K+6M9bEdrjQdtGk4YOtcmGM zXR9Ptc%mM_Xo`U#-adZ(r~D%ly^VTnu~48^%?up0kNxYsWso7e`x8`&_YLv8^Lq;HSI+ZU7Yj7cX85ot z&Yw8XR`fX~59BKCn6$+t4o25B?GEYn9*}C>|gE~ zZx(u)drO?Mm*z)2raPR>{d8{>)mEk?yfj5!-ljCzC8soo&j(A*L>H8;Ctu4pJ@^zC!jDA~K3H%d0D)JM=p zRg|l_xk186+1|gZDk85)Z6Te?;~)oYcKM1jCOoalZmI5~GCF+5FzGm~3`)WsLE|6V zF*`lcIbRSTJWC=iNp9~$QY)M9oacBV&1XnUXR=%@#YTxO&0{_ibBmZaV7g++9|2i$ zS?wipf0xNFpMb^ajLIuYot}@!XS=}Wu<9xMOFD>ywfDEPh2=su?+W$h<$BBT_V%~i z#*EqiXRy>H#DuoevVC=>R#4ZleY-qH@feQL8jTNep*{4`i|2MBiJD%#2q9yrXc9LW zdouEC9B{JH68)2V(o9>b_XlAsg|KMSYC~zE(Q7I$1bSH_SO4|n!O{>$;{6=|V#q9- zKlA$rdAj+kMk(J=;4vV&*oadfc9y-=$_#YSgADqpUbtQc~qC(=O0PlCjUyU(>AzUfcO(PfXAKe&nc`+k4IZkI(p?OexycnG8)F$~R+u z=emdDeew2*{rBI;`dZVw>Llfcio8L*5`2Ac#a(!z%!& z*Rl%^7pWtbL5zqx1AvNW-}jDa6k%oYW;knmIr0U6MVu1bzuzoDjl-5> z%t($8_GQA1=*XRU385VLoSS_ZEw3MWTxL9>)uuKx*NBH^(1w0OmQ52&3`y@zB zbX2%nsR#*{O8osqzL<~!IN5teNd0)~zn5sRV`ClJ8BP1l;v(KfJGh>&_7u=ZWwh8< z7Jvar9sI9i0WH?RJ|u4v0pTuUnW26N#3*b_Q&e&=e2#b;W!9Lpz!apzU`Fz&AC5=k zT%YYZ+(W2#Y+QE8{|OC`%CC*DU9dw|EPh%6113nXKmZGvIIW1%)(7A#G zBK5vK7vL5F4yeNt5!mT(Q31W#3Rb&OR0SKT6kJp|qi6IKmn@Z1m-GJlc z2Rk-xr{GU@;f8BNS#O*4PVFvTX>D@ofwXMc)pqV5&w?6-_mq6G<8}73!ElPoYE^ z5A>TNMv}oUwNV2sf8xwg$P|7~px@@^{g^?YW`GU@vyS)$ART&Kb`FNOo!^n>_ Date: Mon, 14 Mar 2016 02:23:31 -0300 Subject: [PATCH 094/435] TODO check if is superadmin for debug info --- admin/delibera_cron.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/admin/delibera_cron.php b/admin/delibera_cron.php index d725c9d..4cb977d 100644 --- a/admin/delibera_cron.php +++ b/admin/delibera_cron.php @@ -15,7 +15,10 @@ public function __construct() add_action('admin_action_delibera_cron_action', array($this, 'action')); add_action('wp', array($this, 'registry') ); add_action('admin_action_delibera_cron_list', array($this, 'list')); - add_action('delibera_menu_itens', array($this, 'addMenu')); + //if(is_super_admin()) // TODO load after init + { + add_action('delibera_menu_itens', array($this, 'addMenu')); + } add_action('wp_trash_post', array($this, 'del') ); add_action('before_delete_post', array($this, 'del') ); } From 92f5dc9c02694a8339a00705e94586effd690bbc Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Mon, 14 Mar 2016 02:24:26 -0300 Subject: [PATCH 095/435] if is in flow, is active --- modules/validation/validation.php | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/modules/validation/validation.php b/modules/validation/validation.php index b627c77..b6de3ca 100644 --- a/modules/validation/validation.php +++ b/modules/validation/validation.php @@ -172,8 +172,6 @@ public function topicMeta($post, $custom, $options_plugin_delibera, $situacao, $ $prazo_validacao = array_key_exists("prazo_validacao", $custom) ? $custom["prazo_validacao"][0] : $prazo_validacao; } - if($options_plugin_delibera['validacao'] == "S") - { ?>

    @@ -184,7 +182,6 @@ public function topicMeta($post, $custom, $options_plugin_delibera, $situacao, $ id="prazo_validacao" name="prazo_validacao" class="prazo_validacao widefat hasdatepicker" value=""/>

    0; - if(!$autosave && ($valida === false)) - { - $erros[] = __("É necessário definir corretamente o número mínimo de validações", "delibera"); - } + $erros[] = __("É necessário definir corretamente o prazo de validação", "delibera"); + } + + $value = (int)$_POST['min_validacoes']; + $valida = is_int($value) && $value > 0; + if(!$autosave && ($valida === false)) + { + $erros[] = __("É necessário definir corretamente o número mínimo de validações", "delibera"); } return $erros; } From 43e193905d8c115c8872604fbafe63891b4411f6 Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Mon, 14 Mar 2016 02:25:06 -0300 Subject: [PATCH 096/435] load new font icons on admin --- delibera_init.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/delibera_init.php b/delibera_init.php index 5aa7731..b52ff42 100644 --- a/delibera_init.php +++ b/delibera_init.php @@ -237,6 +237,12 @@ function delibera_admin_scripts() } add_action( 'admin_print_scripts', 'delibera_admin_scripts' ); +function delibera_print_font_styles() +{ + wp_enqueue_style('delibera-font', WP_CONTENT_URL.'/plugins/delibera/css/fonts/fontello-051a52f4/css/delibera.css'); +} +add_action('admin_print_styles', 'delibera_print_font_styles'); + // Fim Scripts function delibera_footer() { From c680dc931f49df7e0b726f58216de8047bbcfe6b Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Mon, 14 Mar 2016 02:25:44 -0300 Subject: [PATCH 097/435] flow window test --- admin/css/flow.css | 63 +++++++++++++++++ admin/images/iconSpirite.gif | Bin 0 -> 668 bytes admin/js/flow.js | 88 ++++++++++++++++++++++++ delibera_flow.php | 130 +++++++++++++++++++++++++++++++++++ 4 files changed, 281 insertions(+) create mode 100644 admin/css/flow.css create mode 100644 admin/images/iconSpirite.gif create mode 100644 admin/js/flow.js diff --git a/admin/css/flow.css b/admin/css/flow.css new file mode 100644 index 0000000..6c89610 --- /dev/null +++ b/admin/css/flow.css @@ -0,0 +1,63 @@ +@CHARSET "UTF-8"; + +.column{ + width:49%; + margin-right:.5%; + min-height:150px; + background:#fff; + float:left; +} +.column .dragbox{ + margin:5px 2px 20px; + background:#fff; + position:"relative"; + border:1px solid #946553; + -moz-border-radius:5px; + -webkit-border-radius:5px; +} +.column .dragbox h2{ + margin:0; + font-size:12px; + background:#946553; + color:#fff; + border-bottom:1px solid #946553; + font-family:Verdana; + cursor:move; + padding:5px; +} + +.dragbox-content{ + background:#fff; + min-height:100px; margin:5px; + font-family:'Lucida Grande', Verdana; font-size:0.8em; line-height:1.5em; +} +.column .placeholder{ + background: #EED5B7; + border:1px dashed #946553; +} + +.opIcons +{ +background-image: url('../images/iconSpirite.gif')!important; +background-repeat: no-repeat; +float:right; +height:13px; +width:13px; +margin:0px 2px; +} + +.maxmin +{ + background-position:-26px 1px; +} + +.delete +{ + background-position:-269px center; + padding-top:1px; +} + + +#column1 .ui-sortable-handle a { + display: none; +} diff --git a/admin/images/iconSpirite.gif b/admin/images/iconSpirite.gif new file mode 100644 index 0000000000000000000000000000000000000000..8057c186ad63eabd6fb569be7306f20cfe387464 GIT binary patch literal 668 zcmV;N0%QG0Nk%w1VJ86%0P+L?%*@Q@=H~PB^Z5Aq|Ns900000000000A^8LW000F5 zEC2ui04D(r000C2Sh}$OyNge z1lRh79w*xoCfqqGBqhf7jMj`%fD!te3aQVq*!qQ(gI<~zYrR}wjHWn7mJk{#T~}Ll z^?eLmYam>NH))55gDD{K$?|} zf+B^eD4aUCQ>%}?v=<|VwRf$qJtROa3&~5#8M!DKpA&J^%hw;&dAutYdl5e^cs$&} zeBrQ}gtNYex~bzydbGjj-t_p7e8#VElP~=!$>5Y^kdYGA5Ej9getFlowModules(); + /** + * Create Defaults value for topicMeta like in action TODO check if value is need after make this work + * @var unknown + */ + $post = new \WP_Post(new \stdClass()); + $custom = array(); + $options_plugin_delibera = delibera_get_config(); + $situacao = ""; + $disable_edicao = false; + foreach ($modules as $key => $module) + { + $situacao = get_term_by('slug', $key, 'situacao'); + ?> +
    +

    name; ?> + + +

    + +
    + + +
    + listModulesConfigBoxes(); + ?> +
    +
    + +
    + + $post->ID, + 'ajax_url' => admin_url('admin-ajax.php'), + ); + /*if (is_object($situation)) { + $data['situation'] = $situation->slug; + }*/ + + wp_localize_script('delibera-admin-flow', 'delibera_admin_flow', $data); + + wp_enqueue_style('delibera-admin-flow',WP_CONTENT_URL.'/plugins/delibera/admin/css/flow.css'); + } + + public function saveFlowCallback() + { + $flow = explode(',', strip_tags($_POST['flow'])); + $post_id = intval(strip_tags($_POST['post_id'])); + $opt = delibera_get_config(); + $all_errors = array(); + + if($post_id > 0) + { + $modules = $this->getFlowModules(); + $events_meta = array(); + foreach ($flow as $situacao) + { + $errors = array(); + if(array_key_exists($situacao, $modules)) + { + $errors = $modules[$situacao]->checkPostData($erros, $opt, false); + if(count($errors) == 0) + { + $events_meta = $modules[$situacao]->savePostMetas($events_meta, $opt); + } + else + { + $all_errors = array_merge($all_errors,$errors); + } + } + } + if(count($all_errors) > 0) + { + die(json_encode($all_errors)); + } + foreach ($events_meta as $key => $value) // Buscar dados + { + update_post_meta($post_id, $key, $value); // Atualiza + } + } + else + { + $opt['delibera_flow'] = $flow; + if(! update_option('delibera-config', $opt)) + { + $all_errors = array(_('can not update flow', 'delibera')); + die(json_encode($all_errors)); + } + } + die('ok'); + } + + } global $DeliberaFlow; From 18ed905ba9460b16e4aff58e9d5278a9a75cc65a Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Mon, 14 Mar 2016 03:08:54 -0300 Subject: [PATCH 098/435] differ config and post display --- admin/css/flow.css | 6 +++- admin/js/flow.js | 5 ++- delibera_flow.php | 90 +++++++++++++++++++++++++++++++--------------- 3 files changed, 71 insertions(+), 30 deletions(-) diff --git a/admin/css/flow.css b/admin/css/flow.css index 6c89610..ada8322 100644 --- a/admin/css/flow.css +++ b/admin/css/flow.css @@ -58,6 +58,10 @@ margin:0px 2px; } -#column1 .ui-sortable-handle a { +.delibera-flow-panel-config #column2 .ui-sortable-handle a { + display: none; +} + +.delibera-flow-panel-post #column1 .ui-sortable-handle a { display: none; } diff --git a/admin/js/flow.js b/admin/js/flow.js index d7709c3..b6d9a6c 100644 --- a/admin/js/flow.js +++ b/admin/js/flow.js @@ -46,7 +46,10 @@ jQuery(document).ready(function() { }, stop : function(event, ui) { copyHelper && copyHelper.remove(); - + if(delibera_admin_flow.post_id == '') + { + jQuery(ui.item).find('.dragbox-content').toggle(); + } jQuery(ui.item).find('h2').click(); sortorder = ''; jQuery('#column2').each(function() { diff --git a/delibera_flow.php b/delibera_flow.php index 23f6118..89530d8 100644 --- a/delibera_flow.php +++ b/delibera_flow.php @@ -353,18 +353,31 @@ public function addMenu($base_page) add_submenu_page($base_page, __('Delibera Flow','delibera'),__('Delibera Flow','delibera'), 'manage_options', 'delibera-flow', array($this, 'confPage')); } - public function listModulesConfigBoxes() + public function listModulesConfigBoxes($post = null) { + $is_post_meta = !is_null($post); + $modules = $this->getFlowModules(); + /** * Create Defaults value for topicMeta like in action TODO check if value is need after make this work - * @var unknown */ - $post = new \WP_Post(new \stdClass()); $custom = array(); $options_plugin_delibera = delibera_get_config(); $situacao = ""; $disable_edicao = false; + + if(is_null($post)) + { + $post = new \WP_Post(new \stdClass()); + } + else + { + $custom = get_post_meta($post->ID); + $situacao = delibera_get_situacao($post->ID); + } + + foreach ($modules as $key => $module) { $situacao = get_term_by('slug', $key, 'situacao'); @@ -374,9 +387,23 @@ public function listModulesConfigBoxes() -