Example #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;
 }
Example #2
0
 public function commit()
 {
     //iniciando o retorno padrao
     $HttpReturnResult = new HttpResult();
     $CategoryVO = new CategoryVO();
     if ($_POST["category_id"] == NULL) {
         $_POST["category_id"] = 0;
     }
     $_POST["active"] = 1;
     $CategoryVO->setFetchArray($_POST);
     $ResultValidate = $CategoryVO->validate();
     $resultPage = new DefaultPage();
     //Debug::print_r($ResultValidate); exit();
     if ($ResultValidate->success) {
         $ReturnResult = $CategoryVO->commit();
         //Debug::print_r($ReturnResult);exit();
         if ($ReturnResult->success) {
             Navigation::redirect("admin/category/select");
         } else {
             $resultPage->returnResult = $ReturnResult;
         }
     } else {
         $resultPage->returnResult = $ResultValidate;
     }
     $HttpReturnResult->setHttpContentResult($resultPage);
     return $HttpReturnResult;
 }
Example #3
0
 public function commit()
 {
     //iniciando o retorno padrao
     $HttpReturnResult = new HttpResult();
     $CategoryVO = new CategoryVO();
     if (!isset($_POST["category_id"]) || $_POST["category_id"] == NULL) {
         $_POST["category_id"] = 2;
     }
     $_POST["active"] = 1;
     $CategoryVO->setFetchArray($_POST);
     $id = DataHandler::forceInt(DataHandler::getValueByArrayIndex($this->arrayVariable, "id"));
     if ($id > 0) {
         $CategoryVO->setId($id);
     }
     $ResultValidate = $CategoryVO->validate();
     $resultPage = new DefaultPage();
     //Debug::print_r($ResultValidate); exit();
     if ($ResultValidate->success) {
         $ReturnResult = $CategoryVO->commit();
         //Debug::print_r($ReturnResult);exit();
         if ($ReturnResult->success) {
             Navigation::redirect("backend/category/show");
         } else {
             $resultPage->returnResult = $ReturnResult;
         }
     } else {
         $resultPage->returnResult = $ResultValidate;
     }
     $HttpReturnResult->setHttpContentResult($resultPage);
     return $HttpReturnResult;
 }