Skip to content

Commit

Permalink
Algumas views simples
Browse files Browse the repository at this point in the history
  • Loading branch information
guaycuru committed Nov 29, 2016
1 parent 8326c81 commit dc2b44e
Show file tree
Hide file tree
Showing 14 changed files with 739 additions and 67 deletions.
19 changes: 19 additions & 0 deletions ajax/contato.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

define('JUST_INC', true);

require_once('../common/common.inc.php');
require_once('../classes/Recomendacao.inc.php');

echo "<script>$(document).ready( function(){";

if(isset($_POST['enviar'])) {
if(Envia_Email("gde-support@googlegroups.com", "GDE - ".$_POST['assunto'], $_POST['mensagem']."\n\n".print_r($_Usuario, true), $_Usuario->getEmail()) !== false)
echo "$.guaycuru.confirmacao(\"Sua Mensagem foi enviada com sucesso! O GDE agradece!!!\", \"".CONFIG_URL."index\")";
else
echo "$.guaycuru.confirmacao(\"N&atilde;o foi poss&iacute;vel enviar a Mensagem...\")";
}

echo "});</script>";

echo $FIM;
32 changes: 32 additions & 0 deletions ajax/recomendar.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

define('JUST_INC', true);

require_once('../common/common.inc.php');

echo "<script>$(document).ready( function(){";

if(isset($_POST['enviar'])) {
$Rec = new Recomendacao();
$Rec->setChave();
$Rec->setLogin($_Usuario->getLogin(true));
$Rec->setEmail($_POST['email']);
$Rec->setRA(intval($_POST['ra']));
$verificar = $Rec->Verificar();
if($verificar !== true) {
echo "$.guaycuru.confirmacao(\"Os seguintes erros foram encontrados, favor corrig&iacute;-los:<br />";
foreach($verificar as $erro) {
echo $erro."<br />";
}
echo "\");";
} else {
if($Rec->Recomendar($_Usuario, $_POST['mensagem']) === true)
echo "$.guaycuru.confirmacao(\"Sua Recomenda&ccedil;&atilde;o foi enviada com sucesso! O GDE agradece!!!\", \"".CONFIG_URL."/index/\")";
else
echo "$.guaycuru.confirmacao(\"N&atilde;o foi poss&iacute;vel enviar a Recomenda&ccedil;&atilde;o.\")";
}
}

echo "});</script>";

echo $FIM;
6 changes: 6 additions & 0 deletions classes/GDE/Dado.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,5 +237,11 @@ class Dado extends Base {
*/
protected $max_online_ts;

public static function Pega_Dados() {
$Dados = self::Load(1);
if($Dados === null)
return array();
return get_object_vars($Dados);
}

}
134 changes: 134 additions & 0 deletions classes/GDE/Recomendacao.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
<?php

namespace GDE;

use Doctrine\ORM\Mapping as ORM;

