Example #1
0
 public function addAlert()
 {
     $input = Input::all();
     $alert = new Alert();
     $alert->value = $input['value'];
     $alert->condition = $input['condition'];
     $alert->user_id = $input['user'];
     $alert->owner_user_id = $input['user'];
     $alert->save();
     return Redirect::to('/alerts');
 }
try {
    if ($id) {
        $alertTable = Doctrine_Core::getTable('Alert');
        $result = $alertTable->find($id);
        if ($result) {
            echo "Found alert " . $result['Id'];
            $alert = $result;
            $alert['Active'] = $active;
        } else {
            //TODO: Passed in an Id, but didn't find it. Add error here.
        }
    } else {
        $alert = new Alert();
        $alert['Active'] = 0;
    }
    $alert['AlertFolderId'] = $folderId;
    $alert['UserId'] = $user_id;
    $alert['Label'] = $label;
    $alert['Description'] = $description;
    $alert['EmailAddresses'] = $emailaddresses;
    $alert['AlertOn'] = $alerton;
    $alert['AlertOnType'] = $alertontype;
    $alert['AlertOnComparator'] = $alertoncomparator;
    $alert['AlertOnValue'] = $alertonvalue;
    $alert['AlertThreshold'] = $alertthreshold;
    $alert->save();
} catch (Exception $e) {
    error_log("[WPTMonitor] Failed while updating alert: for " . $user_id . " message: " . $e->getMessage());
}
header("Location: listAlerts.php");
exit;