Beispiel #1
0
 /**
  * @throws \Exception
  */
 public function dumpXML()
 {
     $xmlReader = new XMLReader();
     $db = new Database();
     $conn = $db->connect();
     $source_file = $xmlReader->getFileList('xml', 'xml');
     if (is_array($source_file)) {
         foreach ($source_file as $path) {
             $filterXML = $xmlReader->filterXML($path);
             $db->insert('gcide', $filterXML, 'w,def');
         }
     }
     if ($conn) {
         $db->disconnect();
     }
 }
Beispiel #2
0
 /**
  * handle post after validation if needs
  * @param $post
  * @return array|bool
  */
 public function handlePost($post)
 {
     if (count($post) < 1) {
         return false;
     }
     $database = new Database();
     $invalidFields = [];
     $fields = [];
     foreach ($this->getForm()->getFields() as $field) {
         if ($field->isStorable()) {
             $field->setValue($post[$field->getName()]);
             if ($field->getValidation() && Validation::validate($field->getValidation(), $field->getValue())->isValid() != true) {
                 $invalidFields[$field->getName()] = $field->getValue();
             }
             $fields[$field->getName()] = $field->getValue();
         }
     }
     if (count($invalidFields) > 0 && (!isset($post['delete']) || $post['delete'] != 1)) {
         return ['status' => false, 'invalidFields' => $invalidFields];
     }
     switch ($this->getMethod()) {
         case self::_edit:
             if (isset($post['delete']) && $post['delete'] == 1) {
                 $database->delete($this->getName(), ['ID' => $this->getID()]);
                 $location = $this->getName();
             } else {
                 $database->update($this->getName(), $fields, ['ID' => $this->getID()]);
                 $location = $this->getName() . '/' . $this->getMethod() . '/' . $this->getID();
             }
             break;
         case self::_new:
             $lastInsertedID = $database->insert($this->getName(), $fields, true);
             $location = $this->getName() . '/' . self::_edit . '/' . $lastInsertedID;
             break;
     }
     return ['status' => true, 'location' => $location];
 }
Beispiel #3
0
 /**
  * @param User $user
  * @return User
  */
 public function addUser(User $user, $password)
 {
     $id = $this->database->insert("users", array("username" => $user->getUsername(), "password_hash" => self::hashPassword($password), "vorname" => $user->getVorname(), "nachname" => $user->getNachname(), "anschrift" => $user->getAnschrift(), "telefonDurchwahl" => $user->getTelefonDurchwahl(), "telefonPrivat" => $user->getTelefonPrivat(), "telefonMobil" => $user->getTelefonMobil()));
     $user->setId($id);
     return $user;
 }