/**
* Recomendacao
*
* @ORM\Table(name="gde_recomendacoes", uniqueConstraints={@ORM\UniqueConstraint(name="ra", columns={"ra"}), @ORM\UniqueConstraint(name="email", columns={"email"})}, indexes={@ORM\Index(name="login", columns={"login"}), @ORM\Index(name="recomendado", columns={"recomendado"})})
* @ORM\Entity
*/
class Recomendacao extends Base {
/**
* @var string
*
* @ORM\Column(name="chave", type="string", length=16, nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
protected $chave = '';

/**
* @var integer
*
* @ORM\Column(name="ra", type="integer", options={"unsigned"=true}), nullable=false)
*/
protected $ra;

/**
* @var string
*
* @ORM\Column(name="email", type="string", length=255, nullable=false)
*/
protected $email;

/**
* @var Usuario
*
* @ORM\ManyToOne(targetEntity="Usuario")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="login", referencedColumnName="login")
* })
*/
protected $login;

/**
* @var Usuario
*
* @ORM\ManyToOne(targetEntity="Usuario")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="recomendado", referencedColumnName="login")
* })
*/
protected $recomendado;

/**
* getFinal
*
* Retorna o rodape do email
*
* @param Usuario $Usuario
* @return string
*/
public static function getFinal(Usuario $Usuario) {
return "\r\n\r\nMensagem enviada por ".$Usuario->getNome(true)." pelo GDE - ".CONFIG_URL;
}

/**
* Define uma nova chave aleatoria e unica
*
* @return string
*/
public function setChave() {
do {
$chave = Util::Code(16);
} while(self::FindOneBy(array('chave' => $chave)) !== null);
return $this->chave = $chave;
}

/**
* Existe_Dados
*
* Verifica se ja existe um usuario ou recomendacao com o email ou RA informados
*
* @return bool
*/
public function Existe_Dados() {
return (
(Usuario::FindOneBy(array('email' => $this->getEmail(false))) !== null) ||
(Usuario::FindOneBy(array('ra' => $this->getRA(false))) !== null) ||
(self::FindOneBy(array('email' => $this->getEmail(false))) !== null) ||
(self::FindOneBy(array('ra' => $this->getRA(false))) !== null)
);
}

public function Verificar() {
$erros = array();

if((strlen($this->login) < 3) || (strlen($this->login) > 16))
$erros[] = "O login deve ter no m&iacute;nimo 3 e no m&aacute;ximo 16 caracteres.";

if(preg_match('/^[A-Z0-9_]+/i', $this->login) == 0)
$erros[] = "O login digitado &eacute; inv&aacute;lido. Deve conter apenas letras, n&uacute;meros e underscores.";

if((strlen($this->email) < 2) || (preg_match('/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i', $this->email) == 0))
$erros[] = "O email digitado &eacute; inv&aacute;lido.";

if($this->Existe_Dados() === true)
$erros[] = "O email ou o RA digitado j&aacute; est&aacute; cadastrado no sistema.";

if(count($erros) == 0)
return true;
else
return $erros;
}

/**
* Recomendar
*
* @param $Usuario
* @param $mensagem
* @return bool
*/
public function Recomendar($Usuario, $mensagem) {
$res = mail($this->getEmail(true), 'Voce conhece o GDE?', strip_tags($mensagem).self::getFinal($Usuario, $this->getChave(true))."\n\n", 'From: '.$Usuario->getEmail(true) . "\r\n" .'Reply-To: '.$Usuario->getEmail(true) . "\r\n" . 'X-Mailer: PHP/' . phpversion());

if($res !== false)
return $this->Save(true);
else
return false;
}

}
58 changes: 0 additions & 58 deletions classes/GDE/Recomendacoes.inc.php

This file was deleted.

8 changes: 8 additions & 0 deletions classes/GDE/Util.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
namespace GDE;

