File manager - Edit - /home/missmand/public_html/learning/old/main/couple/notification.php
Back
<?php /* For licensing terms, see /license.txt */ /** * Modèle des notifications * @author Batiste Roger <batiste.roger@live.fr> * @package chamilo.couple */ require_once '../inc/global.inc.php'; require_once(api_get_path(SYS_PATH) . 'main/couple/model.php'); define ('TABLE_NOTIFICATION_MM', 'plateform_notification'); /** * Create a notification. Notifications are plateform_wide notifications. * @param type $recipient_user_id * @param type $title * @param type $text * @param type $url */ function notification_create ($recipient_user_id, $title, $text = null, $url = null) { // Test & Check $context = "couple/notifications.php:notification_create"; error_test_param(UserManager::is_user_id_valid($recipient_user_id), "Invalid user id ($recipient_user_id)", $context); error_test_param(is_string($title), "title should be a string", $context); error_test_param(strlen($title) < 80, "title should be shorter", $context); error_test_param(empty($text) || is_string($text), "text should be a string", $context); error_test_param(empty($url) || is_string($url), "url should be a string", $context); // Query $sql = "INSERT INTO " . TABLE_NOTIFICATION_MM . " SET recipient_user_id = $recipient_user_id, title = '" . trim(Database::escape_string($title)) . "'"; if (!empty($text)) $sql .= ", text = '" . trim(Database::escape_string($text)) . "'"; if (!empty($url)) $sql .= ", url = '" . trim(Database::escape_string($url)) . "'"; Database::query($sql); } /** * Read all notifications that user_id should receive. Status should be used to determin rather or not is will be displayed in the view. * @param type $user_id * @return type */ function notification_read ($user_id) { error_test_param( UserManager::is_user_id_valid($user_id), "Invalid user id ($user_id)", "couple/notifications.php:notification_read"); $sql = "SELECT * FROM " . TABLE_NOTIFICATION_MM . " WHERE recipient_user_id = $user_id"; return db_query($sql); } function notification_delete ($id) { db_query("DELETE FROM " . TABLE_NOTIFICATION_MM . " WHERE id = '$id'", false); }
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings