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
5 changed files
with
76 additions
and
83 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 |
---|---|---|
@@ -1,32 +1,34 @@ | ||
<?php | ||
|
||
define('JUST_INC', true); | ||
namespace GDE; | ||
|
||
define('JSON', true); | ||
require_once('../common/common.inc.php'); | ||
|
||
echo "<script>$(document).ready( function(){"; | ||
$Rec = new Recomendacao(); | ||
$Rec->setChave(); | ||
$Rec->setRecomendante($_Usuario); | ||
$Rec->setEmail($_POST['email']); | ||
$Rec->setRA($_POST['ra']); | ||
|
||
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.\")"; | ||
} | ||
$erros = array(); | ||
if((strlen($_POST['email']) < 2) || (preg_match('/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i', $_POST['email']) == 0)) | ||
$erros[] = "O email digitado é inválido."; | ||
if($Rec->Existe_Dados() === true) | ||
$erros[] = "O email ou o RA digitado já está cadastrado no sistema."; | ||
if(count($erros) > 0) { | ||
die(Base::To_JSON(array( | ||
'ok' => false, | ||
'erros' => $erros | ||
))); | ||
} else { | ||
if($Rec->Recomendar($_Usuario, $_POST['mensagem']) === true) | ||
die(Base::To_JSON(array( | ||
'ok' => true | ||
))); | ||
else | ||
die(Base::To_JSON(array( | ||
'ok' => false, | ||
'erros' => array('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
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