Skip to content

UserInterface

Alexander Saal edited this page Aug 4, 2025 · 1 revision

UserInterface

Interface & Methods

interface UserInterface
{
    /**
     * Returns the user's language.
     *
     * @return string user's language
     */
    public function getLanguage(): string;

    /**
     * Returns the user's avatar image url.
     *
     * @return string Avatar image url or the avatar fallback image path
     */
    public function getAvatarUrl(): string;

    /**
     * Returns the login name for the user.
     *
     * @return string Login name of the user.
     */
    public function getUsername(): string;

    /**
     * Returns the user's first name (pre-name).
     *
     * @return string First name of the user.
     */
    public function getPrename(): string;

    /**
     * Returns the last name of the user.
     *
     * @return string Last name of the user.
     */
    public function getLastName(): string;

    /**
     * Returns the complete name of the user in the form of "pre-name lastname".
     *
     * Is equivalent to:
     *
     *      <?php
     *      echo $user->getPrename() . ' ' .  $user->getLastName();
     *
     * @return string Complete name of the user.
     */
    public function getFullName(): string;

    /**
     * Returns the user's e-mail address
     *
     * @return string user's e-mail address.
     */
    public function getEmail(): string;

    /**
     * Returns the first user-defined settings of the user.
     *
     * @return string First user-defined settings of the user; otherwise an empty string.
     */
    public function getUserDefined1(): string;

    /**
     * Returns the second user-defined settings of the user.
     *
     * @return string Second user-defined settings of the user; otherwise an empty string.
     */
    public function getUserDefined2(): string;

    /**
     * Returns the third user-defined settings of the user.
     *
     * @return string Third user-defined settings of the user; otherwise an empty string.
     */
    public function getUserDefined3(): string;

    /**
     * Returns the fourth user-defined settings of the user.
     *
     * @return string Fourth user-defined settings of the user; otherwise an empty string.
     */
    public function getUserDefined4(): string;

    /**
     * Returns the fifth user-defined settings of the user.
     *
     * @return string Fifth user-defined settings of the user; otherwise an empty string.
     */
    public function getUserDefined5(): string;

    /**
     * Returns the supervisor of the user.
     *
     * @return string Supervisor of the user; otherwise an empty string.
     */
    public function getSupervisor(): string;

    /**
     * Returns the user's department.
     *
     * @return string Department of the user; otherwise an empty string.
     */
    public function getDepartment(): string;

    /**
     * Returns the user's phone number.
     *
     * @return string Phone number of the user; otherwise an empty string
     */
    public function getPhone(): string;

    /**
     * Returns the user's fax number.
     *
     * @return string Fax number of the user; otherwise an empty string
     */
    public function getFax(): string;

    /**
     * Returns the user's date format id.
     *
     * @return int Date format id from the user
     */
    public function getDateFormatId(): int;

    /**
     * Returns the user's date format as specified in their settings. If an invalid date format is configured,
     * a default value of YYYY-MM-DD HH:mm:ss is returned.
     *
     * @return string Date format from the user
     */
    public function getDateFormat(): string;

    /**
     * Returns the user's decimal separator.
     *
     * @return string User's decimal separator.
     */
    public function getDecimalSeparator(): string;

    /**
     * Returns the user's thousands separator.
     *
     * @return string User's thousands separator.
     */
    public function getThousandsSeparator(): string;

    /**
     * Returns the user's time zone.
     *
     * @return string Time Zone of the user
     */
    public function getTimezone(): string;

    /**
     * Returns the user's job functions.
     *
     * @return string[] user job functions
     *
     * @throws \JobRouterException
     */
    public function getJobFunctions(): array;

    /**
     * Returns the selected user's profile.
     *
     * @return int Selected user profile.
     */
    public function getUserProfile(): int;

    /**
     * Checks whether the user has administration rights.
     *
     * @return bool true has the user administrator rights; otherwise false
     */
    public function hasAdminRights(): bool;

    /**
     * Checks whether the user is the owner of any processes.
     *
     * @return bool true is the user owner of any processes; otherwise false
     *
     * @throws \JobRouterException If an error occurs during the database query to fetch the processes
     * a JobRouterException containing the DB error message is thrown.
     */
    public function hasOwnProcesses(): bool;

    /**
     * Checks whether the user is in the specified role.
     *
     * @param string $jobFunction Specified JobFunction name
     *
     * @return bool true a user in the given JobFunction; otherwise false
     */
    public function isInJobFunction(string $jobFunction): bool;

    /**
     * Checks whether the user is blocked or not.
     *
     * @return bool true if a user is blocked or not
     */
    public function isBlocked(): bool;
}

Example

<?php

use JobRouter\Sdk\UserManagerInterface;

return function (UserManagerInterface $userInterface): void {
    echo '<h1 style="color: #fc0">JobRouter SDK user interface example!</h1>';

    try {
        $user = $userInterface->getCurrentUser();

        echo '<h3 style="color: #59aa6e;">The user with username "' . $user->getUserName() . '" is authenticated!</h3>';

        $fullName = $user->getFullName();
        $inJobFunction = $user->isInJobFunction('Administrator') === true
            ? 'Yes'
            : 'No';

        echo '<pre>FullName: ' . print_r($fullName, true) . '</pre>';
        echo '<pre>In JobFunctions (Administrator): ' . print_r($inJobFunction, true) . '</pre>';

    } catch (\NoInstanceFoundException) {
        echo '<h3 style="color: #f44;">The user is not authenticated!</h3>';
    }
};

Response

JobRouter SDK user interface example!

The user with username "admin" is authenticated!

FullName: Max Mustermann

In JobFunctions (Administrator): Yes
Clone this wiki locally