Kimai_Database_Mysql::user_get_preference PHP Method

user_get_preference() protected method

Get a preference for a user. If no user ID is given the current user is used.
Author: sl
protected user_get_preference ( string $key, integer $userId = null ) : string
$key string name of the preference to fetch
$userId integer (optional) id of the user to fetch the preference for
return string value of the preference or null if there is no such preference
    protected function user_get_preference($key, $userId = null)
    {
        if ($userId === null) {
            $userId = $this->kga['user']['userID'];
        }
        $table = $this->getPreferencesTable();
        $userId = MySQL::SQLValue($userId, MySQL::SQLVALUE_NUMBER);
        $key2 = MySQL::SQLValue($key);
        $query = "SELECT `value` FROM {$table} WHERE userID = {$userId} AND `option` = {$key2}";
        $this->conn->Query($query);
        if ($this->conn->RowCount() == 1) {
            $row = $this->conn->RowArray(0, MYSQLI_NUM);
            return $row[0];
        }
        return null;
    }
Kimai_Database_Mysql