Reminders
Reminder Functions
The former procedural functions from reminder.lib (lmb_addReminder, lmb_dropReminder, …) have been removed. A migration guide for legacy code can be found at the end of this document.
The reminder functionality (table LMB_REMINDER) is provided by the class Limbas\extra\reminder\Reminder.
GUI Element (Javascript)
Displays a modal for creating or editing a reminder.
limbasReminder(reminderId = 0)
Parameters
reminderId(optional): The ID of the reminder to display. If no ID is provided, the modal for creating a new reminder is shown.
PHP
Class Reminder
The Reminder class represents a reminder and provides methods for creating, editing, and retrieving reminders.
use Limbas\extra\reminder\Reminder;
Properties
A Reminder instance has the following properties:
| Property | Type | Description |
|---|---|---|
id (private) | int | Reminder ID. Read-only via $reminder->getId() |
$tableId | int | Table ID (gtabid) the reminder belongs to. |
$dataId | ?int | Record ID. |
$deadline | DateTime | Due date of the reminder. |
$description | ?string | Description. |
$fromUser | ?int | Creator. If null, defaults to the currently logged-in user ($session["user_id"]). |
$content | ?string | Content. If empty and a primary field is defined for the table, the content is automatically derived from the record's primary field on creation. |
$category | ?int | Reminder group (category). 0 = default reminder. |
$workflowInstance | ?int | Workflow instance. |
$formId | ?int | Form opened when the reminder is clicked. |
$multitenantId | ?int | Tenant ID. |
Note: The constructor is private. New reminders are not created with new Reminder(...) but via the factory method Reminder::create(), which also persists them; existing reminders are loaded via Reminder::get() or Reminder::all(). Public properties can be read and modified (before calling save()), e.g. $reminder->deadline = $newDate;. The ID is read-only via getId().
Static Methods
Reminder::create(...)
public static function create(
int $tableId,
?int $dataId,
DateTime $deadline,
?string $description,
?int $fromUser = null,
?string $content = '',
int $category = 0,
int $workflowInstance = 0,
int $formId = 0,
array $userOrGroupArray = [],
bool $sendMail = false,
): ?array
Creates one or more reminders and saves them.
| Parameter | Type | Description |
|---|---|---|
$tableId | int | Table ID (gtabid). |
$dataId | ?int | Record ID. |
$deadline | DateTime | Due date. |
$description | ?string | Description. |
$fromUser | ?int | Creator. If null, defaults to the currently logged-in user. |
$content | ?string | Content. If empty and a primary field exists, content is automatically derived from the record. |
$category | int | Reminder group (category). 0 = default reminder. |
$workflowInstance | int | Workflow instance. |
$formId | int | Form opened when the reminder is clicked. |
$userOrGroupArray | array | List of users and/or groups to assign the reminder to (see User and Group Assignment). If empty, the reminder is assigned to the currently logged-in user. |
$sendMail | bool | Whether to send an email notification to the assigned users. |
Returns: On success, an array of the created Reminder objects (with IDs already set). On database error, null. The operation runs in a transaction; on failure it is rolled back.
Assignment behavior depends on whether the category is group-based:
- Group-based: Exactly one reminder is created, shared by all assigned users and groups.
- Non-group-based: A separate reminder is created for each user (including each member of an assigned group).
Reminder::get(int $id): Reminder|null
Returns a single reminder by ID, or null if not found.
Reminder::all(array $where = [], ?int $category = null, ?int $tableId = null, ?int $dataId = null, bool $valid = false, ?int $userId = null): array
Returns an array of Reminder objects based on the provided filters. Automatically respects permissions (table rights), multi-tenancy, and group/user-based visibility.
| Parameter | Type | Description |
|---|---|---|
$where | array | Additional WHERE conditions as ['FIELD' => value]. |
$category | ?int | Reminder group (category). |
$tableId | ?int | Table ID. |
$dataId | ?int | Record ID. |
$valid | bool | If true, only due reminders (FRIST < current time) are returned. |
$userId | ?int | Optional user. Defaults to the logged-in user from the session. |
Reminder::allLegacy(?int $category = null, ?int $tableId = null, ?int $dataId = null, ?int $wfl_inst = null, ?bool $valid = false): array
Like all(), but returns the result in the old column-oriented array format (['id' => [...], 'validdate' => [...], 'desc' => [...], …]). Not recommended for new development — use all() instead.
Reminder::deleteByFilter($reminderId, $tableId = null, $category = null, $dataId = null, $workflowInstance = null, $valid = null): bool
Deletes one or more reminders based on the provided filters.
Returns: true on success, false otherwise.
Reminder::countPerCategory(int $category): int
Returns the count of active (due) reminders in a category for the current user.
Reminder::sendAllCronMails(): void
Sends each user a digest email containing their open (due) reminders.
Reminder::convertLegacyUsergroupArray(mixed $userOrGroupArray): array
Migration helper: converts the old assignment notation (string like '33_u;22_g') into the new userOrGroupArray format. Not recommended for new development — use the new format directly.
Methods
save(): bool
Saves changes to an existing reminder (UPDATE). Requires a valid ID; if the ID is 0, returns false without saving. Use Reminder::create() to create new reminders.
Returns: true on success, false otherwise.
update(): bool
Writes the updatable fields (tab_id, dat_id, frist, description, content, category, wfl_inst, form_id) to the database. save() is essentially a wrapper around this method with a preceding ID check.
Returns: true on success, false otherwise.
delete(): bool
Deletes the reminder.
Returns: true on success, false otherwise.
getId(): int
Returns the reminder's ID. Reminders obtained via Reminder::get(), Reminder::all(), or Reminder::create() carry their actual database ID.
getDeadlineTimezoned(): string
Returns the due date (deadline) as a formatted, timezone-adjusted string.
toArray(): array
Returns all reminder properties as an associative array (keys match the class property names).
toArrayLegacy(): array
Returns the reminder in the old array format (keys like tab_id, dat_id, validdate, desc, fromuser, …). Useful for compatibility with legacy code. Not recommended for new development — use toArray() instead.
User and Group Assignment
Reminder::create() expects an array of assignments in the $userOrGroupArray parameter. Each entry consists of type ('user' or 'group') and id:
$userOrGroupArray = [
['type' => 'user', 'id' => 33],
['type' => 'group', 'id' => 22],
['type' => 'user', 'id' => 55],
];
If the list is empty, the reminder is automatically assigned to the currently logged-in user.
Customizing the Message Text
When sending an email, the message body can be customized via a custom function. The function name is defined in the reminder settings. For the default reminder, it can be set via the array $greminder[$gtabid]["message"][0] = 'myExt_functname'.
The function is called with the following arguments:
$message = myExt_functname(
$userId, // recipient
$tableId, // table ID
$dataId, // record ID
$category, // category
$deadline, // formatted due timestamp
$description, // description
$content, // content
$workflowInstance // workflow instance
);
Example
function myExt_sendReminderMessage($userId, $gtabid, $ID, $category, $date, $description, $header, $wfl_inst)
{
global $userdat, $session, $umgvar;
$message = "
hallo " . $userdat["bezeichnung"][$userId] . "<br><br>
" . $session['vorname'] . " " . $session['name'] . " send you a $header - reminder for:<br>
<i><b><a href=\"" . $umgvar['url'] . "/main.php?action=\"> $header </a></b></i><br><br><br>
$description<br><br>
";
$message .= "
-------------------------------------------------------------------------------------<br>
This is an automatically generated email, please do not reply!<br>
-------------------------------------------------------------------------------------<br>
";
return $message;
}
Examples
Creating a Reminder
use Limbas\extra\reminder\Reminder;
$deadline = new DateTime('2026-03-16 22:44');
$reminders = Reminder::create(
tableId: 1,
dataId: 23,
deadline: $deadline,
description: 'Follow up on offer',
category: 2,
formId: 5,
userOrGroupArray: [
['type' => 'user', 'id' => 1],
['type' => 'group', 'id' => 4],
],
sendMail: true,
);
if ($reminders === null) {
// error while saving (transaction rolled back)
}
Editing a Reminder
$reminder = Reminder::get(42);
if ($reminder) {
$reminder->deadline = new DateTime('2026-04-01 09:00');
$reminder->description = 'Appointment rescheduled';
$reminder->save();
}
Fetching Reminders
// all due reminders for a record
$reminders = Reminder::all(
category: 0,
tableId: 1,
dataId: 23,
valid: true
);
foreach ($reminders as $reminder) {
echo $reminder->getId() . ': ' . $reminder->description . ' – ' . $reminder->getDeadlineTimezoned() . "\n";
}
Deleting a Reminder
// delete single instance
$reminder = Reminder::get(42);
$reminder?->delete();
// delete by filter
Reminder::deleteByFilter(tableId: 5, dataId: 23);
Getting the Count
$count = Reminder::countPerCategory(2);
Migrating from Legacy Functions
The reminder.lib file and its procedural functions have been removed. Existing code using these functions must be migrated to the Reminder class. The table below shows the equivalent replacement for each.
| Removed Function | New Equivalent |
|---|---|
lmb_addReminder($gfrist, $gfrist_desc, $gtabid, $ID, $to, $category, $wfl_inst, $fielddesc, $sendmail, $form_id) | Reminder::create($gtabid, $ID, $deadline, $gfrist_desc, null, $fielddesc, $category, $wfl_inst, $form_id, $userOrGroupArray, $sendmail) |
lmb_dropReminder($rem_id, $gtabid, $category, $ID, $wfl_inst, $valid) | Reminder::deleteByFilter($rem_id, $gtabid, $category, $ID, $wfl_inst, $valid) |
lmb_changeReminder($rem_id, $gfrist, $gfrist_desc) | Reminder::get($rem_id) → set properties → save() |
lmb_getReminder($gtabid, $ID, $category, $wfl_inst, $valid) | Reminder::allLegacy($category, $gtabid, $ID, $wfl_inst, $valid) |
lmb_getReminderCount($category) | Reminder::countPerCategory($category) |
Migration Notes
- The old assignment notation (
'33_u;22_g') can be converted withReminder::convertLegacyUsergroupArray()to the newuserOrGroupArrayformat, but it is recommended to migrate directly to the new format. - The former
$gfristtimestamp is now represented as aDateTimeobject ($deadline). - The old column-oriented return format of
lmb_getReminder()corresponds toReminder::allLegacy(); object-oriented code should useReminder::all()instead and work withReminderobjects.