Exemplo n.º 1
0
 public function add()
 {
     //name
     $nome = DataHandler::getValueByArrayIndex($_POST, "nome");
     //title
     $sobreNome = DataHandler::getValueByArrayIndex($_POST, "sobreNome");
     //author
     $email = DataHandler::getValueByArrayIndex($_POST, "email");
     //hat
     $companhia = DataHandler::getValueByArrayIndex($_POST, "companhia");
     //slug
     $profissao = DataHandler::getValueByArrayIndex($_POST, "provissao");
     //key_words
     $arquiteto = DataHandler::getValueByArrayIndex($_POST, "arquiteto");
     $erros = array();
     //validação
     if (!Validation::validateEmail($email)) {
         $erros[] = "email inválido";
     }
     if (!$nome) {
         $erros[] = "nome inválido";
     }
     if (!$sobreNome) {
         $erros[] = "sobrenome incorreto";
     }
     $ReturnResultVO = new ReturnResultVO($erros);
     if (!count($erros) > 0) {
         //nao tem erros na validação
         $ContentSiteVO = new ContentSiteVO();
         $ContentSiteVO->setName($nome);
         $ContentSiteVO->setTitle($sobreNome);
         $ContentSiteVO->setAuthor($email);
         $ContentSiteVO->setHat($companhia);
         $ContentSiteVO->setSlug($profissao);
         $ContentSiteVO->setKeyWords($arquiteto);
         $ReturnResultVO = $ContentSiteVO->commit();
         if ($ReturnResultVO->success) {
             //agora poe esse content na categoria correta
             $CategoryVO = new CategoryVO();
             echo "id de category necessária para newslatter funcionar";
             exit;
             $CategoryVO->setId(127, TRUE);
             if ($ContentSiteVO->getId() > 0) {
                 $CategoryVO->addLink("newslatter", $ContentSiteVO->getId());
                 $CategoryVO->commit();
             }
         }
     }
     echo $ReturnResultVO->toJson();
     exit;
 }