private function removeTopicalDomain() { $td_id = $_GET['td_id']; $td = TopicalDomain::fromDatabaseById($td_id); if ($td) { if ($td->getActive()) { return 'notDeactivated'; } if ($td->delete()) { return 'true'; } } return 'false'; }
public function execute() { // Trim data $this->td_name = trim($this->td_name); $this->td_description = trim($this->td_description); // Data validation if ($this->td_name === '') { $this->message = "Errore: il campo nome è obbligatorio."; return true; } // Sanitize td_name if (preg_match('/^[0-9a-zàèéìò \']+$/i', $this->td_name) !== 1) { $this->message = "Errore: il nome contiene caratteri non validi."; return true; } // Sanitize td_description if (preg_match('/^[0-9a-zàèéìò \'.,();:"]*$/i', $this->td_description) !== 1) { $this->message = "Errore: la descrizione contiene caratteri non validi."; return true; } // Check that topical domain is disabled // Hopefully this has already been done before ;-) if ($this->td_id) { $td = TopicalDomain::fromDatabaseById($this->td_id); if ($td->getActive()) { $this->message = "Errore: l'area tematica non è disattivata."; return true; } } if ($this->td_id === 0) { $td = TopicalDomain::newRecord(); $td->setActive(1); } else { $td = TopicalDomain::fromDatabaseById($this->td_id); } $td->setCode($this->td_code); $td->setName($this->td_name); $td->setDescription($this->td_description); $td->setIcon($this->td_icon); $td->setColor($this->td_color); if ($td->save()) { gfSetDelayedMsg('Operazione effettuata correttamente', 'Ok'); global $gvPath; $redirect = new RedirectOutput("{$gvPath}/application/adminTopicalDomainList"); return $redirect; } else { $this->message = "Impossibile salvare le modifiche. Ritentare in seguito."; return true; } }
private function performRequest() { $resultFalse = array('result' => 'false'); if (!isset($_GET['td_id'])) { return $resultFalse; } $td_id = $_GET['td_id']; $td = TopicalDomain::fromDatabaseById($td_id); if (!$td) { return $resultFalse; } if ($td->getActive() == 1 && !$td->canBeDeactivated()) { return array('result' => 'ticketInQueue'); } $td->setActive($td->getActive() ? 0 : 1); if ($td->save()) { return array('result' => 'true'); } return $resultFalse; }