diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..bca85c2
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,12 @@
+# EditorConfig is awesome: http://EditorConfig.org
+
+# top-most EditorConfig file
+root = true
+
+# Unix-style newlines with a newline ending every file
+[*]
+end_of_line = lf
+insert_final_newline = true
+indent_style = tab
+indent_size = 2
+charset = utf-8
diff --git a/.gitignore b/.gitignore
index e00540d..360f4af 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,4 +5,5 @@ Thumbs.db
.project
.settings
.buildpath
-
+.idea/*
+*~
diff --git a/README.md b/README.md
index 9a9acca..7ab1631 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,6 @@
+[](https://waffle.io/redelivre/delibera)
+
+[](https://github.com/redelivre/delibera)
Delibera
========
@@ -18,10 +21,33 @@ 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?
===============
Existem algumas maneiras de colaborar com o desenvolvimento deste plugin. Se você é um usuário, você pode ter encontrado um problema (bug) ou ter tido alguma idéia de uma nova funcionalidade. Em qualquer um dos casos, entre em contato com os desenvolvedores criando uma [issue](https://github.com/redelivre/delibera/issues).
Se você é um desenvolvedor, sinta-se livre para fazer um fork e contribuir com o desenvolvimento. Se quiser, dê uma olhada se você pode resolver alguma das [issues abertas](https://github.com/redelivre/delibera/issues).
+
+
+### Situações possíveis da pauta
+
+| Slugs | Module | Descrição |
+| --------------- |:---------------:| -----:|
+| validacao | Mod. validation | Proposta de pauta, precisa ser validada para ser continuar no fluxo, comentário é apenas se valida |
+| naovalidada | Mod. validation | Proposta recusada por prazo sem minimo de validação ou forçada pelo admin |
+| discussao | Mod. Discussion | Pauta em discussão, aceita comentários do tipo padrão ou encaminhamento |
+| eleicao_relator | Mod. rapporteur | Pauta que precisa de relator, mas antes o relator precisa ser eleito (não implementado) |
+| relatoria | Mod. rapporteur | o Relator vai editar os encaminhamentos para criar opções válidas para votação |
+| emvotacao | Mod. vote | Pauta em votação, aqui o comentário é um voto simples |
+| comresolucao | Mod. result | Pauta chegou ao fim, apresentar resultado |
diff --git a/admin/css/flow.css b/admin/css/flow.css
new file mode 100644
index 0000000..220bab5
--- /dev/null
+++ b/admin/css/flow.css
@@ -0,0 +1,81 @@
+@CHARSET "UTF-8";
+
+
+.delibera-flow-panel.delibera-flow-panel-post {
+ display: block;
+ float: none;
+ overflow: hidden;
+ position: relative;
+}
+
+.delibera-flow-panel .delibera-flow-column{
+ width:49%;
+ margin-right:.5%;
+ min-height:150px;
+ background:#fff;
+ float:left;
+}
+.delibera-flow-panel .delibera-flow-column .dragbox{
+ margin:5px 2px 20px;
+ background:#fff;
+ position:"relative";
+ border:1px solid #946553;
+ -moz-border-radius:5px;
+ -webkit-border-radius:5px;
+}
+#poststuff .delibera-flow-panel .delibera-flow-column .dragbox h2,
+.delibera-flow-panel .delibera-flow-column .dragbox h2 {
+ margin:0;
+ font-size:12px;
+ background:#946553;
+ color:#fff;
+ border-bottom:1px solid #946553;
+ font-family:Verdana;
+ cursor:move;
+ padding:5px;
+}
+
+.delibera-flow-panel .dragbox-content{
+ background:#fff;
+ min-height:100px; margin:5px;
+ font-family:'Lucida Grande', Verdana; font-size:0.8em; line-height:1.5em;
+}
+.delibera-flow-panel .delibera-flow-column .placeholder{
+ background: #EED5B7;
+ border:1px dashed #946553;
+}
+
+.delibera-flow-panel .opIcons
+{
+background-image: url('../images/iconSpirite.gif')!important;
+background-repeat: no-repeat;
+float:right;
+height:13px;
+width:13px;
+margin:0px 2px;
+}
+
+.delibera-flow-panel .maxmin
+{
+ background-position:-26px 1px;
+ cursor: pointer;
+}
+
+.delibera-flow-panel .delete
+{
+ background-position:-269px center;
+ padding-top:1px;
+ cursor: pointer;
+}
+
+.delibera-flow-panel-config #delibera-flow-column2 .ui-sortable-handle span:last-child {
+ display: none;
+}
+
+.delibera-flow-panel-config #delibera-flow-column2 .dragbox-content {
+ display: none;
+}
+
+.delibera-flow-panel-post #delibera-flow-column1 h2 span {
+ display: none;
+}
diff --git a/admin/delibera_admin_functions.php b/admin/delibera_admin_functions.php
new file mode 100644
index 0000000..4089dbc
--- /dev/null
+++ b/admin/delibera_admin_functions.php
@@ -0,0 +1,268 @@
+post_type == 'pauta' && $current_screen->id == "edit-pauta") {
+ ?>
+
+ current_action();
+
+ switch($action) {
+ case 'set_prazodiscussao':
+ check_admin_referer('bulk-posts');
+
+ $pautas_ids = $_REQUEST['post'];
+ $novo_prazo_discussao = $_REQUEST['novo_prazo_discussao'];
+ $inovo_prazo_discussao = DateTime::createFromFormat('d/m/Y', $novo_prazo_discussao)->getTimestamp();
+ $pautas_afetadas = 0;
+
+ foreach($pautas_ids as $pauta_id) {
+
+ delibera_set_novo_prazo_discussao_relatoria($pauta_id, $inovo_prazo_discussao, delibera_get_config());
+
+ $pautas_afetadas++;
+ }
+
+ $sendback = admin_url( "edit.php?post_type=pauta&pautas_afetadas=$pautas_afetadas&novo_prazo=$novo_prazo_discussao");
+
+ wp_redirect($sendback);
+
+ exit();
+
+ break;
+ }
+}
+
+add_action('load-edit.php', 'delibera_custom_bulk_action');
+
+/**
+ * Função que exibe a mensagem de confirmação da alteração em massa
+ *
+ */
+function delibera_custom_bulk_admin_notices() {
+
+ $current_screen = get_current_screen();
+
+ if($current_screen->post_type == 'pauta' && $current_screen->id == "edit-pauta" &&
+ isset($_REQUEST['pautas_afetadas']) && (int) $_REQUEST['pautas_afetadas']) {
+ $mensagem = sprintf( '%s pautas definidas para o prazo de %s.', number_format_i18n( $_REQUEST['pautas_afetadas']), $_REQUEST['novo_prazo'] );
+ echo "
";
+ }
+}
+
+add_action('admin_notices', 'delibera_custom_bulk_admin_notices');
+
+/**
+ *
+ * Comentário na tela de Edição na administração
+ * @param WP_comment $comment
+ *
+ * @property add_meta_boxes_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, "tema");
+ break;
+ case 'situacao':
+ echo delibera_get_situacao($post->ID)->name;
+ break;
+ case 'prazo':
+ $data = "";
+ $prazo = \Delibera\Flow::getDeadlineDays($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');
+
+/**
+ * Inclui novas ações na lista do wp admin
+ * @param $columns
+ * @param $post
+ *
+ */
+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);
+
+/**
+ * Preenche lista de valores disponíveis para filtro da listagem do WP admin
+ *
+ */
+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/admin/delibera_conf_permission.php b/admin/delibera_conf_permission.php
new file mode 100644
index 0000000..3f47bf5
--- /dev/null
+++ b/admin/delibera_conf_permission.php
@@ -0,0 +1,307 @@
+roleList = array(
+ array(
+ 'id' => 'delete_pautas',
+ 'label' => __('remover pautas','delibera'),
+ ),
+ array(
+ 'id' => 'delete_private_pautas',
+ 'label' => __('remover pautas privadas','delibera'),
+ ),
+ array(
+ 'id' => 'edit_pauta',
+ 'label' => __('editar pauta','delibera'),
+ ),
+ array(
+ 'id' => 'edit_pautas',
+ 'label' => __('editar multiplas pautas','delibera'),
+ ),
+ array(
+ 'id' => 'edit_private_pautas',
+ 'label' => __('editar multiplas pautas privadas','delibera'),
+ ),
+ array(
+ 'id' => 'publish_pautas',
+ 'label' => __('publicar pautas','delibera'),
+ ),
+ array(
+ 'id' => 'read_pauta',
+ 'label' => __('visualizar pautas','delibera'),
+ ),
+ array(
+ 'id' => 'read_private_pautas',
+ 'label' => __('visualizar pautas privadas','delibera'),
+ ),
+ array(
+ 'id' => 'delete_published_pautas',
+ 'label' => __('remover pautas publicadas','delibera'),
+ ),
+ array(
+ 'id' => 'forcar_prazo',
+ 'label' => __('forcar o final de prazo','delibera'),
+ ),
+ array(
+ 'id' => 'delibera_reabrir_pauta',
+ 'label' => __('reabrir pauta','delibera'),
+ ),
+ array(
+ 'id' => 'edit_published_pautas',
+ 'label' => __('editar multiplas pautas publicadas','delibera'),
+ ),
+ array(
+ 'id' => 'edit_published_pauta',
+ 'label' => __('editar pauta publicada','delibera'),
+ ),
+ array(
+ 'id' => 'edit_encaminhamento',
+ 'label' => __('editar encaminhamentos','delibera'),
+ ),
+ array(
+ 'id' => 'votar',
+ 'label' => __('votar','delibera'),
+ ),
+ array(
+ 'id' => 'relatoria',
+ 'label' => __('fazer relatoria','delibera'),
+ ),
+ array(
+ 'id' => 'edit_others_pautas',
+ 'label' => __('editar multiplas pautas de outras pessoas','delibera'),
+ ),
+ array(
+ 'id' => 'edit_others_pauta',
+ 'label' => __('editar pauta de outras pessoas','delibera'),
+ ),
+ array(
+ 'id' => 'delete_others_pautas',
+ 'label' => __('remover multiplas pautas de outras pessoas','delibera'),
+ ),
+ array(
+ 'id' => 'manage_tema_term',
+ 'label' => __('gerenciar temas','delibera'),
+ ),
+ array(
+ 'id' => 'edit_tema_term',
+ 'label' => __('editar temas','delibera'),
+ ),
+ array(
+ 'id' => 'delete_tema_term',
+ 'label' => __('remover temas','delibera'),
+ ),
+ array(
+ 'id' => 'assign_tema_term',
+ 'label' => __('atribuir temas','delibera'),
+ ),
+ array(
+ 'id' => 'manage_delibera_cat_term',
+ 'label' => __('gerenciar categorias','delibera'),
+ ),
+ array(
+ 'id' => 'edit_delibera_cat_term',
+ 'label' => __('editar categorias','delibera'),
+ ),
+ array(
+ 'id' => 'delete_delibera_cat_term',
+ 'label' => __('remover categorias','delibera'),
+ ),
+ array(
+ 'id' => 'assign_delibera_cat_term',
+ 'label' => __('atribuir categorias','delibera'),
+ ),
+ );
+ add_action('init', array($this, 'admin_init'));
+ add_action( 'registered_taxonomy', array($this, 'setTaxonomyCaps'), 10, 3 );
+ }
+
+ public function admin_init()
+ {
+ add_action('delibera_menu_itens', array($this, 'addMenu'));
+ }
+
+ public function addMenu($base_page)
+ {
+ add_submenu_page($base_page, __('Delibera Permissões','delibera'),__('Delibera Permissões','delibera'), 'manage_options', 'delibera-perm', array($this, 'confPage'));
+ }
+
+ public function confPage()
+ {
+ if ($_SERVER['REQUEST_METHOD']=='POST')
+ {
+ if (!current_user_can('manage_options'))
+ {
+ die(__('Você não pode editar as configurações do delibera.','delibera'));
+ }
+ check_admin_referer('delibera-permission-nonce');
+ $this->save();
+ }
+ $this->html();
+ }
+
+ /**
+ * * Copied from Sendpress **
+ */
+ function str_lreplace($search, $replace, $subject)
+ {
+ $pos = strrpos($subject, $search);
+
+ if($pos !== false)
+ {
+ $subject = substr_replace($subject, $replace, $pos, strlen($search));
+ }
+
+ return $subject;
+ }
+
+ function save()
+ {
+ foreach($this->get_editable_roles() as $role => $role_name)
+ {
+ if(is_super_admin() || $role != 'administrator')
+ {
+ $saverole = get_role($role);
+ foreach ($this->roleList as $rolearray)
+ {
+ if( isset($_POST[$role . "_{$rolearray['id']}"] ))
+ {
+ $saverole->add_cap( $rolearray['id']);
+ }
+ else
+ {
+ $saverole->remove_cap($rolearray['id']);
+ }
+ }
+ }
+ }
+ }
+
+ function GenerateCheckbox($id, $role, $echo = false, $label = "", $checked = '')
+ {
+ $listrole = get_role(sanitize_title($role));
+ if($listrole->has_cap($id))
+ {
+ $checked = 'checked';
+ }
+ $output = "
+
+ ".
+ ''.$label.''.
+ " | "
+ ;
+ if($echo) echo $output;
+ return $output;
+ }
+
+ function html()
+ {
+ $roles = array();
+ foreach ($this->roleList as $cap)
+ {
+ foreach($this->get_editable_roles() as $role => $role_name)
+ {
+ if(is_super_admin() || $role != 'administrator')
+ {
+ if(!array_key_exists($cap['label'], $roles)) $roles[$cap['label']] = array();
+ $roles[$cap['label']][$role] = $cap['id'];
+ }
+ }
+ }
+ $header = reset($roles);
+ //echo '';print_r($roles);die();
+ ?>
+
security_check();
+ global $wp_roles;
+
+ if(! isset($wp_roles))
+ $wp_roles = new WP_Roles();
+
+ return $wp_roles->get_role($role);
+ }
+
+ function get_editable_roles()
+ {
+ // $this->security_check();
+ global $wp_roles;
+
+ if(! isset($wp_roles))
+ $wp_roles = new WP_Roles();
+
+ $all_roles = $wp_roles->get_names();
+ $editable_roles = apply_filters('editable_roles', $all_roles);
+
+ return $all_roles;
+ }
+ /*** End Copied from Sendpress ***/
+
+ public function setTaxonomyCaps( $taxonomy, $object_type, $args )
+ {
+ global $wp_taxonomies;
+ if ( 'tema' == $taxonomy && ( ( is_string($object_type) && 'pauta' == $object_type ) || (is_array($object_type) && in_array('pauta', $object_type) ) ) )
+ {
+ $wp_taxonomies[ 'category' ]->cap->manage_terms = 'manage_delibera_cat_term';
+ $wp_taxonomies[ 'category' ]->cap->edit_terms = 'edit_delibera_cat_term';
+ $wp_taxonomies[ 'category' ]->cap->delete_terms = 'delete_delibera_cat_term';
+ $wp_taxonomies[ 'category' ]->cap->assign_terms = 'assign_delibera_cat_term';
+ }
+ }
+
+}
+
+$DeliberaConfPermission = new \Delibera\Conf\Permission();
diff --git a/admin/delibera_cron.php b/admin/delibera_cron.php
new file mode 100644
index 0000000..b3aa308
--- /dev/null
+++ b/admin/delibera_cron.php
@@ -0,0 +1,230 @@
+getTimestamp();
+
+ $exec = 0;
+ foreach ($crons as $key => $values)
+ {
+ if($key <= $now)
+ {
+ foreach ($values as $value)
+ {
+ $exec++;
+ try
+ {
+ if(is_array($value['call_back']))
+ {
+ 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']);
+ }
+ }
+ }
+ 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);
+ file_put_contents('/tmp/delibera_cron.log', $error, FILE_APPEND);
+ }
+ }
+ }
+ else
+ {
+ $new_crons[$key] = $values;
+ }
+ }
+ update_option('delibera-cron', $new_crons);
+
+ //wp_mail("jacson@ethymos.com.br", get_bloginfo('name'),"Foram executadas $exec tarefa(s)");
+ }
+
+ /**
+ * Registry a cron event check hourly
+ */
+ function registry()
+ {
+ 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');
+ }
+ }
+
+ /**
+ * Simple text list of cron jobs
+ */
+ function cronList()
+ {
+ ?>
+
+
+
$values)
+ {
+ echo "\n
[$key]: ".date("d/m/Y H:i:s", $key);
+ foreach ($values as $key2 => $value)
+ {
+ echo "\n
\t [$key2]";
+ foreach ($value as $ki => $item)
+ {
+ echo "\n
\t\t [$ki]";
+ if(is_array($item))
+ {
+ if(array_key_exists('post_ID', $item))
+ {
+ $post = get_post($item['post_ID']);
+ $title = get_the_title($post);
+ echo "\n$title";
+ }
+ echo "\n
\t\t ".print_r($item, true);
+ }
+ else
+ {
+ echo "\n
\t\t $item";
+ }
+ }
+ }
+ }?>
+
+
0)
+ {
+ $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);
+ if(!update_option('delibera-cron', $crons))
+ {
+ throw new \Exception("Cron not updated on $data, values:".print_r($crons[$data],true));
+ }
+ }
+ }
+
+ /**
+ * Remove a cron trigger
+ * @param int $postID
+ * @param function $callback function name or array($object, 'functio-name')
+ */
+ static function del($postID, $callback = false)
+ {
+ $crons = get_option('delibera-cron', array());
+ if(!is_array($crons)) $crons = array();
+
+ if( is_array($callback) )
+ {
+ $callback = $callback[0].'_'.$callback[1];
+ }
+
+ $crons_new = array();
+ foreach($crons as $cron_data => $cron_value)
+ {
+ $new_cron = array();
+ foreach ($cron_value as $call)
+ {
+ $cron_callback = $call['call_back'];
+ if( is_array($call['call_back']) )
+ {
+ $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'];
+
+ if($call['args']['post_ID'] != $postID || ($callback !== false && $callback != $cron_callback ))
+ {
+ $new_cron[] = $call;
+ }
+ }
+ if(count($new_cron) > 0)
+ {
+ $crons_new[$cron_data] = $new_cron;
+ }
+ }
+
+ ksort($crons_new);
+ update_option('delibera-cron', $crons_new);
+ }
+
+ public function addMenu($base_page)
+ {
+ add_submenu_page($base_page, __('Delibera Cron','delibera'),__('Delibera Cron','delibera'), 'manage_options', 'delibera-cron', array($this, 'confPage'));
+ }
+
+ public function confPage()
+ {
+ $this->cronList();
+ }
+
+ public function init()
+ {
+ if(is_super_admin()) // TODO load after init
+ {
+ add_action('delibera_menu_itens', array($this, 'addMenu'));
+ }
+ }
+
+}
+
+$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();
+ }*/
+//update_option('delibera-cron', array()); //delete cron
+?>
\ No newline at end of file
diff --git a/admin/delibera_flow.php b/admin/delibera_flow.php
new file mode 100644
index 0000000..8164801
--- /dev/null
+++ b/admin/delibera_flow.php
@@ -0,0 +1,688 @@
+ "delibera_flow",
+ "label" => __('Fluxo padrão de uma pauta?', 'delibera'),
+ "content" => ''
+ );
+ return $rows;
+ }
+
+ /**
+ * Filter main config option before save
+ * @param unknown $opts
+ */
+ public function preMainConfigSave($opts)
+ {
+ $save_opts = delibera_get_config();
+
+ if(array_key_exists('delibera_flow', $opts) && is_string($opts['delibera_flow']) && strlen($opts['delibera_flow']) > 1)
+ {
+ $opts['delibera_flow'] = explode(',', trim($opts['delibera_flow']));
+ }
+
+ if( empty($opts['delibera_flow']) || (is_string($opts['delibera_flow']) && strlen($opts['delibera_flow']) < 2 ) )
+ {
+ if(empty($save_opts['delibera_flow']))
+ {
+ $opts = $this->getMainConfig($opts);
+ }
+ else
+ {
+ $opts['delibera_flow'] = $save_opts['delibera_flow'];
+ }
+ }
+ return $opts;
+ }
+
+ /**
+ *
+ * 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)
+ {
+ $flow = implode(',', array_map("htmlspecialchars", $this->get($post->ID)) );
+ /*?>
+
+
+ id="delibera_flow" name="delibera_flow" class="delibera_flow widefat" value=""/>
+
+ confPage();
+ }
+
+ /**
+ * get topic flow sequence
+ * @param string $post_id
+ */
+ 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();
+ if($post_id == false)
+ {
+ return $default_flow;
+ }
+ }
+
+ if(array_key_exists($post_id, $this->flow)) return $this->flow[$post_id];
+
+ $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;
+ }
+ else
+ {
+ $this->flow[$post_id] = $default_flow;
+ return $default_flow;
+ }
+ }
+
+ /**
+ * List of Modules and each situation for get information about the module, like deadline
+ *
+ * @return \Delibera\Modules\ModuleBase[]
+ */
+ 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;
+ }
+
+ /**
+ * Get the last deadline before current module
+ * @param string $situacao
+ * @param int $post_id
+ *
+ * @return string date (dd/mm/YYYY)
+ */
+ public static function getLastDeadline($situacao, $post_id = false)
+ {
+ global $DeliberaFlow;
+ if(is_object($situacao))
+ {
+ $situacao = $situacao->slug;
+ }
+
+ if($post_id == false)
+ {
+ $post_id = get_the_ID();
+ }
+ $flow = $DeliberaFlow->get($post_id);
+ $modules = $DeliberaFlow->getFlowModules();
+
+ $now = array_search($situacao, $flow);
+ 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();
+ }
+ else
+ {
+ return date('d/m/Y');
+ }
+ }
+
+ /**
+ * Save post meta filter
+ * @param array $events_meta metas to save
+ * @param array $opt delibera config options
+ *
+ * @return array return filtered $events_meta array
+ */
+ public function savePostMetas($events_meta, $opt, $post_id)
+ {
+ if(array_key_exists('delibera_flow', $_POST) )
+ {
+ $flow = $_POST['delibera_flow'];
+
+ if(is_string($flow))
+ {
+ $flow = explode(',', trim($_POST['delibera_flow']));
+ }
+ $events_meta['delibera_flow'] = $flow;
+
+ $modules = $this->getFlowModules();
+ foreach ($flow as $situacao)
+ {
+ if(array_key_exists($situacao, $modules))
+ {
+ $events_meta = $modules[$situacao]->savePostMetas($events_meta, $opt);
+ }
+ }
+ }
+ return $events_meta;
+ }
+
+ /**
+ * Create a new date triggers for current module
+ * @param int $post_id
+ * @param string $appendDays number of day to append or false to get config option default
+ */
+ public function newDeadline($post_id, $appendDays = false)
+ {
+ $module = $this->getCurrentModule($post_id);
+ $module->newDeadline($post_id, $appendDays);
+ }
+
+ /**
+ * Action when pauta is saved
+ * @param int $post_id
+ * @param \WP_Post $post
+ * @param array $opt delibera config options
+ */
+ public function savePost($post_id, $post, $opt)
+ {
+ $this->newDeadline($post_id, 0);
+ }
+
+ /**
+ * When the topic is published
+ * @param int $postID
+ * @param array $opt delibera configs
+ * @param bool $alterar has been altered
+ */
+ public function publishPauta($postID, $opt)
+ {
+ /**
+ * Update flow meta after publish because is before save metas
+ */
+ if(array_key_exists('delibera_flow', $_POST))
+ {
+ $flow = array();
+ if(is_array($_POST['delibera_flow']))
+ {
+ $flow = array_map("strip_tags", $_POST['delibera_flow']);
+ }
+ else
+ {
+ $flow = explode(',', trim(strip_tags($_POST['delibera_flow'])));
+ }
+ update_post_meta($postID, 'delibera_flow', $flow);
+ //file_put_contents('/tmp/publish.log', date('Ymd H:i:s').$postID."\n", FILE_APPEND);
+ 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->slug, $flow);
+ $modules = $DeliberaFlow->getFlowModules(); //TODO cache?
+
+ if($current === false)
+ {
+ $situacoes = array();
+ foreach ($modules as $module)
+ {
+ foreach ($module->situacao as $sit)
+ {
+ $situacoes[$sit] = $module;
+ }
+ }
+ if (array_key_exists($situacao->slug, $situacoes))
+ {
+ return $situacoes[$situacao->slug];
+ }
+ $current = 0;
+ }
+ if(array_key_exists($current, $flow) && array_key_exists($flow[$current], $modules))
+ {
+ return $modules[$flow[$current]];
+ }
+ else
+ {
+ return array_shift($modules);
+ }
+ }
+
+ /**
+ * 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->slug, $flow);
+ $modules = $DeliberaFlow->getFlowModules(); //TODO cache?
+
+ if(array_key_exists($current+1, $flow))
+ {
+ $modules[$flow[$current+1]]->initModule($post_id);
+ }
+ else
+ {
+ //TODO the end?
+ }
+ }
+
+ /**
+ * Trigger module deadline
+ * @param int $post_id
+ */
+ public static function forcarFimPrazo($post_id)
+ {
+ if(is_object($post_id)) $post_id = $post_id->ID;
+
+ $current = \Delibera\Flow::getCurrentModule($post_id);
+ \Delibera\Cron::del($post_id);
+ call_user_func(array(get_class($current), 'deadline'), array('post_ID' => $post_id, 'prazo' => date('d/m/Y'), 'force' => true) );
+ }
+
+ /**
+ * Reopen finished topic
+ * @param int $postID
+ * @param bool $new_deadline_days if is true will add days to new dateline
+ */
+ public static function reabrirPauta($postID, $new_deadline_days = false)
+ {
+ global $DeliberaFlow;
+ $flow = $DeliberaFlow->get($postID);
+ $modules = $DeliberaFlow->getFlowModules();
+ $modules[$flow[0]]->initModule($postID);
+ if($new_deadline_days) $modules[$flow[0]]->newDeadline($postID, false);
+ }
+
+ /**
+ * 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();
+ }
+ }
+
+ /**
+ * 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, &$data = null)
+ {
+ $module = \Delibera\Flow::getCurrentModule($post_id);
+
+ $deadline = $module->getDeadline($post_id);
+
+ if($deadline == -1) return $deadline;
+
+ $dateTimeNow = new \DateTime();
+ $deadlineDate = \DateTime::createFromFormat('d/m/Y H:i:s', $deadline." 23:59:59");
+
+ $diff = $dateTimeNow->diff($deadlineDate);
+ if(!is_null($data))
+ {
+ $data = $deadlineDate->format('d/m/Y');
+ }
+ if($diff->d > 0)
+ {
+ return $diff->format('%r%a');
+ }
+ if($diff->d < 1 && ($diff->i || $diff->h || $diff->s))
+ {
+ return 1;
+ }
+ else
+ {
+ return -1;
+ }
+
+ }
+
+ 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($post = null, $flow = false)
+ {
+ $is_post_meta = !is_null($post);
+
+ /**
+ * Create Defaults value for topicMeta like in action TODO check if value is need after make this work
+ */
+ $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);
+ }
+
+ $modules = $this->getFlowModules();
+
+ if( $flow != false && is_array($flow) )
+ {
+ $allmodules = $modules;
+ $modules = array();
+ foreach ($flow as $step)
+ {
+ $modules[$step] = $allmodules[$step];
+ }
+ }
+
+ foreach ($modules as $key => $module)
+ {
+ $situacao = get_term_by('slug', $key, 'situacao');
+ ?>
+
+
name; ?>
+
+
+
+
" >
+ topicMeta($post, $custom, $options_plugin_delibera, $situacao, $disable_edicao);
+ }
+ else
+ {
+ $rows = array();
+ $rows = $module->configPageRows($rows, $options_plugin_delibera);
+ $table = delibera_form_table($rows);
+ if(has_filter('delibera_config_form'))
+ {
+ $table = apply_filters('delibera_config_form', $table, $opt);
+ }
+ echo $table;
+ }
+ if(!$is_post_meta) // Use post save
+ {?>
+
+
+
+
+
+ get();
+ ?>
+
+
+
+
+ listModulesConfigBoxes($post);
+ ?>
+
+
+
+ listModulesConfigBoxes($post, $flow);
+ ?>
+
+
+ id;
+ if(strpos($screenid, 'page_delibera') !== false || $screenid == 'pauta' )
+ {
+ $post_id = get_the_ID();
+ wp_enqueue_script('delibera-admin-flow', plugin_dir_url(__FILE__).'/js/flow.js', array( 'jquery-ui-core', 'jquery-ui-sortable'));
+ $data = array(
+ 'ajax_url' => admin_url('admin-ajax.php'),
+ 'post_id' => $post_id
+ );
+
+ wp_localize_script('delibera-admin-flow', 'delibera_admin_flow', $data);
+ wp_enqueue_script('jquery-ui-datepicker-ptbr', DELIBERA_DIR_URL.'/js/jquery.ui.datepicker-pt-BR.js', array('jquery-ui-datepicker'));
+ wp_enqueue_script('delibera-admin', plugin_dir_url(__FILE__).'/js/admin_scripts.js', array( 'jquery-ui-datepicker-ptbr'));
+
+ wp_enqueue_style('delibera-admin-flow',plugin_dir_url(__FILE__).'/css/flow.css');
+ }
+ }
+
+ /**
+ * Validate topic required data
+ * @param array $errors erros report array
+ * @param array $opt Delibera configs
+ * @param bool $autosave is autosave?
+ * @return array erros report array append if needed
+ */
+ public function checkPostData($errors, $opt, $autosave)
+ {
+ if(array_key_exists('delibera_flow', $_POST) )
+ {
+ $flow = $_POST['delibera_flow'];
+ if(is_string($flow))
+ {
+ $flow = explode(',', strip_tags($_POST['delibera_flow']));
+ }
+ $valida = is_array($flow) ? count($flow) : false;
+ if(!$autosave && ($valida === false || $valida < 1))
+ {
+ $errors[] = __("É necessário definir corretamente o fluxo da pauta", "delibera");
+ }
+ else
+ {
+ $modules = $this->getFlowModules();
+ foreach ($flow as $situacao)
+ {
+ if(array_key_exists($situacao, $modules))
+ {
+ $errors = $modules[$situacao]->checkPostData($errors, $opt, false);
+ }
+ }
+ }
+ }
+ else
+ {
+ $errors[] = __("É necessário definir corretamente o fluxo da pauta", "delibera");
+ }
+ return $errors;
+ }
+
+ public function saveFlowCallback()
+ {
+ $flow = explode(',', strip_tags($_POST['delibera_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($errors, $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)
+ {
+ if ( defined( 'DOING_AJAX' ) ) {
+ die(json_encode($all_errors));//TODO error notice and parser
+ }
+ wp_die( implode('
', $errors) );
+
+ }
+ foreach ($events_meta as $key => $value) // Buscar dados
+ {
+ update_post_meta($post_id, $key, $value); // Atualiza
+ }
+ }
+ else
+ {
+ $rows = array();
+ $rows = $this->configPageRows($rows, $opt);
+ $modules = \Delibera\Flow::getFlowModules();
+ foreach ($modules as $module)
+ {
+ $rows = $module->configPageRows($rows, $opt);
+ }
+ $oldFlow = implode(',', $opt['delibera_flow']);
+ $configs_to_save = array_value_recursive('id', $rows);
+ foreach ($configs_to_save as $option_name) //TODO better way to do this
+ {
+ if (isset($_POST[$option_name]))
+ {
+ $opt[$option_name] = htmlspecialchars($_POST[$option_name]);
+ }
+ else // checkbox maybe
+ {
+ $opt[$option_name] = "N";
+ }
+ }
+ $opt['delibera_flow'] = $flow;
+ if(! update_option('delibera-config', $opt) && $oldFlow != implode(',', $flow) )
+ {
+ $all_errors = array(__('can not update modules configs', 'delibera'));
+ }
+
+ if(count($all_errors) > 0)
+ {
+ die(json_encode($all_errors));//TODO error notice and parser
+ }
+ }
+ die('ok');
+ }
+
+ /**
+ * return list of Deadlines of a post in format: array of [situacao] => [date]
+ * @param int $post_id
+ * @return array
+ */
+ public static function getDeadlineDates($post_id)
+ {
+ global $DeliberaFlow;
+
+ $dates = array();
+ $flow = $DeliberaFlow->get($post_id);
+ $modules = $DeliberaFlow->getFlowModules();
+ foreach ($flow as $situacao)
+ {
+ if(array_key_exists($situacao, $modules))
+ {
+ $dates[$situacao] = $modules[$situacao]->getDeadline($post_id);
+ }
+ }
+ return $dates;
+ }
+
+}
+
+global $DeliberaFlow;
+$DeliberaFlow = new \Delibera\Flow();
diff --git a/delibera_user_painel.php b/admin/delibera_user_painel.php
similarity index 100%
rename from delibera_user_painel.php
rename to admin/delibera_user_painel.php
diff --git a/admin/images/iconSpirite.gif b/admin/images/iconSpirite.gif
new file mode 100644
index 0000000..8057c18
Binary files /dev/null and b/admin/images/iconSpirite.gif differ
diff --git a/js/admin_notifica_scripts.js b/admin/js/admin_notifica_scripts.js
similarity index 100%
rename from js/admin_notifica_scripts.js
rename to admin/js/admin_notifica_scripts.js
diff --git a/js/admin_scripts.js b/admin/js/admin_scripts.js
similarity index 100%
rename from js/admin_scripts.js
rename to admin/js/admin_scripts.js
diff --git a/admin/js/flow.js b/admin/js/flow.js
new file mode 100644
index 0000000..66cb007
--- /dev/null
+++ b/admin/js/flow.js
@@ -0,0 +1,238 @@
+/**
+ *
+ */
+
+function deliberaIsConfig()
+{
+ return delibera_admin_flow.post_id == '';
+}
+
+function deliberaFlowToggle(element)
+{
+ jQuery(element).parent().siblings('.dragbox-content').toggle();
+}
+
+function deliberaFlowRemove(element)
+{
+ var sel = confirm('do you want to delete this step?');
+ if (sel) {
+ jQuery(element).parent().parent().remove();
+ deliberaUpdateFlow();
+ }
+}
+
+var sortorder = '';
+function deliberaUpdateFlow()
+{
+ sortorder = '';
+ jQuery('.delibera-flow-panel').find('#delibera-flow-column2').each(function()
+ {
+ var itemorder = jQuery(this).sortable('toArray', { attribute: 'class'} );
+ for (i = 0; i < itemorder.length; i++)
+ {
+ var tmp = itemorder[i].replace("dragbox ", "").replace(" clone", "");
+ itemorder[i] = tmp;
+ }
+ sortorder += itemorder.toString();
+ });
+ jQuery('#delibera_flow').val(sortorder);
+ jQuery('#delibera-flow-column2').trigger('deliberaUpdateFlow');
+ if(deliberaIsConfig())
+ {
+ updateDates();
+ deliberaHideUsedModules()
+
+ }
+}
+
+function deliberaUsedModule(id)
+{
+ if(jQuery('.delibera-flow-panel').find("#delibera-flow-column2").find("."+id).length > 1)
+ {
+ return true;
+ }
+ return false;
+}
+
+function deliberaHideUsedModules()
+{
+ /** remove after multiple of the same has implemented **/
+ if(!deliberaIsConfig())
+ {
+ var boxes = jQuery('#delibera-flow-column2').find('.dragbox');
+ jQuery('.delibera-flow-panel').find("#delibera-flow-column1").find('.dragbox').show();
+ for (var i = 0; i < boxes.length; i++)
+ {
+ var itemclass = jQuery(boxes[i]).attr('class').replace("dragbox ", "").replace(" clone", "");
+ //console.log(itemclass);
+ jQuery('.delibera-flow-panel').find("#delibera-flow-column1").find("."+itemclass).hide();
+ }
+ /** END remove after multiple of the same has implemented **/
+ }
+}
+
+Date.prototype.addDays = function(days)
+{
+ var dat = new Date(this.valueOf());
+ dat.setDate(dat.getDate() + days);
+ return dat;
+}
+
+function updateDates()
+{
+ var boxes = jQuery('#delibera-flow-column2').find('.dragbox');
+ var lastDate = new Date();
+ for (var i = 0; i < boxes.length; i++)
+ {
+ var dateinput = jQuery(boxes[i]).find('input.hasDatepicker');
+ var daysinput = jQuery(boxes[i]).find('input.delibera_flow_module_days');
+ var daysToAdd = Number(jQuery(daysinput).val());
+ lastDate = lastDate.addDays(daysToAdd);
+ jQuery(dateinput).val( ('00' + lastDate.getDate()).slice(-2) + "/" + ('00' + (lastDate.getMonth()+1)).slice(-2) + "/" + lastDate.getFullYear());
+ }
+}
+
+jQuery(document).ready(function() {
+ deliberaHideUsedModules();
+ jQuery('.delibera-flow-panel').find('span.maxmin').click(function() {
+ deliberaFlowToggle(this);
+ });
+
+ jQuery('.delibera-flow-panel').find('span.delete').click(function() {
+ deliberaFlowRemove(this);
+ });
+
+ jQuery('.delibera-flow-column').sortable({
+ connectWith : '.delibera-flow-column',
+ handle : 'h2',
+ cursor : 'move',
+ placeholder : 'placeholder',
+ forcePlaceholderSize : true,
+ opacity : 0.4,
+ helper : function(e, div) {
+ copyHelper = div.clone().insertAfter(div);
+ jQuery(copyHelper).find('span.maxmin').click(function() {
+ deliberaFlowToggle(this);
+ });
+ jQuery(copyHelper).find('span.delete').click(function() {
+ deliberaFlowRemove(this);
+ });
+ jQuery(copyHelper).find('.hasdatepicker:not([readonly])').removeAttr('id');
+ jQuery(copyHelper).find('.hasdatepicker:not([readonly])').removeClass('hasDatepicker').datepicker({
+ userLang : 'pt-BR',
+ americanMode: false,
+ });
+ div_copy = div.clone();
+ return div_copy;
+ },
+ stop : function(event, ui) {
+ copyHelper && copyHelper.remove();
+ jQuery(ui.item).addClass('clone');
+ jQuery(ui.item).find('h2').click();
+ sortorder = '';
+ jQuery(ui.item).find('.hasdatepicker:not([readonly])').removeClass('hasDatepicker').datepicker({
+ userLang : 'pt-BR',
+ americanMode: false,
+ });
+ jQuery(ui.item).find("input").prop('disabled', false);
+ deliberaUpdateFlow();
+ if(!deliberaIsConfig() && ui.item.parent().attr('id') != 'delibera-flow-column1' ) {
+ jQuery(ui.item).find('.dragbox-content').show();
+ }
+ }
+ });
+ jQuery('.delibera-flow-panel').find("#delibera-flow-column2").sortable({
+ receive : function(e, ui) {
+ copyHelper = null;
+ var id = ui.item.attr('class').replace("dragbox ", "").replace(" clone", "");
+ if(deliberaUsedModule(id))
+ {
+ ui.sender.sortable("cancel");
+ }
+ }
+ });
+ jQuery('.delibera-flow-panel').find("#delibera-flow-column1").sortable({
+ receive : function(e, ui) {
+ if(ui.item.hasClass("clone"))
+ {
+ ui.sender.sortable("cancel");
+ }
+ }
+ });
+ if(deliberaIsConfig())
+ {
+ jQuery('.delibera-flow-panel').find("#delibera-flow-column2").find("input").prop('disabled', true);
+ }
+ else
+ {
+ jQuery('.delibera-flow-panel').find("#delibera-flow-column1").find("input").prop('disabled', true);
+ }
+
+ jQuery('.delibera-flow-panel').find("input.dragbox-bt-save").click(function(){
+ deliberaUpdateFlow();
+ var data = {
+ action : "delibera_save_flow",
+ delibera_flow: sortorder,
+ post_id: jQuery('#delibera-flow-postid').val(),
+ nonce: jQuery('#_delibera-flow-nonce').val()
+ };
+ if(deliberaIsConfig())
+ {
+ jQuery('.delibera-flow-panel').find('#delibera-flow-column1').find('input:not(input[type=button], input[type=submit], input[type=reset]), textarea, select').each(function(){
+ if(this.type == 'checkbox')
+ {
+ if(this.checked) data[this.name] = this.value;
+ }
+ else
+ {
+ data[this.name] = this.value;
+ }
+ });
+ }
+ else
+ {
+ jQuery('.delibera-flow-panel').find('#delibera-flow-column2').find('input:not(input[type=button], input[type=submit], input[type=reset]), textarea, select').each(function(){
+ if(this.name.indexOf('[') > -1)
+ {
+ if(data[this.name] == null)
+ {
+ data[this.name] = [[
+ this.id,
+ this.value
+ ]];
+ }
+ else
+ {
+ data[this.name].push([
+ this.id,
+ this.value
+ ]);
+ }
+ }
+ else
+ {
+ if(this.type == 'checkbox')
+ {
+ if(this.checked) data[this.name] = this.value;
+ }
+ else
+ {
+ data[this.name] = this.value;
+ }
+ }
+ });
+ }
+
+ jQuery.post(
+ delibera_admin_flow.ajax_url,
+ data,
+ function(response) {
+ if(response == 'ok')
+ alert("Saved");
+ //window.location.reload(true);
+ else
+ alert("Errors");
+ }
+ );
+ });
+});
\ No newline at end of file
diff --git a/css/delibera.css b/css/delibera.css
index 466311e..f274bf6 100644
--- a/css/delibera.css
+++ b/css/delibera.css
@@ -40,4 +40,4 @@ background:url('../qtranslate/flags/es.png') left bottom no-repeat;
.delibera-config-mensagem
{
height: 140px;
-}
\ No newline at end of file
+}
diff --git a/css/fonts/fontello-6acce062/LICENSE.txt b/css/fonts/fontello-6acce062/LICENSE.txt
new file mode 100755
index 0000000..2e7737a
--- /dev/null
+++ b/css/fonts/fontello-6acce062/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-6acce062/README.txt b/css/fonts/fontello-6acce062/README.txt
new file mode 100755
index 0000000..beaab33
--- /dev/null
+++ b/css/fonts/fontello-6acce062/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-icon-spin20xe800
+
delibera-icon-ok0xe801
+
delibera-icon-plus0xe802
+
delibera-icon-print0xe803
+
+
+
delibera-icon-down-open0xe804
+
delibera-icon-left-open0xe805
+
delibera-icon-right-open0xe806
+
delibera-icon-up-open0xe807
+
+
+
delibera-icon-thumbs-up-alt0xe808
+
delibera-icon-thumbs-down-alt0xe809
+
delibera-icon-reply0xe80a
+
delibera-icon-trash0xe80b
+
+
+
delibera-icon-attach0xe80c
+
delibera-icon-users0xe80d
+
delibera-icon-chat0xe80e
+
delibera-icon-calendar0xe80f
+
+
+
delibera-icon-newspaper0xe810
+
delibera-icon-key0xe811
+
delibera-icon-cancel0xe812
+
delibera-icon-thumbs-up0xe813
+
+
+
delibera-icon-thumbs-down0xe814
+
delibera-icon-chat-empty0xe815
+
delibera-icon-cog0xe816
+
delibera-icon-facebook-official0xe817
+
+
+
delibera-icon-facebook0xe818
+
delibera-icon-gplus-squared0xe819
+
delibera-icon-gplus0xe81a
+
delibera-icon-twitter0xe81b
+
+
+
delibera-icon-twitter-squared0xe81c
+
delibera-icon-whatsapp0xe81d
+
delibera-icon-edit0xe81e
+
+
+
+
+
\ No newline at end of file
diff --git a/css/fonts/fontello-6acce062/font/delibera.eot b/css/fonts/fontello-6acce062/font/delibera.eot
new file mode 100755
index 0000000..8f04a5c
Binary files /dev/null and b/css/fonts/fontello-6acce062/font/delibera.eot differ
diff --git a/css/fonts/fontello-6acce062/font/delibera.svg b/css/fonts/fontello-6acce062/font/delibera.svg
new file mode 100755
index 0000000..e086ead
--- /dev/null
+++ b/css/fonts/fontello-6acce062/font/delibera.svg
@@ -0,0 +1,72 @@
+
+
+
\ No newline at end of file
diff --git a/css/fonts/fontello-6acce062/font/delibera.ttf b/css/fonts/fontello-6acce062/font/delibera.ttf
new file mode 100755
index 0000000..118ecb5
Binary files /dev/null and b/css/fonts/fontello-6acce062/font/delibera.ttf differ
diff --git a/css/fonts/fontello-6acce062/font/delibera.woff b/css/fonts/fontello-6acce062/font/delibera.woff
new file mode 100755
index 0000000..d0c9f96
Binary files /dev/null and b/css/fonts/fontello-6acce062/font/delibera.woff differ
diff --git a/css/fonts/fontello-6acce062/font/delibera.woff2 b/css/fonts/fontello-6acce062/font/delibera.woff2
new file mode 100755
index 0000000..2964224
Binary files /dev/null and b/css/fonts/fontello-6acce062/font/delibera.woff2 differ
diff --git a/delibera-edit-form-comment.php b/delibera-edit-form-comment.php
index 096d167..611f6d4 100644
--- a/delibera-edit-form-comment.php
+++ b/delibera-edit-form-comment.php
@@ -1,17 +1,31 @@
+
+