forked from guaycuru/gde
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
739 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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ão foi possível enviar a Mensagem...\")"; | ||
} | ||
|
||
echo "});</script>"; | ||
|
||
echo $FIM; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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í-los:<br />"; | ||
foreach($verificar as $erro) { | ||
echo $erro."<br />"; | ||
} | ||
echo "\");"; | ||
} else { | ||
if($Rec->Recomendar($_Usuario, $_POST['mensagem']) === true) | ||
echo "$.guaycuru.confirmacao(\"Sua Recomendação foi enviada com sucesso! O GDE agradece!!!\", \"".CONFIG_URL."/index/\")"; | ||
else | ||
echo "$.guaycuru.confirmacao(\"Não foi possível enviar a Recomendação.\")"; | ||
} | ||
} | ||
|
||
echo "});</script>"; | ||
|
||
echo $FIM; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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ínimo 3 e no máximo 16 caracteres."; | ||
|
||
if(preg_match('/^[A-Z0-9_]+/i', $this->login) == 0) | ||
$erros[] = "O login digitado é inválido. Deve conter apenas letras, nú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 é inválido."; | ||
|
||
if($this->Existe_Dados() === true) | ||
$erros[] = "O email ou o RA digitado já está 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; | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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ê 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ão</option><option value="Duvida">Dúvida</option><option value="Reclamacao">Reclamaçã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; ?> |
Oops, something went wrong.