Example #1
0
 public function update($id, $forceAdmin = true)
 {
     if (userController::isAdmin() == false and $forceAdmin == true) {
         return preg_replace('/%MESSAGE%/', "Updates not allowed here", file_get_contents('./views/message/failure.html'));
     }
     if (isset(filter_input_array(INPUT_POST)[$this->object])) {
         $inputForm = filter_input_array(INPUT_POST)[$this->object];
         $id = $inputForm['id'];
         unset($inputForm['id']);
         if ($this->model->update($inputForm, $id)) {
             return preg_replace("/%MESSAGE%/", "saved", file_get_contents('./views/message/info.html'));
         }
     } else {
         $data = $this->model->read($id);
         $form = $this->model->getForm("update", $data);
         return $this->getGeneratedView('./views/' . $this->object . '/formLayout.php', $form);
     }
 }