Ejemplo n.º 1
0
 /**
  * [__construct description]
  * Stellt entsprechend der Anfrage das Dokument dar
  */
 public function __construct()
 {
     $doc = new Documents();
     // Neues Dokument erstellen
     if (isset($_POST["operation"])) {
         if ($_POST["operation"] == "create") {
             $current_user = wp_get_current_user();
             $doc->createNewDocument($this->saveInputs($_POST["project_name"]), $current_user->display_name, get_current_user_id(), $this->saveInputs($_POST["layout"]));
         } else {
             if ($_POST["operation"] == "delete") {
                 $doc->deleteDocument($this->saveInputs($_POST["id"]));
             } else {
                 if ($_POST["operation"] == "selectGroup") {
                     $group = new Groups();
                     $group->selectGroup($this->saveInputs($_POST["selectedGroup"]), $this->saveInputs($_POST["document_id"]));
                 } else {
                     if ($_POST["operation"] == "addAbschnitt") {
                         $doc->addAbschnitt(esc_textarea($_POST["content"]), $this->saveInputs($_POST["document_id"]));
                     } else {
                         if ($_POST["operation"] == "setContentAbschnitt") {
                             $doc->updateAbschnitt($this->saveInputs($_POST["document_id"]), $this->saveInputs($_POST["abschnitt_id"]), esc_textarea($_POST["content"]));
                         } else {
                             if ($_POST["operation"] == "deleteAbschnitt") {
                                 $doc->deleteAbschnitt($this->saveInputs($_POST["document_id"]), $this->saveInputs($_POST["abschnitt_id"]));
                             } else {
                                 if ($_POST["operation"] == "selectLayout") {
                                     $doc->selectLayout($this->saveInputs($_POST["document_id"]), $this->saveInputs($_POST["selectedLayout"]), $this->saveInputs($_POST["old_layout"]));
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     if (isset($_GET["id"])) {
         $document = $doc->getDocument($this->saveInputs($_GET["id"]));
         $document->abschnitte = array();
         $document->abschnitte = $doc->getAbschnitte($document->id);
         $downloadLinks = $doc->getDownloadLinks($document);
         $document->downloadZip = $downloadLinks["zip"];
         $document->downloadPdf = $downloadLinks["pdf"];
         $this->viewDocument($document);
     } else {
         if (isset($_GET["create"])) {
             $this->viewDocumentCreateForm($_GET["create"]);
         } else {
             $authDocs = $doc->getDocumentsCreatedByUser(get_current_user_id());
             $this->viewShortDoc($authDocs);
             $this->viewDocumentCreateForm();
         }
     }
 }