diff --git a/amd/src/config.js b/amd/src/config.js index 222dc3b..6febb02 100644 --- a/amd/src/config.js +++ b/amd/src/config.js @@ -15,7 +15,7 @@ define(['jquery', 'js/jquery.dataTables.min.js', 'js/jquery-ui.min.js'] , functi // Obtém dados de todas as conversas var tabelaContatos = $('#tabela_contatos').DataTable({ ajax: { - url: "proxy.php?schoolInitials=" + school + "&answered=" + 0, + url: "proxy.php?answered=" + 0, dataSrc:"" }, columns: [ diff --git a/datatable.js b/datatable.js deleted file mode 100644 index 399e31b..0000000 --- a/datatable.js +++ /dev/null @@ -1,4 +0,0 @@ -YUI().use("datatable", "datasource-get", "datasource-jsonschema", "datatable-datasource", function(Y) { - - -}); \ No newline at end of file diff --git a/httpful.phar b/httpful.phar deleted file mode 100644 index 87fb392..0000000 Binary files a/httpful.phar and /dev/null differ diff --git a/index.php b/index.php index 3fd66bb..cbbc6d4 100644 --- a/index.php +++ b/index.php @@ -1,7 +1,7 @@ dirroot.'/blocks/escola_modelo/classes/util.php'); // Check if user is logged and not guest require_login(); @@ -9,6 +9,10 @@ if (isguestuser()) { die(); } +if(!evlHabilitada()) { + die('Esta funcionalidade requer que a integração com a EVL esteja habilitada!'); +} + // Prepare page $context = context_system::instance(); $PAGE->set_pagelayout('standard'); diff --git a/indexyui.php b/indexyui.php deleted file mode 100644 index 9a61e09..0000000 --- a/indexyui.php +++ /dev/null @@ -1,281 +0,0 @@ -set_pagelayout('standard'); -$PAGE->set_url('/blocks/fale_conosco/index.php'); -//$PAGE->requires->js('/blocks/fale_conosco/datatable.js', true); -$PAGE->set_context($context); - - -// Get data -$strtitle = get_string('fale_conosco', 'block_fale_conosco'); -$user = $USER; -//$icon = $OUTPUT->pix_icon('print', get_string('print', 'block_fale_conosco'), 'block_fale_conosco'); - -global $DB, $CFG; -/* -$uri = 'https://escolamodelows.interlegis.leg.br/api/v1/fale_conosco'; -$response = \Httpful\Request::get($uri) - //->sendsJson() - //->body('{"school_initial": "SSL"}') - ->expectsJson() - ->send(); - -$data=$response->body; - -html_writer::span("

Quantidade" . count($data) . '

'); - - -// Print the header -$PAGE->navbar->add($strtitle); -$PAGE->set_title($strtitle); -$PAGE->set_heading($strtitle); - -*/ -//$PAGE->requires->css('/blocks/fale_conosco/printstyle.css'); -echo $OUTPUT->header(); - -// Print concluded courses -echo $OUTPUT->box_start('generalbox boxaligncenter'); -echo $OUTPUT->heading(get_string('fale_conosco', 'block_fale_conosco')); - - -//Instantiate simplehtml_form -$mform = new searchform(); - -//Form processing and displaying is done here -if ($mform->is_cancelled()) { - //Handle form cancel operation, if cancel button is present on form -} else if ($fromform = $mform->get_data()) { - //In this case you process validated data. $mform->get_data() returns data posted in form. -} else { - // this branch is executed if the form is submitted but the data doesn't validate and the form should be redisplayed - // or on the first display of the form. - - //Set default data (if any) - //$mform->set_data($toform); - //displays the form - $mform->display(); -} - -/* -$table = new html_table(); -$table->align = array('left', 'left', 'left', 'center'); -$table->width = '100%'; -$table->head = array( - get_string('id', 'block_fale_conosco'), - get_string('name', 'block_fale_conosco'), - get_string('email, block_fale_conosco'), - get_string('cpf', 'block_fale_conosco') -); - -$table->data = $data; -echo html_writer::table($table); -*/ -?> - - - - - - - - - - - - - - - - - - ... - -
IDSenderReceived
10238eduardo@pingpong.com14.10.2013
- - - -
- -
-
-
-
-

Mensagem específica

-
-
-
- - - - - - - - - - - - - - - - - - -
User IDTitleBody
- -box_end(); -echo $OUTPUT->footer(); diff --git a/proxy.php b/proxy.php index 1b5fb4f..379c3f5 100644 --- a/proxy.php +++ b/proxy.php @@ -1,23 +1,32 @@ dirroot.'/blocks/escola_modelo/classes/util.php'); +include_once($CFG->dirroot . '/blocks/escola_modelo/lib/httpful.phar'); + +if(!evlHabilitada()) { + die('Esta funcionalidade requer que a integração com a EVL esteja habilitada!'); +} + header("Content-Type: application/json"); -if(isset($_GET["conversationID"])) { + // FIXME incluir APIKEY em todas as chamadas + + // Obtém todas as mensagens de uma conversa + if(isset($_GET["conversationID"])) { $id = intval($_GET['conversationID']); - $uri = 'https://escolamodelows.interlegis.leg.br/api/v1/fale_conosco/mensagens'; - // $uri = 'http://localhost:3000/api/v1/fale_conosco/mensagens'; + $uri = evlURLWebServices() . '/api/v1/fale_conosco/mensagens'; $response = \Httpful\Request::post($uri) ->sendsJson() ->body('{"conversation_id": "' . $id . '"}') ->send(); -} elseif(isset($_REQUEST["addMessage"])) { +} + // Adiciona uma nova mensagem a uma conversa + elseif(isset($_REQUEST["addMessage"])) { $id = intval($_GET['addMessage']); $cpf = $USER->username; $description = $_GET['description']; - $uri = 'https://escolamodelows.interlegis.leg.br/api/v1/fale_conosco/adicionar'; - // $uri = 'http://localhost:3000/api/v1/fale_conosco/adicionar'; + $uri = evlURLWebServices() . '/api/v1/fale_conosco/adicionar'; $response = \Httpful\Request::post($uri) ->sendsJson() ->body('{ @@ -29,18 +38,20 @@ if(isset($_GET["conversationID"])) { "conversation_id": "' . $id . '" }') ->send(); -} elseif(isset($_REQUEST["schoolInitials"])) { +} + // Pega todas as conversas de determinada escola, em determinada situação + // FIXME parametrizar limite e tratar paginação + else { $was_answered = intval($_GET['answered'])== 0 ? 'false':'true'; $was_answered = trim($was_answered, '"'); - $uri = 'https://escolamodelows.interlegis.leg.br/api/v1/fale_conosco/conversa'; - // $uri = 'http://localhost:3000/api/v1/fale_conosco/conversa'; + $uri = evlURLWebServices() . '/api/v1/fale_conosco/conversa'; $response = \Httpful\Request::post($uri) ->sendsJson() ->body( '{ - "school_initials": "SSL", + "school_initials": "' . evlSiglaEscola() . '", "page" : "1", - "limit": "2000", + "limit": "2000", "was_answered": '. $was_answered .' }') ->send();