コード例 #1
0
ファイル: Alert.php プロジェクト: sbraz/LBCAlerte
 public function fetchById($id)
 {
     $alert = null;
     $alertDb = $this->_connection->query("SELECT * FROM " . $this->_table . " WHERE user_id = " . $this->_user->getId() . "\n                AND idstr = '" . $this->_connection->real_escape_string($id) . "'")->fetch_assoc();
     if ($alertDb) {
         $alert = new \App\Mail\Alert();
         $alert->fromArray($alertDb);
         $alert->id = $alertDb["idstr"];
     }
     return $alert;
 }
コード例 #2
0
ファイル: Alert.php プロジェクト: sbraz/LBCAlerte
 public function fetchById($id)
 {
     $alert = null;
     if (is_file($this->_filename)) {
         $fopen = fopen($this->_filename, "r");
         if ($header = fgetcsv($fopen, 0, ",", '"')) {
             while (false !== ($values = fgetcsv($fopen, 0, ",", '"'))) {
                 $options = array_combine($header, $values);
                 if ($options["id"] == $id) {
                     $alert = new \App\Mail\Alert();
                     $alert->fromArray($options);
                     break;
                 }
             }
         }
         fclose($fopen);
     }
     return $alert;
 }
コード例 #3
0
ファイル: form.php プロジェクト: sbraz/LBCAlerte
<?php

if (isset($_GET["id"])) {
    $alert = $storage->fetchById($_GET["id"]);
}
if (empty($alert)) {
    $alert = new App\Mail\Alert();
}
$categoryCollection = new \Lbc\CategoryCollection();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    foreach ($_POST as $name => $value) {
        if (is_array($value)) {
            $_POST[$name] = array_map("trim", $_POST[$name]);
        } else {
            $_POST[$name] = trim($_POST[$name]);
        }
    }
    $alert->fromArray($_POST);
    if (empty($alert->send_mail) && empty($alert->send_sms_free_mobile) && empty($alert->send_sms_ovh) && empty($alert->send_pushbullet) && empty($alert->send_notifymyandroid) && empty($alert->send_pushover)) {
        $errors["send_type"] = "Vous devez sélectionner au moins un moyen de communication.";
    }
    if (empty($alert->email)) {
        $errors["email"] = "Ce champ est obligatoire.";
    }
    if (empty($alert->title)) {
        $errors["title"] = "Ce champ est obligatoire.";
    }
    if (empty($alert->price_min)) {
        $alert->price_min = -1;
    }
    if (empty($alert->price_max)) {