Skip to content

Commit

Permalink
add support to discussion type
Browse files Browse the repository at this point in the history
  • Loading branch information
jacsonp committed Jul 7, 2017
1 parent 22ca232 commit eb8dafb
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions modules/discussion/discussion.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,18 @@ public function configPageRows($rows, $opt)
"label" => __('Dias para discussão da pauta:', 'delibera'),
"content" => '<input type="text" name="dias_discussao" id="dias_discussao" value="'.htmlspecialchars_decode($opt['dias_discussao']).'" autocomplete="off" />'
);
$id = 'discussion_type';
$value = htmlspecialchars_decode($opt[$id]);
$rows[] = array(
"id" => $id,
"label" => __('Tipo da discussão:', 'delibera'),
"content" => '
<select name="'.$id.'" id="'.$id.'" autocomplete="off" >
<option value="forum" '.($value == 'forum' ? 'selected="selected"' : '').'>'.__('Formato de forum', 'delibera').'</option>
<option value="side" '.($value == 'side' ? 'selected="selected"' : '').'>'.__('Por parágrafo', 'delibera').'</option>
</select>
'
);
$rows[] = array(
"id" => "pauta_suporta_encaminhamento",
"label" => __('Pautas suportam sugestão de encaminhamento?', 'delibera'),
Expand Down Expand Up @@ -144,7 +156,7 @@ public function generateDeadline($options_plugin_delibera)
public function topicMeta($post, $custom, $options_plugin_delibera, $situacao, $disable_edicao)
{
$prazo_discussao = $this->generateDeadline($options_plugin_delibera);
$tipo_discussao = array_key_exists("tipo_discussao", $custom) ? $custom["tipo_discussao"][0] : 'forum';
$discussion_type = array_key_exists("discussion_type", $custom) ? $custom["discussion_type"][0] : 'forum';
$delibera_show_default_comment_form = array_key_exists("delibera_show_default_comment_form", $custom) ? $custom["delibera_show_default_comment_form"][0] : 'N';

if(!($post->post_status == 'draft' ||
Expand All @@ -158,12 +170,14 @@ public function topicMeta($post, $custom, $options_plugin_delibera, $situacao, $
<p>
<label class="label_prazo_discussao"><?php _e('Prazo para Discussões','delibera') ?>:</label>
<input <?php echo $disable_edicao ?> name="prazo_discussao" class="prazo_discussao widefat hasdatepicker" value="<?php echo $prazo_discussao; ?>"/>
</p><?php /*?>
</p>
<p>
<label class="label_tipo_discussao"><?php _e('Tipo de Discussões','delibera') ?>:</label>
<input <?php echo $disable_edicao ?> name="tipo_discussao" class="tipo_discussao widefat" value="<?php echo $tipo_discussao; ?>"/>
<label class="label_discussion_type"><?php _e('Tipo da Discussão','delibera') ?>:</label>
<select name="discussion_type" id="discussion_type" class="discussion_type widefat" autocomplete="off" >
<option value="forum" <?php echo $discussion_type == 'forum' ? 'selected="selected"' : ''; ?>><?php _e('Formato de forum', 'delibera'); ?></option>
<option value="side" <?php echo $discussion_type == 'side' ? 'selected="selected"' : ''; ?>><?php _e('Por parágrafo', 'delibera'); ?></option>
</select>
</p>
<?php */ ?>
<p>
<label class="label_delibera_show_default_comment_form" title="<?php _e('Mostrar campo para opinião/encaminhamento padrão com o comentário por parágrafo ativo?','delibera') ?>" ><?php _e('Permitir comentários gerais?','delibera') ?>:
<input <?php echo $disable_edicao ?> name="delibera_show_default_comment_form" type="checkbox" value="S" class="delibera_show_default_comment_form widefat delibera-admin-checkbox" <?php echo $delibera_show_default_comment_form== 'S' ? 'checked="checked"' : ''; ?> />
Expand Down Expand Up @@ -232,9 +246,9 @@ public function savePostMetas($events_meta, $opt, $post_id = false)
{
$events_meta['prazo_discussao'] = sanitize_text_field($_POST['prazo_discussao']);
}
if(array_key_exists('tipo_discussao', $_POST))
if(array_key_exists('discussion_type', $_POST))
{
$events_meta['tipo_discussao'] = sanitize_text_field($_POST['tipo_discussao']);
$events_meta['discussion_type'] = sanitize_text_field($_POST['discussion_type']);
}
$events_meta['delibera_show_default_comment_form'] = array_key_exists('delibera_show_default_comment_form', $_POST) ? sanitize_text_field($_POST['delibera_show_default_comment_form']) : 'N';

Expand Down Expand Up @@ -296,15 +310,7 @@ public function getCommentListLabel()
*/
public function template_redirect()
{
/*$tipo = get_post_meta(get_the_ID(), 'tipo_discussao', true);
if($tipo == 'side')
{
require_once DELIBERA_DIR_PATH . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'wp-side-comments' . DIRECTORY_SEPARATOR . 'wp-side-comments.php';
if(function_exists('\Delibera\Includes\SideComments\wpsc_init_side_comments'))
{
\Delibera\Includes\SideComments\wpsc_init_side_comments();
}
}*/

}

public static function treatCommentType($comment, $encaminhamento)
Expand Down

0 comments on commit eb8dafb

Please sign in to comment.