class Util {
public static function Code($nc, $a='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789') {
$l = strlen($a) - 1;
$r='';
while($nc-->0)
$r .= $a{mt_rand(0,$l)};
return $r;
}

public static function Limita($texto, $tamanho) {
return (strlen($texto) <= $tamanho) ? $texto : substr($texto, 0, $tamanho-3).'...';
}
Expand Down
18 changes: 9 additions & 9 deletions common/common.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ function Tempo_Geracao($inicio) {
<li><a href="<?= CONFIG_URL; ?>visoes/Arvore.php">&Aacute;rvore / Integraliza&ccedil;&atilde;o</a></li>
<li><a href="<?= CONFIG_URL; ?>visoes/Avaliar.php">Avaliar Professores</a></li>
<li><a href="<?= CONFIG_URL; ?>visoes/Eliminador.php">Eliminar Disciplinas</a></li>
<li><a href="<?= CONFIG_URL; ?>visoes/Mapa.php">Mapa do Campus</a></li>
<li><a href="<?= CONFIG_URL; ?>mapa/">Mapa do Campus</a></li>
<li><a href="<?= CONFIG_URL; ?>visoes/Planejador.php">Planejador</a></li>
<li><a class="ui-corner-bottom" href="<?= CONFIG_URL; ?>visoes/Rankings.php">Rankings</a></li>
</ul>
Expand All @@ -226,18 +226,18 @@ function Tempo_Geracao($inicio) {
<li><a href="<?= CONFIG_URL; ?>visoes/EditarPerfil.php">Editar Perfil</a></li>
<li><a href="<?= CONFIG_URL; ?>visoes/Configuracoes.php">Configura&ccedil;&otilde;es da Conta</a></li>
<li><a href="<?= CONFIG_URL; ?>visoes/Amigos.php">Meus Amigos</a></li>
<li><a href="<?= CONFIG_URL; ?>visoes/Recomendar.php">Convidar um Amigo</a></li>
<li><a href="<?= CONFIG_URL; ?>visoes/CadastroGrupo.php">Criar Grupo</a></li>
<li><a class="ui-corner-bottom" href="<?= CONFIG_URL; ?>visoes/Grupos.php">Meus Grupos</a></li>
<li><a class="ui-corner-bottom" href="<?= CONFIG_URL; ?>recomendar/">Convidar um Amigo</a></li>
<!-- <li><a href="<?= CONFIG_URL; ?>visoes/CadastroGrupo.php">Criar Grupo</a></li>
<li><a class="ui-corner-bottom" href="<?= CONFIG_URL; ?>visoes/Grupos.php">Meus Grupos</a></li> -->
</ul>
</li>
<li><a href="#" onclick="return false;">Ajuda</a>
<ul>
<li><a href="<?= CONFIG_URL; ?>visoes/Contato.php">Contato</a></li>
<li><a href="<?= CONFIG_URL; ?>visoes/Estatisticas.php">Estat&iacute;sticas</a></li>
<li><a href="<?= CONFIG_URL; ?>visoes/FAQ.php">Perguntas Frequentes</a></li>
<li><a href="<?= CONFIG_URL; ?>visoes/Sobre.php">Sobre o GDE</a></li>
<li><a class="ui-corner-bottom" href="<?= CONFIG_URL; ?>visoes/Termos.php">Termos de Uso</a></li>
<li><a href="<?= CONFIG_URL; ?>contato/">Contato</a></li>
<li><a href="<?= CONFIG_URL; ?>estatisticas/">Estat&iacute;sticas</a></li>
<li><a href="<?= CONFIG_URL; ?>faq/">Perguntas Frequentes</a></li>
<li><a href="<?= CONFIG_URL; ?>sobre/">Sobre o GDE</a></li>
<li><a class="ui-corner-bottom" href="<?= CONFIG_URL; ?>termos/">Termos de Uso</a></li>
</ul>
</li>
<li><a href="#" onclick="Logout(); return false;">Sair</a></li>
Expand Down
27 changes: 27 additions & 0 deletions views/contato.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace GDE;

define('TITULO', 'Contato');

require_once('../common/common.inc.php');

?>
Antes de enviar sua mensagem, consulte as "<a href="<?= CONFIG_URL; ?>faq/">Perguntas Frequentes</a>", talvez voc&ecirc; encontre respostas...<br /><br />
<h2>Recomendar o GDE</h2>
<form method="post" action="<?= CONFIG_URL; ?>ajax/contato/" target="controle">
<table border="0">
<tr>
<td>Assunto:</td>
<td><select name="assunto"><option value="Elogio">Elogio</option><option value="Sugestao">Sugest&atilde;o</option><option value="Duvida">D&uacute;vida</option><option value="Reclamacao">Reclama&ccedil;&atilde;o</option><option value="BUG">Problema / BUG</option></select></td>
</tr>
<tr>
<td>Mensagem:</td>
<td><textarea name="mensagem" cols="50" rows="10"></textarea></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="enviar" value=" " alt="Enviar" class="botao_enviar" /></td>
</tr>
</table>
</form>
<?= $FIM; ?>
Loading

0 comments on commit dc2b44e

Please sign in to comment.