An easy point of sale system with automatic inventory tracking. https://netsyms.biz/apps/nickelbox/
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

Notifications.lib.php 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /*
  3. * This Source Code Form is subject to the terms of the Mozilla Public
  4. * License, v. 2.0. If a copy of the MPL was not distributed with this
  5. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  6. */
  7. class Notifications {
  8. /**
  9. * Add a new notification.
  10. * @global $database
  11. * @param User $user
  12. * @param string $title
  13. * @param string $content
  14. * @param string $timestamp If left empty, the current date and time will be used.
  15. * @param string $url
  16. * @param bool $sensitive If true, the notification is marked as containing sensitive content, and the $content might be hidden on lockscreens and other non-secure places.
  17. * @return int The newly-created notification ID.
  18. * @throws Exception
  19. */
  20. public static function add(User $user, string $title, string $content, string $timestamp = "", string $url = "", bool $sensitive = false): int {
  21. global $Strings;
  22. if ($user->exists()) {
  23. if (empty($title) || empty($content)) {
  24. throw new Exception($Strings->get("invalid parameters", false));
  25. }
  26. $timestamp = date("Y-m-d H:i:s");
  27. if (!empty($timestamp)) {
  28. $timestamp = date("Y-m-d H:i:s", strtotime($timestamp));
  29. }
  30. $client = new GuzzleHttp\Client();
  31. $response = $client
  32. ->request('POST', PORTAL_API, [
  33. 'form_params' => [
  34. 'key' => PORTAL_KEY,
  35. 'action' => "addnotification",
  36. 'uid' => $user->getUID(),
  37. 'title' => $title,
  38. 'content' => $content,
  39. 'timestamp' => $timestamp,
  40. 'url' => $url,
  41. 'sensitive' => $sensitive
  42. ]
  43. ]);
  44. if ($response->getStatusCode() > 299) {
  45. sendError("Login server error: " . $response->getBody());
  46. }
  47. $resp = json_decode($response->getBody(), TRUE);
  48. if ($resp['status'] == "OK") {
  49. return $resp['id'] * 1;
  50. } else {
  51. return false;
  52. }
  53. }
  54. throw new Exception($Strings->get("user does not exist", false));
  55. }
  56. }