Changed more functions 🎉
This commit is contained in:
parent
b069a938c6
commit
89e62c95a7
|
@ -57,17 +57,17 @@ function angeltype_link($angeltype_id, $params = [])
|
||||||
*/
|
*/
|
||||||
function angeltypes_about_controller()
|
function angeltypes_about_controller()
|
||||||
{
|
{
|
||||||
global $user;
|
$user = auth()->user();
|
||||||
|
|
||||||
if (isset($user)) {
|
if ($user) {
|
||||||
$angeltypes = AngelTypes_with_user($user);
|
$angeltypes = AngelTypes_with_user($user->id);
|
||||||
} else {
|
} else {
|
||||||
$angeltypes = AngelTypes();
|
$angeltypes = AngelTypes();
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
__('Teams/Job description'),
|
__('Teams/Job description'),
|
||||||
AngelTypes_about_view($angeltypes, isset($user))
|
AngelTypes_about_view($angeltypes, (bool)$user)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ function angeltype_controller()
|
||||||
}
|
}
|
||||||
|
|
||||||
$angeltype = load_angeltype();
|
$angeltype = load_angeltype();
|
||||||
$user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
|
$user_angeltype = UserAngelType_by_User_and_AngelType($user['UID'], $angeltype);
|
||||||
$user_driver_license = UserDriverLicense($user['UID']);
|
$user_driver_license = UserDriverLicense($user['UID']);
|
||||||
$members = Users_by_angeltype($angeltype);
|
$members = Users_by_angeltype($angeltype);
|
||||||
|
|
||||||
|
@ -277,13 +277,14 @@ function angeltype_controller_shiftsFilter($angeltype, $days)
|
||||||
*/
|
*/
|
||||||
function angeltypes_list_controller()
|
function angeltypes_list_controller()
|
||||||
{
|
{
|
||||||
global $privileges, $user;
|
global $privileges;
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
if (!in_array('angeltypes', $privileges)) {
|
if (!in_array('angeltypes', $privileges)) {
|
||||||
redirect(page_link_to('/'));
|
redirect(page_link_to('/'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$angeltypes = AngelTypes_with_user($user);
|
$angeltypes = AngelTypes_with_user($user->id);
|
||||||
|
|
||||||
foreach ($angeltypes as &$angeltype) {
|
foreach ($angeltypes as &$angeltype) {
|
||||||
$actions = [
|
$actions = [
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Engelsystem\Models\User\User;
|
||||||
use Engelsystem\ShiftSignupState;
|
use Engelsystem\ShiftSignupState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -9,15 +10,14 @@ use Engelsystem\ShiftSignupState;
|
||||||
*/
|
*/
|
||||||
function shift_entries_controller()
|
function shift_entries_controller()
|
||||||
{
|
{
|
||||||
global $user;
|
$user = auth()->user();
|
||||||
|
if ($user) {
|
||||||
if (!isset($user)) {
|
|
||||||
redirect(page_link_to('login'));
|
redirect(page_link_to('login'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$action = strip_request_item('action');
|
$action = strip_request_item('action');
|
||||||
if (empty($action)) {
|
if (empty($action)) {
|
||||||
redirect(user_link($user['UID']));
|
redirect(user_link($user->id));
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
|
@ -74,14 +74,14 @@ function shift_entry_create_controller()
|
||||||
*/
|
*/
|
||||||
function shift_entry_create_controller_admin($shift, $angeltype)
|
function shift_entry_create_controller_admin($shift, $angeltype)
|
||||||
{
|
{
|
||||||
global $user;
|
$user = auth()->user();
|
||||||
$request = request();
|
$request = request();
|
||||||
|
|
||||||
$signup_user = $user;
|
$signup_user = $user;
|
||||||
if ($request->has('user_id')) {
|
if ($request->has('user_id')) {
|
||||||
$signup_user = User($request->input('user_id'));
|
$signup_user = User::find($request->input('user_id'));
|
||||||
}
|
}
|
||||||
if (empty($signup_user)) {
|
if (!$signup_user) {
|
||||||
redirect(shift_link($shift));
|
redirect(shift_link($shift));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ function shift_entry_create_controller_admin($shift, $angeltype)
|
||||||
ShiftEntry_create([
|
ShiftEntry_create([
|
||||||
'SID' => $shift['SID'],
|
'SID' => $shift['SID'],
|
||||||
'TID' => $angeltype['id'],
|
'TID' => $angeltype['id'],
|
||||||
'UID' => $signup_user['UID'],
|
'UID' => $signup_user->id,
|
||||||
'Comment' => '',
|
'Comment' => '',
|
||||||
'freeloaded' => false,
|
'freeloaded' => false,
|
||||||
'freeload_comment' => ''
|
'freeload_comment' => ''
|
||||||
|
@ -145,7 +145,7 @@ function shift_entry_create_controller_supporter($shift, $angeltype)
|
||||||
if ($request->has('user_id')) {
|
if ($request->has('user_id')) {
|
||||||
$signup_user = User($request->input('user_id'));
|
$signup_user = User($request->input('user_id'));
|
||||||
}
|
}
|
||||||
if (!UserAngelType_exists($signup_user, $angeltype)) {
|
if (!UserAngelType_exists($signup_user['UID'], $angeltype)) {
|
||||||
error(__('User is not in angeltype.'));
|
error(__('User is not in angeltype.'));
|
||||||
redirect(shift_link($shift));
|
redirect(shift_link($shift));
|
||||||
}
|
}
|
||||||
|
@ -259,8 +259,8 @@ function shift_entry_create_controller_user($shift, $angeltype)
|
||||||
'freeload_comment' => ''
|
'freeload_comment' => ''
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($angeltype['restricted'] == false && !UserAngelType_exists($signup_user, $angeltype)) {
|
if ($angeltype['restricted'] == false && !UserAngelType_exists($signup_user['UID'], $angeltype)) {
|
||||||
UserAngelType_create($signup_user, $angeltype);
|
UserAngelType_create($signup_user['UID'], $angeltype);
|
||||||
}
|
}
|
||||||
|
|
||||||
success(__('You are subscribed. Thank you!'));
|
success(__('You are subscribed. Thank you!'));
|
||||||
|
|
|
@ -272,15 +272,15 @@ function shift_controller()
|
||||||
$shifttype = ShiftType($shift['shifttype_id']);
|
$shifttype = ShiftType($shift['shifttype_id']);
|
||||||
$room = Room($shift['RID']);
|
$room = Room($shift['RID']);
|
||||||
$angeltypes = AngelTypes();
|
$angeltypes = AngelTypes();
|
||||||
$user_shifts = Shifts_by_user($user);
|
$user_shifts = Shifts_by_user($user['UID']);
|
||||||
|
|
||||||
$shift_signup_state = new ShiftSignupState(ShiftSignupState::OCCUPIED, 0);
|
$shift_signup_state = new ShiftSignupState(ShiftSignupState::OCCUPIED, 0);
|
||||||
foreach ($angeltypes as &$angeltype) {
|
foreach ($angeltypes as &$angeltype) {
|
||||||
$needed_angeltype = NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype);
|
$needed_angeltype = NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype);
|
||||||
if(empty($needed_angeltype)) {
|
if (empty($needed_angeltype)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$shift_entries = ShiftEntries_by_shift_and_angeltype($shift['SID'], $angeltype['id']);
|
$shift_entries = ShiftEntries_by_shift_and_angeltype($shift['SID'], $angeltype['id']);
|
||||||
|
|
||||||
$angeltype_signup_state = Shift_signup_allowed(
|
$angeltype_signup_state = Shift_signup_allowed(
|
||||||
|
@ -330,13 +330,14 @@ function shifts_controller()
|
||||||
*/
|
*/
|
||||||
function shift_next_controller()
|
function shift_next_controller()
|
||||||
{
|
{
|
||||||
global $user, $privileges;
|
global $privileges;
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
if (!in_array('user_shifts', $privileges)) {
|
if (!in_array('user_shifts', $privileges)) {
|
||||||
redirect(page_link_to('/'));
|
redirect(page_link_to('/'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$upcoming_shifts = ShiftEntries_upcoming_for_user($user);
|
$upcoming_shifts = ShiftEntries_upcoming_for_user($user->id);
|
||||||
|
|
||||||
if (!empty($upcoming_shifts)) {
|
if (!empty($upcoming_shifts)) {
|
||||||
redirect(shift_link($upcoming_shifts[0]));
|
redirect(shift_link($upcoming_shifts[0]));
|
||||||
|
@ -381,7 +382,5 @@ function shifts_json_export_controller()
|
||||||
*/
|
*/
|
||||||
function load_ical_shifts()
|
function load_ical_shifts()
|
||||||
{
|
{
|
||||||
global $user;
|
return Shifts_by_user(auth()->user()->id);
|
||||||
|
|
||||||
return Shifts_by_user($user);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Engelsystem\Models\User\User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display a hint for team/angeltype supporters if there are unconfirmed users for his angeltype.
|
* Display a hint for team/angeltype supporters if there are unconfirmed users for his angeltype.
|
||||||
*
|
*
|
||||||
|
@ -7,9 +9,9 @@
|
||||||
*/
|
*/
|
||||||
function user_angeltypes_unconfirmed_hint()
|
function user_angeltypes_unconfirmed_hint()
|
||||||
{
|
{
|
||||||
global $user;
|
$user = auth()->user();
|
||||||
|
|
||||||
$unconfirmed_user_angeltypes = User_unconfirmed_AngelTypes($user);
|
$unconfirmed_user_angeltypes = User_unconfirmed_AngelTypes($user->id);
|
||||||
if (count($unconfirmed_user_angeltypes) == 0) {
|
if (count($unconfirmed_user_angeltypes) == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -101,7 +103,7 @@ function user_angeltypes_confirm_all_controller()
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($request->has('confirmed')) {
|
if ($request->has('confirmed')) {
|
||||||
UserAngelTypes_confirm_all($angeltype['id'], $user);
|
UserAngelTypes_confirm_all($angeltype['id'], $user['UID']);
|
||||||
|
|
||||||
engelsystem_log(sprintf('Confirmed all users for angeltype %s', AngelType_name_render($angeltype)));
|
engelsystem_log(sprintf('Confirmed all users for angeltype %s', AngelType_name_render($angeltype)));
|
||||||
success(sprintf(__('Confirmed all users for angeltype %s.'), AngelType_name_render($angeltype)));
|
success(sprintf(__('Confirmed all users for angeltype %s.'), AngelType_name_render($angeltype)));
|
||||||
|
@ -146,14 +148,14 @@ function user_angeltype_confirm_controller()
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$user_source = User($user_angeltype['user_id']);
|
$user_source = User::find($user_angeltype['user_id']);
|
||||||
if (empty($user_source)) {
|
if (!$user_source) {
|
||||||
error(__('User doesn\'t exist.'));
|
error(__('User doesn\'t exist.'));
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($request->has('confirmed')) {
|
if ($request->has('confirmed')) {
|
||||||
UserAngelType_confirm($user_angeltype['id'], $user);
|
UserAngelType_confirm($user_angeltype['id'], $user['UID']);
|
||||||
|
|
||||||
engelsystem_log(sprintf(
|
engelsystem_log(sprintf(
|
||||||
'%s confirmed for angeltype %s',
|
'%s confirmed for angeltype %s',
|
||||||
|
@ -201,8 +203,8 @@ function user_angeltype_delete_controller()
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$user_source = User($user_angeltype['user_id']);
|
$user_source = User::find($user_angeltype['user_id']);
|
||||||
if (empty($user_source)) {
|
if (!$user_source) {
|
||||||
error(__('User doesn\'t exist.'));
|
error(__('User doesn\'t exist.'));
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
@ -268,8 +270,8 @@ function user_angeltype_update_controller()
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$user_source = User($user_angeltype['user_id']);
|
$user_source = User::find($user_angeltype['user_id']);
|
||||||
if (empty($user_source)) {
|
if (!$user_source) {
|
||||||
error(__('User doesn\'t exist.'));
|
error(__('User doesn\'t exist.'));
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
@ -322,8 +324,8 @@ function user_angeltype_add_controller()
|
||||||
if (request()->has('submit')) {
|
if (request()->has('submit')) {
|
||||||
$user_source = load_user();
|
$user_source = load_user();
|
||||||
|
|
||||||
if (!UserAngelType_exists($user_source, $angeltype)) {
|
if (!UserAngelType_exists($user_source['UID'], $angeltype)) {
|
||||||
$user_angeltype_id = UserAngelType_create($user_source, $angeltype);
|
$user_angeltype_id = UserAngelType_create($user_source['UID'], $angeltype);
|
||||||
|
|
||||||
engelsystem_log(sprintf(
|
engelsystem_log(sprintf(
|
||||||
'User %s added to %s.',
|
'User %s added to %s.',
|
||||||
|
@ -336,7 +338,7 @@ function user_angeltype_add_controller()
|
||||||
AngelType_name_render($angeltype)
|
AngelType_name_render($angeltype)
|
||||||
));
|
));
|
||||||
|
|
||||||
UserAngelType_confirm($user_angeltype_id, $user_source);
|
UserAngelType_confirm($user_angeltype_id, $user_source['UID']);
|
||||||
engelsystem_log(sprintf(
|
engelsystem_log(sprintf(
|
||||||
'User %s confirmed as %s.',
|
'User %s confirmed as %s.',
|
||||||
User_Nick_render($user_source),
|
User_Nick_render($user_source),
|
||||||
|
@ -363,14 +365,14 @@ function user_angeltype_join_controller($angeltype)
|
||||||
{
|
{
|
||||||
global $user, $privileges;
|
global $user, $privileges;
|
||||||
|
|
||||||
$user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
|
$user_angeltype = UserAngelType_by_User_and_AngelType($user['UID'], $angeltype);
|
||||||
if (!empty($user_angeltype)) {
|
if (!empty($user_angeltype)) {
|
||||||
error(sprintf(__('You are already a %s.'), $angeltype['name']));
|
error(sprintf(__('You are already a %s.'), $angeltype['name']));
|
||||||
redirect(page_link_to('angeltypes'));
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request()->has('confirmed')) {
|
if (request()->has('confirmed')) {
|
||||||
$user_angeltype_id = UserAngelType_create($user, $angeltype);
|
$user_angeltype_id = UserAngelType_create($user['UID'], $angeltype);
|
||||||
|
|
||||||
$success_message = sprintf(__('You joined %s.'), $angeltype['name']);
|
$success_message = sprintf(__('You joined %s.'), $angeltype['name']);
|
||||||
engelsystem_log(sprintf(
|
engelsystem_log(sprintf(
|
||||||
|
@ -381,7 +383,7 @@ function user_angeltype_join_controller($angeltype)
|
||||||
success($success_message);
|
success($success_message);
|
||||||
|
|
||||||
if (in_array('admin_user_angeltypes', $privileges)) {
|
if (in_array('admin_user_angeltypes', $privileges)) {
|
||||||
UserAngelType_confirm($user_angeltype_id, $user);
|
UserAngelType_confirm($user_angeltype_id, $user['UID']);
|
||||||
engelsystem_log(sprintf(
|
engelsystem_log(sprintf(
|
||||||
'User %s confirmed as %s.',
|
'User %s confirmed as %s.',
|
||||||
User_Nick_render($user),
|
User_Nick_render($user),
|
||||||
|
|
|
@ -8,10 +8,10 @@
|
||||||
*/
|
*/
|
||||||
function user_driver_license_required_hint()
|
function user_driver_license_required_hint()
|
||||||
{
|
{
|
||||||
global $user;
|
$user = auth()->user();
|
||||||
|
|
||||||
$angeltypes = User_angeltypes($user);
|
$angeltypes = User_angeltypes($user->id);
|
||||||
$user_driver_license = UserDriverLicense($user['UID']);
|
$user_driver_license = UserDriverLicense($user->id);
|
||||||
|
|
||||||
// User has already entered data, no hint needed.
|
// User has already entered data, no hint needed.
|
||||||
if (!empty($user_driver_license)) {
|
if (!empty($user_driver_license)) {
|
||||||
|
@ -124,7 +124,7 @@ function user_driver_license_edit_controller()
|
||||||
|
|
||||||
if (UserDriverLicense_valid($user_driver_license)) {
|
if (UserDriverLicense_valid($user_driver_license)) {
|
||||||
if (empty($user_driver_license['user_id'])) {
|
if (empty($user_driver_license['user_id'])) {
|
||||||
$user_driver_license = UserDriverLicenses_create($user_driver_license, $user_source);
|
$user_driver_license = UserDriverLicenses_create($user_driver_license, $user_source['UID']);
|
||||||
} else {
|
} else {
|
||||||
UserDriverLicenses_update($user_driver_license);
|
UserDriverLicenses_update($user_driver_license);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Engelsystem\Models\User\User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a work log entry.
|
* Delete a work log entry.
|
||||||
*
|
*
|
||||||
|
@ -7,20 +9,20 @@
|
||||||
*/
|
*/
|
||||||
function user_worklog_delete_controller()
|
function user_worklog_delete_controller()
|
||||||
{
|
{
|
||||||
global $user;
|
$user = auth()->user();
|
||||||
|
|
||||||
$request = request();
|
$request = request();
|
||||||
$userWorkLog = UserWorkLog($request->input('user_worklog_id'));
|
$userWorkLog = UserWorkLog($request->input('user_worklog_id'));
|
||||||
if (empty($userWorkLog)) {
|
if (empty($userWorkLog)) {
|
||||||
redirect(user_link($user['UID']));
|
redirect(user_link($user->id));
|
||||||
}
|
}
|
||||||
$user_source = User($userWorkLog['user_id']);
|
$user_source = User::find($userWorkLog['user_id']);
|
||||||
|
|
||||||
if ($request->has('confirmed')) {
|
if ($request->has('confirmed')) {
|
||||||
UserWorkLog_delete($userWorkLog);
|
UserWorkLog_delete($userWorkLog);
|
||||||
|
|
||||||
success(__('Work log entry deleted.'));
|
success(__('Work log entry deleted.'));
|
||||||
redirect(user_link($user_source['UID']));
|
redirect(user_link($user_source->id));
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
@ -36,12 +38,12 @@ function user_worklog_delete_controller()
|
||||||
*/
|
*/
|
||||||
function user_worklog_edit_controller()
|
function user_worklog_edit_controller()
|
||||||
{
|
{
|
||||||
global $user;
|
$user = auth()->user();
|
||||||
|
|
||||||
$request = request();
|
$request = request();
|
||||||
$userWorkLog = UserWorkLog($request->input('user_worklog_id'));
|
$userWorkLog = UserWorkLog($request->input('user_worklog_id'));
|
||||||
if (empty($userWorkLog)) {
|
if (empty($userWorkLog)) {
|
||||||
redirect(user_link($user['UID']));
|
redirect(user_link($user->id));
|
||||||
}
|
}
|
||||||
$user_source = User($userWorkLog['user_id']);
|
$user_source = User($userWorkLog['user_id']);
|
||||||
|
|
||||||
|
@ -108,15 +110,15 @@ function user_worklog_from_request($userWorkLog)
|
||||||
*/
|
*/
|
||||||
function user_worklog_add_controller()
|
function user_worklog_add_controller()
|
||||||
{
|
{
|
||||||
global $user;
|
$user = auth()->user();
|
||||||
|
|
||||||
$request = request();
|
$request = request();
|
||||||
$user_source = User($request->input('user_id'));
|
$user_source = User($request->input('user_id'));
|
||||||
if (empty($user_source)) {
|
if (empty($user_source)) {
|
||||||
redirect(user_link($user['UID']));
|
redirect(user_link($user->id));
|
||||||
}
|
}
|
||||||
|
|
||||||
$userWorkLog = UserWorkLog_new($user_source);
|
$userWorkLog = UserWorkLog_new($user_source['UID']);
|
||||||
|
|
||||||
if ($request->has('submit')) {
|
if ($request->has('submit')) {
|
||||||
list ($valid, $userWorkLog) = user_worklog_from_request($userWorkLog);
|
list ($valid, $userWorkLog) = user_worklog_from_request($userWorkLog);
|
||||||
|
@ -186,16 +188,17 @@ function user_worklog_delete_link($userWorkLog, $parameters = [])
|
||||||
*/
|
*/
|
||||||
function user_worklog_controller()
|
function user_worklog_controller()
|
||||||
{
|
{
|
||||||
global $user, $privileges;
|
global $privileges;
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
if (!in_array('admin_user_worklog', $privileges)) {
|
if (!in_array('admin_user_worklog', $privileges)) {
|
||||||
redirect(user_link($user['UID']));
|
redirect(user_link($user->id));
|
||||||
}
|
}
|
||||||
|
|
||||||
$request = request();
|
$request = request();
|
||||||
$action = $request->input('action');
|
$action = $request->input('action');
|
||||||
if (!$request->has('action')) {
|
if (!$request->has('action')) {
|
||||||
redirect(user_link($user['UID']));
|
redirect(user_link($user->id));
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Engelsystem\Database\DB;
|
use Engelsystem\Database\DB;
|
||||||
|
use Engelsystem\Models\User\PasswordReset;
|
||||||
|
use Engelsystem\Models\User\User;
|
||||||
use Engelsystem\ShiftCalendarRenderer;
|
use Engelsystem\ShiftCalendarRenderer;
|
||||||
use Engelsystem\ShiftsFilter;
|
use Engelsystem\ShiftsFilter;
|
||||||
|
|
||||||
|
@ -43,11 +45,12 @@ function users_controller()
|
||||||
*/
|
*/
|
||||||
function user_delete_controller()
|
function user_delete_controller()
|
||||||
{
|
{
|
||||||
global $privileges, $user;
|
global $privileges;
|
||||||
|
$user = auth()->user();
|
||||||
$request = request();
|
$request = request();
|
||||||
|
|
||||||
if ($request->has('user_id')) {
|
if ($request->has('user_id')) {
|
||||||
$user_source = User($request->query->get('user_id'));
|
$user_source = User::find($request->query->get('user_id'));
|
||||||
} else {
|
} else {
|
||||||
$user_source = $user;
|
$user_source = $user;
|
||||||
}
|
}
|
||||||
|
@ -57,9 +60,9 @@ function user_delete_controller()
|
||||||
}
|
}
|
||||||
|
|
||||||
// You cannot delete yourself
|
// You cannot delete yourself
|
||||||
if ($user['UID'] == $user_source['UID']) {
|
if ($user->id == $user_source->id) {
|
||||||
error(__('You cannot delete yourself.'));
|
error(__('You cannot delete yourself.'));
|
||||||
redirect(user_link($user['UID']));
|
redirect(user_link($user->id));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($request->has('submit')) {
|
if ($request->has('submit')) {
|
||||||
|
@ -68,7 +71,7 @@ function user_delete_controller()
|
||||||
if (
|
if (
|
||||||
!(
|
!(
|
||||||
$request->has('password')
|
$request->has('password')
|
||||||
&& verify_password($request->postData('password'), $user['Passwort'], $user['UID'])
|
&& verify_password($request->postData('password'), $user->password, $user->id)
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
|
@ -76,7 +79,7 @@ function user_delete_controller()
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
User_delete($user_source['UID']);
|
User_delete($user_source->id);
|
||||||
|
|
||||||
mail_user_delete($user_source);
|
mail_user_delete($user_source);
|
||||||
success(__('User deleted.'));
|
success(__('User deleted.'));
|
||||||
|
@ -87,7 +90,7 @@ function user_delete_controller()
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
sprintf(__('Delete %s'), $user_source['Nick']),
|
sprintf(__('Delete %s'), $user_source->name),
|
||||||
User_delete_view($user_source)
|
User_delete_view($user_source)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -196,7 +199,7 @@ function user_controller()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$shifts = Shifts_by_user($user_source, in_array('user_shifts_admin', $privileges));
|
$shifts = Shifts_by_user($user_source['UID'], in_array('user_shifts_admin', $privileges));
|
||||||
foreach ($shifts as &$shift) {
|
foreach ($shifts as &$shift) {
|
||||||
// TODO: Move queries to model
|
// TODO: Move queries to model
|
||||||
$shift['needed_angeltypes'] = DB::select('
|
$shift['needed_angeltypes'] = DB::select('
|
||||||
|
@ -228,7 +231,7 @@ function user_controller()
|
||||||
if ($user_source['force_active']) {
|
if ($user_source['force_active']) {
|
||||||
$tshirt_score = __('Enough');
|
$tshirt_score = __('Enough');
|
||||||
} else {
|
} else {
|
||||||
$tshirt_score = sprintf('%.2f', User_tshirt_score($user_source)) . ' h';
|
$tshirt_score = sprintf('%.2f', User_tshirt_score($user_source['UID'])) . ' h';
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
@ -237,14 +240,14 @@ function user_controller()
|
||||||
$user_source,
|
$user_source,
|
||||||
in_array('admin_user', $privileges),
|
in_array('admin_user', $privileges),
|
||||||
User_is_freeloader($user_source),
|
User_is_freeloader($user_source),
|
||||||
User_angeltypes($user_source),
|
User_angeltypes($user_source['UID']),
|
||||||
User_groups($user_source),
|
User_groups($user_source['UID']),
|
||||||
$shifts,
|
$shifts,
|
||||||
$user['UID'] == $user_source['UID'],
|
$user['UID'] == $user_source['UID'],
|
||||||
$tshirt_score,
|
$tshirt_score,
|
||||||
in_array('admin_active', $privileges),
|
in_array('admin_active', $privileges),
|
||||||
in_array('admin_user_worklog', $privileges),
|
in_array('admin_user_worklog', $privileges),
|
||||||
UserWorkLogsForUser($user_source)
|
UserWorkLogsForUser($user_source['UID'])
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -270,7 +273,7 @@ function users_list_controller()
|
||||||
|
|
||||||
$users = Users($order_by);
|
$users = Users($order_by);
|
||||||
foreach ($users as &$user) {
|
foreach ($users as &$user) {
|
||||||
$user['freeloads'] = count(ShiftEntries_freeloaded_by_user($user));
|
$user['freeloads'] = count(ShiftEntries_freeloaded_by_user($user['UID']));
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
@ -296,8 +299,8 @@ function users_list_controller()
|
||||||
function user_password_recovery_set_new_controller()
|
function user_password_recovery_set_new_controller()
|
||||||
{
|
{
|
||||||
$request = request();
|
$request = request();
|
||||||
$user_source = User_by_password_recovery_token($request->input('token'));
|
$passwordReset = PasswordReset::whereToken($request->input('token'));
|
||||||
if (empty($user_source)) {
|
if (!$passwordReset) {
|
||||||
error(__('Token is not correct.'));
|
error(__('Token is not correct.'));
|
||||||
redirect(page_link_to('login'));
|
redirect(page_link_to('login'));
|
||||||
}
|
}
|
||||||
|
@ -319,8 +322,9 @@ function user_password_recovery_set_new_controller()
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
set_password($user_source['UID'], $request->postData('password'));
|
set_password($passwordReset->user->id, $request->postData('password'));
|
||||||
success(__('Password saved.'));
|
success(__('Password saved.'));
|
||||||
|
$passwordReset->delete();
|
||||||
redirect(page_link_to('login'));
|
redirect(page_link_to('login'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,32 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Engelsystem\Mail\EngelsystemMailer;
|
use Engelsystem\Mail\EngelsystemMailer;
|
||||||
|
use Engelsystem\Models\User\User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $recipient_user
|
* @param array|User $recipientUser
|
||||||
* @param string $title
|
* @param string $title
|
||||||
* @param string $message
|
* @param string $message
|
||||||
* @param bool $not_if_its_me
|
* @param bool $notIfItsMe
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function engelsystem_email_to_user($recipient_user, $title, $message, $not_if_its_me = false)
|
function engelsystem_email_to_user($recipientUser, $title, $message, $notIfItsMe = false)
|
||||||
{
|
{
|
||||||
$user = Auth()->user();
|
$user = Auth()->user();
|
||||||
|
|
||||||
if ($not_if_its_me && $user->id == $recipient_user['UID']) {
|
if ($recipientUser instanceof User) {
|
||||||
|
$id = $user->id;
|
||||||
|
$lang = $user->settings->language;
|
||||||
|
$email = $user->contact->email ? $user->contact->email : $user->email;
|
||||||
|
$username = $user->name;
|
||||||
|
} else {
|
||||||
|
$id = $recipientUser['UID'];
|
||||||
|
$lang = $recipientUser['Sprache'];
|
||||||
|
$email = $recipientUser['email'];
|
||||||
|
$username = $recipientUser['Nick'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($notIfItsMe && $user->id == $id) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,12 +36,12 @@ function engelsystem_email_to_user($recipient_user, $title, $message, $not_if_it
|
||||||
/** @var EngelsystemMailer $mailer */
|
/** @var EngelsystemMailer $mailer */
|
||||||
$mailer = app('mailer');
|
$mailer = app('mailer');
|
||||||
|
|
||||||
$translator->setLocale($recipient_user['Sprache']);
|
$translator->setLocale($lang);
|
||||||
$status = $mailer->sendView(
|
$status = $mailer->sendView(
|
||||||
$recipient_user['email'],
|
$email,
|
||||||
$title,
|
$title,
|
||||||
'emails/mail',
|
'emails/mail',
|
||||||
['username' => $recipient_user['Nick'], 'message' => $message]
|
['username' => $username, 'message' => $message]
|
||||||
);
|
);
|
||||||
$translator->setLocale($locale);
|
$translator->setLocale($locale);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Engelsystem\Models\User\User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $old_shift
|
* @param array $old_shift
|
||||||
* @param array $new_shift
|
* @param array $new_shift
|
||||||
|
@ -96,12 +98,12 @@ function mail_shift_delete($shift)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $user
|
* @param User $user
|
||||||
* @param array $shift
|
* @param array $shift
|
||||||
*/
|
*/
|
||||||
function mail_shift_assign($user, $shift)
|
function mail_shift_assign($user, $shift)
|
||||||
{
|
{
|
||||||
if (!$user['email_shiftinfo']) {
|
if (!$user->settings->email_shiftinfo) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,12 +119,12 @@ function mail_shift_assign($user, $shift)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $user
|
* @param User $user
|
||||||
* @param array $shift
|
* @param array $shift
|
||||||
*/
|
*/
|
||||||
function mail_shift_removed($user, $shift)
|
function mail_shift_removed($user, $shift)
|
||||||
{
|
{
|
||||||
if (!$user['email_shiftinfo']) {
|
if (!$user->settings->email_shiftinfo) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Engelsystem\Models\User\User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $user
|
* @param User $user
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function mail_user_delete($user)
|
function mail_user_delete($user)
|
||||||
|
|
|
@ -181,10 +181,10 @@ function AngelType_validate_name($name, $angeltype)
|
||||||
/**
|
/**
|
||||||
* Returns all angeltypes and subscription state to each of them for given user.
|
* Returns all angeltypes and subscription state to each of them for given user.
|
||||||
*
|
*
|
||||||
* @param array $user
|
* @param int $userId
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function AngelTypes_with_user($user)
|
function AngelTypes_with_user($userId)
|
||||||
{
|
{
|
||||||
return DB::select('
|
return DB::select('
|
||||||
SELECT `AngelTypes`.*,
|
SELECT `AngelTypes`.*,
|
||||||
|
@ -194,7 +194,7 @@ function AngelTypes_with_user($user)
|
||||||
FROM `AngelTypes`
|
FROM `AngelTypes`
|
||||||
LEFT JOIN `UserAngelTypes` ON `AngelTypes`.`id`=`UserAngelTypes`.`angeltype_id`
|
LEFT JOIN `UserAngelTypes` ON `AngelTypes`.`id`=`UserAngelTypes`.`angeltype_id`
|
||||||
AND `UserAngelTypes`.`user_id` = ?
|
AND `UserAngelTypes`.`user_id` = ?
|
||||||
ORDER BY `name`', [$user['UID']]);
|
ORDER BY `name`', [$userId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Engelsystem\Database\DB;
|
use Engelsystem\Database\DB;
|
||||||
|
use Engelsystem\Models\User\User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array with the attributes of shift entries.
|
* Returns an array with the attributes of shift entries.
|
||||||
|
@ -74,7 +75,7 @@ function ShiftEntries_by_shift($shift_id)
|
||||||
*/
|
*/
|
||||||
function ShiftEntry_create($shift_entry)
|
function ShiftEntry_create($shift_entry)
|
||||||
{
|
{
|
||||||
$user = User($shift_entry['UID']);
|
$user = User::find($shift_entry['UID']);
|
||||||
$shift = Shift($shift_entry['SID']);
|
$shift = Shift($shift_entry['SID']);
|
||||||
mail_shift_assign($user, $shift);
|
mail_shift_assign($user, $shift);
|
||||||
$result = DB::insert('
|
$result = DB::insert('
|
||||||
|
@ -150,10 +151,10 @@ function ShiftEntry($shift_entry_id)
|
||||||
*/
|
*/
|
||||||
function ShiftEntry_delete($shiftEntry)
|
function ShiftEntry_delete($shiftEntry)
|
||||||
{
|
{
|
||||||
mail_shift_removed(User($shiftEntry['UID']), Shift($shiftEntry['SID']));
|
mail_shift_removed(User::find($shiftEntry['UID']), Shift($shiftEntry['SID']));
|
||||||
DB::delete('DELETE FROM `ShiftEntry` WHERE `id` = ?', [$shiftEntry['id']]);
|
DB::delete('DELETE FROM `ShiftEntry` WHERE `id` = ?', [$shiftEntry['id']]);
|
||||||
|
|
||||||
$signout_user = User($shiftEntry['UID']);
|
$signout_user = User::find($shiftEntry['UID']);
|
||||||
$shift = Shift($shiftEntry['SID']);
|
$shift = Shift($shiftEntry['SID']);
|
||||||
$shifttype = ShiftType($shift['shifttype_id']);
|
$shifttype = ShiftType($shift['shifttype_id']);
|
||||||
$room = Room($shift['RID']);
|
$room = Room($shift['RID']);
|
||||||
|
@ -171,10 +172,10 @@ function ShiftEntry_delete($shiftEntry)
|
||||||
/**
|
/**
|
||||||
* Returns next (or current) shifts of given user.
|
* Returns next (or current) shifts of given user.
|
||||||
*
|
*
|
||||||
* @param array $user
|
* @param int $userId
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function ShiftEntries_upcoming_for_user($user)
|
function ShiftEntries_upcoming_for_user($userId)
|
||||||
{
|
{
|
||||||
return DB::select('
|
return DB::select('
|
||||||
SELECT *
|
SELECT *
|
||||||
|
@ -186,7 +187,7 @@ function ShiftEntries_upcoming_for_user($user)
|
||||||
ORDER BY `Shifts`.`end`
|
ORDER BY `Shifts`.`end`
|
||||||
',
|
',
|
||||||
[
|
[
|
||||||
$user['UID'],
|
$userId,
|
||||||
time(),
|
time(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -195,10 +196,10 @@ function ShiftEntries_upcoming_for_user($user)
|
||||||
/**
|
/**
|
||||||
* Returns shifts completed by the given user.
|
* Returns shifts completed by the given user.
|
||||||
*
|
*
|
||||||
* @param array $user
|
* @param int $userId
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function ShiftEntries_finished_by_user($user)
|
function ShiftEntries_finished_by_user($userId)
|
||||||
{
|
{
|
||||||
return DB::select('
|
return DB::select('
|
||||||
SELECT *
|
SELECT *
|
||||||
|
@ -211,7 +212,7 @@ function ShiftEntries_finished_by_user($user)
|
||||||
ORDER BY `Shifts`.`end`
|
ORDER BY `Shifts`.`end`
|
||||||
',
|
',
|
||||||
[
|
[
|
||||||
$user['UID'],
|
$userId,
|
||||||
time(),
|
time(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -242,10 +243,10 @@ function ShiftEntries_by_shift_and_angeltype($shift_id, $angeltype_id)
|
||||||
/**
|
/**
|
||||||
* Returns all freeloaded shifts for given user.
|
* Returns all freeloaded shifts for given user.
|
||||||
*
|
*
|
||||||
* @param array $user
|
* @param int $userId
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function ShiftEntries_freeloaded_by_user($user)
|
function ShiftEntries_freeloaded_by_user($userId)
|
||||||
{
|
{
|
||||||
return DB::select('
|
return DB::select('
|
||||||
SELECT *
|
SELECT *
|
||||||
|
@ -254,7 +255,7 @@ function ShiftEntries_freeloaded_by_user($user)
|
||||||
AND `UID` = ?
|
AND `UID` = ?
|
||||||
',
|
',
|
||||||
[
|
[
|
||||||
$user['UID']
|
$userId
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -326,7 +326,7 @@ function Shift_signup_allowed_angel(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($user_shifts)) {
|
if (empty($user_shifts)) {
|
||||||
$user_shifts = Shifts_by_user($user);
|
$user_shifts = Shifts_by_user($user['UID']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$signed_up = false;
|
$signed_up = false;
|
||||||
|
@ -352,7 +352,7 @@ function Shift_signup_allowed_angel(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($user_angeltype)) {
|
if (empty($user_angeltype)) {
|
||||||
$user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
|
$user_angeltype = UserAngelType_by_User_and_AngelType($user['UID'], $angeltype);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
@ -577,7 +577,7 @@ function Shift_update_by_psid($shift)
|
||||||
*/
|
*/
|
||||||
function Shift_create($shift)
|
function Shift_create($shift)
|
||||||
{
|
{
|
||||||
global $user;
|
$user = auth()->user();
|
||||||
DB::insert('
|
DB::insert('
|
||||||
INSERT INTO `Shifts` (
|
INSERT INTO `Shifts` (
|
||||||
`shifttype_id`,
|
`shifttype_id`,
|
||||||
|
@ -601,7 +601,7 @@ function Shift_create($shift)
|
||||||
$shift['title'],
|
$shift['title'],
|
||||||
$shift['URL'],
|
$shift['URL'],
|
||||||
$shift['PSID'],
|
$shift['PSID'],
|
||||||
$user['UID'],
|
$user->id,
|
||||||
time(),
|
time(),
|
||||||
time(),
|
time(),
|
||||||
]
|
]
|
||||||
|
@ -613,11 +613,11 @@ function Shift_create($shift)
|
||||||
/**
|
/**
|
||||||
* Return users shifts.
|
* Return users shifts.
|
||||||
*
|
*
|
||||||
* @param array $user
|
* @param int $userId
|
||||||
* @param bool $include_freeload_comments
|
* @param bool $include_freeload_comments
|
||||||
* @return array[]
|
* @return array[]
|
||||||
*/
|
*/
|
||||||
function Shifts_by_user($user, $include_freeload_comments = false)
|
function Shifts_by_user($userId, $include_freeload_comments = false)
|
||||||
{
|
{
|
||||||
return DB::select('
|
return DB::select('
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -640,7 +640,7 @@ function Shifts_by_user($user, $include_freeload_comments = false)
|
||||||
ORDER BY `start`
|
ORDER BY `start`
|
||||||
',
|
',
|
||||||
[
|
[
|
||||||
$user['UID']
|
$userId
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,43 +9,43 @@ use Engelsystem\Database\DB;
|
||||||
/**
|
/**
|
||||||
* Checks if a user joined an angeltype.
|
* Checks if a user joined an angeltype.
|
||||||
*
|
*
|
||||||
* @param array $user The user to be checked
|
* @param int $userId The user to be checked
|
||||||
* @param array $angeltype The angeltype to be checked
|
* @param array $angeltype The angeltype to be checked
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function UserAngelType_exists($user, $angeltype)
|
function UserAngelType_exists($userId, $angeltype)
|
||||||
{
|
{
|
||||||
return count(DB::select('
|
return count(DB::select('
|
||||||
SELECT `id`
|
SELECT `id`
|
||||||
FROM `UserAngelTypes`
|
FROM `UserAngelTypes`
|
||||||
WHERE `UserAngelTypes`.`user_id`=?
|
WHERE `UserAngelTypes`.`user_id`=?
|
||||||
AND `angeltype_id`=?
|
AND `angeltype_id`=?
|
||||||
', [$user['UID'], $angeltype['id']])) > 0;
|
', [$userId, $angeltype['id']])) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List users angeltypes.
|
* List users angeltypes.
|
||||||
*
|
*
|
||||||
* @param array $user
|
* @param int $userId
|
||||||
* @return array[]
|
* @return array[]
|
||||||
*/
|
*/
|
||||||
function User_angeltypes($user)
|
function User_angeltypes($userId)
|
||||||
{
|
{
|
||||||
return DB::select('
|
return DB::select('
|
||||||
SELECT `AngelTypes`.*, `UserAngelTypes`.`confirm_user_id`, `UserAngelTypes`.`supporter`
|
SELECT `AngelTypes`.*, `UserAngelTypes`.`confirm_user_id`, `UserAngelTypes`.`supporter`
|
||||||
FROM `UserAngelTypes`
|
FROM `UserAngelTypes`
|
||||||
JOIN `AngelTypes` ON `UserAngelTypes`.`angeltype_id` = `AngelTypes`.`id`
|
JOIN `AngelTypes` ON `UserAngelTypes`.`angeltype_id` = `AngelTypes`.`id`
|
||||||
WHERE `UserAngelTypes`.`user_id`=?
|
WHERE `UserAngelTypes`.`user_id`=?
|
||||||
', [$user['UID']]);
|
', [$userId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets unconfirmed user angeltypes for angeltypes of which the given user is a supporter.
|
* Gets unconfirmed user angeltypes for angeltypes of which the given user is a supporter.
|
||||||
*
|
*
|
||||||
* @param array $user
|
* @param int $userId
|
||||||
* @return array[]
|
* @return array[]
|
||||||
*/
|
*/
|
||||||
function User_unconfirmed_AngelTypes($user)
|
function User_unconfirmed_AngelTypes($userId)
|
||||||
{
|
{
|
||||||
return DB::select('
|
return DB::select('
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -61,7 +61,7 @@ function User_unconfirmed_AngelTypes($user)
|
||||||
AND `UnconfirmedMembers`.`confirm_user_id` IS NULL
|
AND `UnconfirmedMembers`.`confirm_user_id` IS NULL
|
||||||
GROUP BY `UserAngelTypes`.`angeltype_id`, `UserAngelTypes`.`id`
|
GROUP BY `UserAngelTypes`.`angeltype_id`, `UserAngelTypes`.`id`
|
||||||
ORDER BY `AngelTypes`.`name`
|
ORDER BY `AngelTypes`.`name`
|
||||||
', [$user['UID']]);
|
', [$userId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -126,32 +126,32 @@ function UserAngelTypes_delete_all($angeltype_id)
|
||||||
/**
|
/**
|
||||||
* Confirm all unconfirmed UserAngelTypes for given Angeltype.
|
* Confirm all unconfirmed UserAngelTypes for given Angeltype.
|
||||||
*
|
*
|
||||||
* @param int $angeltype_id
|
* @param int $angeltype_id
|
||||||
* @param array $confirm_user
|
* @param int $confirm_user_id
|
||||||
*/
|
*/
|
||||||
function UserAngelTypes_confirm_all($angeltype_id, $confirm_user)
|
function UserAngelTypes_confirm_all($angeltype_id, $confirm_user_id)
|
||||||
{
|
{
|
||||||
DB::update('
|
DB::update('
|
||||||
UPDATE `UserAngelTypes`
|
UPDATE `UserAngelTypes`
|
||||||
SET `confirm_user_id`=?
|
SET `confirm_user_id`=?
|
||||||
WHERE `angeltype_id`=?
|
WHERE `angeltype_id`=?
|
||||||
AND `confirm_user_id` IS NULL
|
AND `confirm_user_id` IS NULL
|
||||||
', [$confirm_user['UID'], $angeltype_id]);
|
', [$confirm_user_id, $angeltype_id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Confirm an UserAngelType with confirming user.
|
* Confirm an UserAngelType with confirming user.
|
||||||
*
|
*
|
||||||
* @param int $user_angeltype_id
|
* @param int $user_angeltype_id
|
||||||
* @param array $confirm_user
|
* @param int $confirm_user_id
|
||||||
*/
|
*/
|
||||||
function UserAngelType_confirm($user_angeltype_id, $confirm_user)
|
function UserAngelType_confirm($user_angeltype_id, $confirm_user_id)
|
||||||
{
|
{
|
||||||
DB::update('
|
DB::update('
|
||||||
UPDATE `UserAngelTypes`
|
UPDATE `UserAngelTypes`
|
||||||
SET `confirm_user_id`=?
|
SET `confirm_user_id`=?
|
||||||
WHERE `id`=?
|
WHERE `id`=?
|
||||||
LIMIT 1', [$confirm_user['UID'], $user_angeltype_id]);
|
LIMIT 1', [$confirm_user_id, $user_angeltype_id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -170,18 +170,18 @@ function UserAngelType_delete($user_angeltype)
|
||||||
/**
|
/**
|
||||||
* Create an UserAngelType.
|
* Create an UserAngelType.
|
||||||
*
|
*
|
||||||
* @param array $user
|
* @param int $userId
|
||||||
* @param array $angeltype
|
* @param array $angeltype
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
function UserAngelType_create($user, $angeltype)
|
function UserAngelType_create($userId, $angeltype)
|
||||||
{
|
{
|
||||||
DB::insert('
|
DB::insert('
|
||||||
INSERT INTO `UserAngelTypes` (`user_id`, `angeltype_id`, `supporter`)
|
INSERT INTO `UserAngelTypes` (`user_id`, `angeltype_id`, `supporter`)
|
||||||
VALUES (?, ?, FALSE)
|
VALUES (?, ?, FALSE)
|
||||||
',
|
',
|
||||||
[
|
[
|
||||||
$user['UID'],
|
$userId,
|
||||||
$angeltype['id']
|
$angeltype['id']
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -209,11 +209,11 @@ function UserAngelType($user_angeltype_id)
|
||||||
/**
|
/**
|
||||||
* Get an UserAngelType by user and angeltype.
|
* Get an UserAngelType by user and angeltype.
|
||||||
*
|
*
|
||||||
* @param array $user
|
* @param int $userId
|
||||||
* @param array $angeltype
|
* @param array $angeltype
|
||||||
* @return array|null
|
* @return array|null
|
||||||
*/
|
*/
|
||||||
function UserAngelType_by_User_and_AngelType($user, $angeltype)
|
function UserAngelType_by_User_and_AngelType($userId, $angeltype)
|
||||||
{
|
{
|
||||||
$angelType = DB::selectOne('
|
$angelType = DB::selectOne('
|
||||||
SELECT *
|
SELECT *
|
||||||
|
@ -223,7 +223,7 @@ function UserAngelType_by_User_and_AngelType($user, $angeltype)
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
',
|
',
|
||||||
[
|
[
|
||||||
$user['UID'],
|
$userId,
|
||||||
$angeltype['id']
|
$angeltype['id']
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -234,16 +234,16 @@ function UserAngelType_by_User_and_AngelType($user, $angeltype)
|
||||||
/**
|
/**
|
||||||
* Get an UserAngelTypes by user
|
* Get an UserAngelTypes by user
|
||||||
*
|
*
|
||||||
* @param array $user
|
* @param int $userId
|
||||||
* @return array[]|null
|
* @return array[]|null
|
||||||
*/
|
*/
|
||||||
function UserAngelTypes_by_User($user)
|
function UserAngelTypes_by_User($userId)
|
||||||
{
|
{
|
||||||
return DB::select('
|
return DB::select('
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `UserAngelTypes`
|
FROM `UserAngelTypes`
|
||||||
WHERE `user_id`=?
|
WHERE `user_id`=?
|
||||||
',
|
',
|
||||||
[$user['UID']]
|
[$userId]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,12 +57,12 @@ function UserDriverLicense($user_id)
|
||||||
* Create a user's driver license entry
|
* Create a user's driver license entry
|
||||||
*
|
*
|
||||||
* @param array $user_driver_license The UserDriverLicense to create
|
* @param array $user_driver_license The UserDriverLicense to create
|
||||||
* @param array $user
|
* @param int $userId
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function UserDriverLicenses_create($user_driver_license, $user)
|
function UserDriverLicenses_create($user_driver_license, $userId)
|
||||||
{
|
{
|
||||||
$user_driver_license['user_id'] = $user['UID'];
|
$user_driver_license['user_id'] = $userId;
|
||||||
DB::insert('
|
DB::insert('
|
||||||
INSERT INTO `UserDriverLicenses` (
|
INSERT INTO `UserDriverLicenses` (
|
||||||
`user_id`,
|
`user_id`,
|
||||||
|
|
|
@ -5,10 +5,10 @@ use Engelsystem\Database\DB;
|
||||||
/**
|
/**
|
||||||
* Returns users groups
|
* Returns users groups
|
||||||
*
|
*
|
||||||
* @param array $user
|
* @param int $userId
|
||||||
* @return array[]
|
* @return array[]
|
||||||
*/
|
*/
|
||||||
function User_groups($user)
|
function User_groups($userId)
|
||||||
{
|
{
|
||||||
return DB::select('
|
return DB::select('
|
||||||
SELECT `Groups`.*
|
SELECT `Groups`.*
|
||||||
|
@ -17,6 +17,6 @@ function User_groups($user)
|
||||||
WHERE `UserGroups`.`uid`=?
|
WHERE `UserGroups`.`uid`=?
|
||||||
ORDER BY `UserGroups`.`group_id`
|
ORDER BY `UserGroups`.`group_id`
|
||||||
',
|
',
|
||||||
[$user['UID']]
|
[$userId]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,13 +21,13 @@ function UserWorkLog($user_worklog_id)
|
||||||
/**
|
/**
|
||||||
* Returns all work log entries for a user.
|
* Returns all work log entries for a user.
|
||||||
*
|
*
|
||||||
* @param array $user
|
* @param int $userId
|
||||||
* @return array[]
|
* @return array[]
|
||||||
*/
|
*/
|
||||||
function UserWorkLogsForUser($user)
|
function UserWorkLogsForUser($userId)
|
||||||
{
|
{
|
||||||
return Db::select("SELECT * FROM `UserWorkLog` WHERE `user_id`=? ORDER BY `created_timestamp`", [
|
return Db::select("SELECT * FROM `UserWorkLog` WHERE `user_id`=? ORDER BY `created_timestamp`", [
|
||||||
$user['UID']
|
$userId
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,10 +123,10 @@ function UserWorkLog_create($userWorkLog)
|
||||||
/**
|
/**
|
||||||
* New user work log entry
|
* New user work log entry
|
||||||
*
|
*
|
||||||
* @param array[] $user
|
* @param int $userId
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function UserWorkLog_new($user)
|
function UserWorkLog_new($userId)
|
||||||
{
|
{
|
||||||
$work_date = parse_date('Y-m-d H:i', date('Y-m-d 00:00', time()));
|
$work_date = parse_date('Y-m-d H:i', date('Y-m-d 00:00', time()));
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ function UserWorkLog_new($user)
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'user_id' => $user['UID'],
|
'user_id' => $userId,
|
||||||
'work_timestamp' => $work_date,
|
'work_timestamp' => $work_date,
|
||||||
'work_hours' => 0,
|
'work_hours' => 0,
|
||||||
'comment' => ''
|
'comment' => ''
|
||||||
|
|
|
@ -22,10 +22,10 @@ function User_delete($user_id)
|
||||||
* Returns the tshirt score (number of hours counted for tshirt).
|
* Returns the tshirt score (number of hours counted for tshirt).
|
||||||
* Accounts only ended shifts.
|
* Accounts only ended shifts.
|
||||||
*
|
*
|
||||||
* @param array[] $user
|
* @param int $userId
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
function User_tshirt_score($user)
|
function User_tshirt_score($userId)
|
||||||
{
|
{
|
||||||
$shift_sum_formula = User_get_shifts_sum_query();
|
$shift_sum_formula = User_get_shifts_sum_query();
|
||||||
$result_shifts = DB::selectOne('
|
$result_shifts = DB::selectOne('
|
||||||
|
@ -36,7 +36,7 @@ function User_tshirt_score($user)
|
||||||
AND `Shifts`.`end` < ?
|
AND `Shifts`.`end` < ?
|
||||||
GROUP BY `User`.`UID`
|
GROUP BY `User`.`UID`
|
||||||
', [
|
', [
|
||||||
$user['UID'],
|
$userId,
|
||||||
time()
|
time()
|
||||||
]);
|
]);
|
||||||
if (!isset($result_shifts['tshirt_score'])) {
|
if (!isset($result_shifts['tshirt_score'])) {
|
||||||
|
@ -50,7 +50,7 @@ function User_tshirt_score($user)
|
||||||
WHERE `User`.`UID` = ?
|
WHERE `User`.`UID` = ?
|
||||||
AND `UserWorkLog`.`work_timestamp` < ?
|
AND `UserWorkLog`.`work_timestamp` < ?
|
||||||
', [
|
', [
|
||||||
$user['UID'],
|
$userId,
|
||||||
time()
|
time()
|
||||||
]);
|
]);
|
||||||
if (!isset($result_worklog['tshirt_score'])) {
|
if (!isset($result_worklog['tshirt_score'])) {
|
||||||
|
@ -245,7 +245,7 @@ function User_is_freeloader($user)
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
return count(ShiftEntries_freeloaded_by_user($user)) >= config('max_freeloadable_shifts');
|
return count(ShiftEntries_freeloaded_by_user($user['UID'])) >= config('max_freeloadable_shifts');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -526,10 +526,10 @@ function User_generate_password_recovery_token(&$user)
|
||||||
* @param array $user
|
* @param array $user
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
function User_get_eligable_voucher_count(&$user)
|
function User_get_eligable_voucher_count($user)
|
||||||
{
|
{
|
||||||
$voucher_settings = config('voucher_settings');
|
$voucher_settings = config('voucher_settings');
|
||||||
$shifts_done = count(ShiftEntries_finished_by_user($user));
|
$shifts_done = count(ShiftEntries_finished_by_user($user['UID']));
|
||||||
|
|
||||||
$earned_vouchers = $user['got_voucher'] - $voucher_settings['initial_vouchers'];
|
$earned_vouchers = $user['got_voucher'] - $voucher_settings['initial_vouchers'];
|
||||||
$eligable_vouchers = $shifts_done / $voucher_settings['shifts_per_voucher'] - $earned_vouchers;
|
$eligable_vouchers = $shifts_done / $voucher_settings['shifts_per_voucher'] - $earned_vouchers;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Engelsystem\Database\DB;
|
use Engelsystem\Database\DB;
|
||||||
|
use Engelsystem\Models\User\User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
|
@ -100,8 +101,8 @@ function admin_active()
|
||||||
|
|
||||||
if ($request->has('active') && preg_match('/^\d+$/', $request->input('active'))) {
|
if ($request->has('active') && preg_match('/^\d+$/', $request->input('active'))) {
|
||||||
$user_id = $request->input('active');
|
$user_id = $request->input('active');
|
||||||
$user_source = User($user_id);
|
$user_source = User::find($user_id);
|
||||||
if (!empty($user_source)) {
|
if ($user_source) {
|
||||||
DB::update('UPDATE `User` SET `Aktiv`=1 WHERE `UID`=? LIMIT 1', [$user_id]);
|
DB::update('UPDATE `User` SET `Aktiv`=1 WHERE `UID`=? LIMIT 1', [$user_id]);
|
||||||
engelsystem_log('User ' . User_Nick_render($user_source) . ' is active now.');
|
engelsystem_log('User ' . User_Nick_render($user_source) . ' is active now.');
|
||||||
$msg = success(__('Angel has been marked as active.'), true);
|
$msg = success(__('Angel has been marked as active.'), true);
|
||||||
|
@ -110,8 +111,8 @@ function admin_active()
|
||||||
}
|
}
|
||||||
} elseif ($request->has('not_active') && preg_match('/^\d+$/', $request->input('not_active'))) {
|
} elseif ($request->has('not_active') && preg_match('/^\d+$/', $request->input('not_active'))) {
|
||||||
$user_id = $request->input('not_active');
|
$user_id = $request->input('not_active');
|
||||||
$user_source = User($user_id);
|
$user_source = User::find($user_id);
|
||||||
if (!empty($user_source)) {
|
if (!$user_source) {
|
||||||
DB::update('UPDATE `User` SET `Aktiv`=0 WHERE `UID`=? LIMIT 1', [$user_id]);
|
DB::update('UPDATE `User` SET `Aktiv`=0 WHERE `UID`=? LIMIT 1', [$user_id]);
|
||||||
engelsystem_log('User ' . User_Nick_render($user_source) . ' is NOT active now.');
|
engelsystem_log('User ' . User_Nick_render($user_source) . ' is NOT active now.');
|
||||||
$msg = success(__('Angel has been marked as not active.'), true);
|
$msg = success(__('Angel has been marked as not active.'), true);
|
||||||
|
@ -120,8 +121,8 @@ function admin_active()
|
||||||
}
|
}
|
||||||
} elseif ($request->has('tshirt') && preg_match('/^\d+$/', $request->input('tshirt'))) {
|
} elseif ($request->has('tshirt') && preg_match('/^\d+$/', $request->input('tshirt'))) {
|
||||||
$user_id = $request->input('tshirt');
|
$user_id = $request->input('tshirt');
|
||||||
$user_source = User($user_id);
|
$user_source = User::find($user_id);
|
||||||
if (!empty($user_source)) {
|
if (!$user_source) {
|
||||||
DB::update('UPDATE `User` SET `Tshirt`=1 WHERE `UID`=? LIMIT 1', [$user_id]);
|
DB::update('UPDATE `User` SET `Tshirt`=1 WHERE `UID`=? LIMIT 1', [$user_id]);
|
||||||
engelsystem_log('User ' . User_Nick_render($user_source) . ' has tshirt now.');
|
engelsystem_log('User ' . User_Nick_render($user_source) . ' has tshirt now.');
|
||||||
$msg = success(__('Angel has got a t-shirt.'), true);
|
$msg = success(__('Angel has got a t-shirt.'), true);
|
||||||
|
@ -130,8 +131,8 @@ function admin_active()
|
||||||
}
|
}
|
||||||
} elseif ($request->has('not_tshirt') && preg_match('/^\d+$/', $request->input('not_tshirt'))) {
|
} elseif ($request->has('not_tshirt') && preg_match('/^\d+$/', $request->input('not_tshirt'))) {
|
||||||
$user_id = $request->input('not_tshirt');
|
$user_id = $request->input('not_tshirt');
|
||||||
$user_source = User($user_id);
|
$user_source = User::find($user_id);
|
||||||
if (!empty($user_source)) {
|
if (!$user_source) {
|
||||||
DB::update('UPDATE `User` SET `Tshirt`=0 WHERE `UID`=? LIMIT 1', [$user_id]);
|
DB::update('UPDATE `User` SET `Tshirt`=0 WHERE `UID`=? LIMIT 1', [$user_id]);
|
||||||
engelsystem_log('User ' . User_Nick_render($user_source) . ' has NO tshirt.');
|
engelsystem_log('User ' . User_Nick_render($user_source) . ' has NO tshirt.');
|
||||||
$msg = success(__('Angel has got no t-shirt.'), true);
|
$msg = success(__('Angel has got no t-shirt.'), true);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Engelsystem\Database\DB;
|
use Engelsystem\Database\DB;
|
||||||
|
use Engelsystem\Models\User\User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
|
@ -26,8 +27,8 @@ function admin_arrive()
|
||||||
|
|
||||||
if ($request->has('reset') && preg_match('/^\d+$/', $request->input('reset'))) {
|
if ($request->has('reset') && preg_match('/^\d+$/', $request->input('reset'))) {
|
||||||
$user_id = $request->input('reset');
|
$user_id = $request->input('reset');
|
||||||
$user_source = User($user_id);
|
$user_source = User::find($user_id);
|
||||||
if (!empty($user_source)) {
|
if ($user_source) {
|
||||||
DB::update('
|
DB::update('
|
||||||
UPDATE `User`
|
UPDATE `User`
|
||||||
SET `Gekommen`=0, `arrival_date` = NULL
|
SET `Gekommen`=0, `arrival_date` = NULL
|
||||||
|
@ -36,14 +37,14 @@ function admin_arrive()
|
||||||
', [$user_id]);
|
', [$user_id]);
|
||||||
engelsystem_log('User set to not arrived: ' . User_Nick_render($user_source));
|
engelsystem_log('User set to not arrived: ' . User_Nick_render($user_source));
|
||||||
success(__('Reset done. Angel has not arrived.'));
|
success(__('Reset done. Angel has not arrived.'));
|
||||||
redirect(user_link($user_source['UID']));
|
redirect(user_link($user_source->id));
|
||||||
} else {
|
} else {
|
||||||
$msg = error(__('Angel not found.'), true);
|
$msg = error(__('Angel not found.'), true);
|
||||||
}
|
}
|
||||||
} elseif ($request->has('arrived') && preg_match('/^\d+$/', $request->input('arrived'))) {
|
} elseif ($request->has('arrived') && preg_match('/^\d+$/', $request->input('arrived'))) {
|
||||||
$user_id = $request->input('arrived');
|
$user_id = $request->input('arrived');
|
||||||
$user_source = User($user_id);
|
$user_source = User::find($user_id);
|
||||||
if (!empty($user_source)) {
|
if ($user_source) {
|
||||||
DB::update('
|
DB::update('
|
||||||
UPDATE `User`
|
UPDATE `User`
|
||||||
SET `Gekommen`=1, `arrival_date`=?
|
SET `Gekommen`=1, `arrival_date`=?
|
||||||
|
@ -52,7 +53,7 @@ function admin_arrive()
|
||||||
', [time(), $user_id]);
|
', [time(), $user_id]);
|
||||||
engelsystem_log('User set has arrived: ' . User_Nick_render($user_source));
|
engelsystem_log('User set has arrived: ' . User_Nick_render($user_source));
|
||||||
success(__('Angel has been marked as arrived.'));
|
success(__('Angel has been marked as arrived.'));
|
||||||
redirect(user_link($user_source['UID']));
|
redirect(user_link($user_source->id));
|
||||||
} else {
|
} else {
|
||||||
$msg = error(__('Angel not found.'), true);
|
$msg = error(__('Angel not found.'), true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Engelsystem\Database\DB;
|
use Engelsystem\Database\DB;
|
||||||
|
use Engelsystem\Models\User\User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
|
@ -29,7 +30,7 @@ function admin_news()
|
||||||
|
|
||||||
switch ($request->input('action')) {
|
switch ($request->input('action')) {
|
||||||
case 'edit':
|
case 'edit':
|
||||||
$user_source = User($news['UID']);
|
$user_source = User::find($news['UID']);
|
||||||
if (
|
if (
|
||||||
!in_array('admin_news_html', $privileges)
|
!in_array('admin_news_html', $privileges)
|
||||||
&& strip_tags($news['Text']) != $news['Text']
|
&& strip_tags($news['Text']) != $news['Text']
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Engelsystem\Database\DB;
|
use Engelsystem\Database\DB;
|
||||||
|
use Engelsystem\Models\User\User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
|
@ -46,7 +47,7 @@ function admin_questions()
|
||||||
$unanswered_questions_table = [];
|
$unanswered_questions_table = [];
|
||||||
$questions = DB::select('SELECT * FROM `Questions` WHERE `AID` IS NULL');
|
$questions = DB::select('SELECT * FROM `Questions` WHERE `AID` IS NULL');
|
||||||
foreach ($questions as $question) {
|
foreach ($questions as $question) {
|
||||||
$user_source = User($question['UID']);
|
$user_source = User::find($question['UID']);
|
||||||
|
|
||||||
$unanswered_questions_table[] = [
|
$unanswered_questions_table[] = [
|
||||||
'from' => User_Nick_render($user_source),
|
'from' => User_Nick_render($user_source),
|
||||||
|
@ -66,7 +67,7 @@ function admin_questions()
|
||||||
$answered_questions_table = [];
|
$answered_questions_table = [];
|
||||||
$questions = DB::select('SELECT * FROM `Questions` WHERE NOT `AID` IS NULL');
|
$questions = DB::select('SELECT * FROM `Questions` WHERE NOT `AID` IS NULL');
|
||||||
foreach ($questions as $question) {
|
foreach ($questions as $question) {
|
||||||
$user_source = User($question['UID']);
|
$user_source = User::find($question['UID']);
|
||||||
$answer_user_source = User($question['AID']);
|
$answer_user_source = User($question['AID']);
|
||||||
$answered_questions_table[] = [
|
$answered_questions_table[] = [
|
||||||
'from' => User_Nick_render($user_source),
|
'from' => User_Nick_render($user_source),
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Engelsystem\Database\DB;
|
use Engelsystem\Database\DB;
|
||||||
|
use Engelsystem\Models\User\User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
|
@ -27,8 +28,8 @@ function admin_user()
|
||||||
|
|
||||||
$user_id = $request->input('id');
|
$user_id = $request->input('id');
|
||||||
if (!$request->has('action')) {
|
if (!$request->has('action')) {
|
||||||
$user_source = User($user_id);
|
$user_source = User::find($user_id);
|
||||||
if (empty($user_source)) {
|
if (!$user_source) {
|
||||||
error(__('This user does not exist.'));
|
error(__('This user does not exist.'));
|
||||||
redirect(users_link());
|
redirect(users_link());
|
||||||
}
|
}
|
||||||
|
@ -47,22 +48,20 @@ function admin_user()
|
||||||
$html .= '<input type="hidden" name="Type" value="Normal">' . "\n";
|
$html .= '<input type="hidden" name="Type" value="Normal">' . "\n";
|
||||||
$html .= '<tr><td>' . "\n";
|
$html .= '<tr><td>' . "\n";
|
||||||
$html .= '<table>' . "\n";
|
$html .= '<table>' . "\n";
|
||||||
$html .= ' <tr><td>Nick</td><td>' . '<input size="40" name="eNick" value="' . $user_source['Nick'] . '" class="form-control"></td></tr>' . "\n";
|
$html .= ' <tr><td>Nick</td><td>' . '<input size="40" name="eNick" value="' . $user_source->name . '" class="form-control"></td></tr>' . "\n";
|
||||||
$html .= ' <tr><td>Last login</td><td><p class="help-block">'
|
$html .= ' <tr><td>Last login</td><td><p class="help-block">'
|
||||||
. date('Y-m-d H:i', $user_source['lastLogIn'])
|
. $user_source->last_login_at->format('Y-m-d H:i')
|
||||||
. '</p></td></tr>' . "\n";
|
. '</p></td></tr>' . "\n";
|
||||||
$html .= ' <tr><td>Name</td><td>' . '<input size="40" name="eName" value="' . $user_source['Name'] . '" class="form-control"></td></tr>' . "\n";
|
$html .= ' <tr><td>Name</td><td>' . '<input size="40" name="eName" value="' . $user_source->personalData->last_name . '" class="form-control"></td></tr>' . "\n";
|
||||||
$html .= ' <tr><td>Vorname</td><td>' . '<input size="40" name="eVorname" value="' . $user_source['Vorname'] . '" class="form-control"></td></tr>' . "\n";
|
$html .= ' <tr><td>Vorname</td><td>' . '<input size="40" name="eVorname" value="' . $user_source->personalData->first_name . '" class="form-control"></td></tr>' . "\n";
|
||||||
$html .= ' <tr><td>Alter</td><td>' . '<input size="5" name="eAlter" value="' . $user_source['Alter'] . '" class="form-control"></td></tr>' . "\n";
|
$html .= ' <tr><td>Handy</td><td>' . '<input type= "tel" size="40" name="eHandy" value="' . $user_source->contact->mobile . '" class="form-control"></td></tr>' . "\n";
|
||||||
$html .= ' <tr><td>Telefon</td><td>' . '<input type="tel" size="40" name="eTelefon" value="' . $user_source['Telefon'] . '" class="form-control"></td></tr>' . "\n";
|
$html .= ' <tr><td>DECT</td><td>' . '<input size="4" name="eDECT" value="' . $user_source->contact->dect . '" class="form-control"></td></tr>' . "\n";
|
||||||
$html .= ' <tr><td>Handy</td><td>' . '<input type= "tel" size="40" name="eHandy" value="' . $user_source['Handy'] . '" class="form-control"></td></tr>' . "\n";
|
if ($user_source->settings->email_human) {
|
||||||
$html .= ' <tr><td>DECT</td><td>' . '<input size="4" name="eDECT" value="' . $user_source['DECT'] . '" class="form-control"></td></tr>' . "\n";
|
$html .= " <tr><td>email</td><td>" . '<input type="email" size="40" name="eemail" value="' . $user_source->email . '" class="form-control"></td></tr>' . "\n";
|
||||||
if ($user_source['email_by_human_allowed']) {
|
|
||||||
$html .= " <tr><td>email</td><td>" . '<input type="email" size="40" name="eemail" value="' . $user_source['email'] . '" class="form-control"></td></tr>' . "\n";
|
|
||||||
}
|
}
|
||||||
$html .= " <tr><td>jabber</td><td>" . '<input type="email" size="40" name="ejabber" value="' . $user_source['jabber'] . '" class="form-control"></td></tr>' . "\n";
|
|
||||||
$html .= ' <tr><td>Size</td><td>'
|
$html .= ' <tr><td>Size</td><td>'
|
||||||
. html_select_key('size', 'eSize', $tshirt_sizes, $user_source['Size'], __('Please select...')) . '</td></tr>' . "\n";
|
. html_select_key('size', 'eSize', $tshirt_sizes, $user_source->personalData->shirt_size,
|
||||||
|
__('Please select...')) . '</td></tr>' . "\n";
|
||||||
|
|
||||||
$options = [
|
$options = [
|
||||||
'1' => __('Yes'),
|
'1' => __('Yes'),
|
||||||
|
@ -71,23 +70,21 @@ function admin_user()
|
||||||
|
|
||||||
// Gekommen?
|
// Gekommen?
|
||||||
$html .= ' <tr><td>Gekommen</td><td>' . "\n";
|
$html .= ' <tr><td>Gekommen</td><td>' . "\n";
|
||||||
$html .= html_options('eGekommen', $options, $user_source['Gekommen']) . '</td></tr>' . "\n";
|
$html .= html_options('eGekommen', $options, $user_source->state->arrived) . '</td></tr>' . "\n";
|
||||||
|
|
||||||
// Aktiv?
|
// Aktiv?
|
||||||
$html .= ' <tr><td>Aktiv</td><td>' . "\n";
|
$html .= ' <tr><td>Aktiv</td><td>' . "\n";
|
||||||
$html .= html_options('eAktiv', $options, $user_source['Aktiv']) . '</td></tr>' . "\n";
|
$html .= html_options('eAktiv', $options, $user_source->state->active) . '</td></tr>' . "\n";
|
||||||
|
|
||||||
// Aktiv erzwingen
|
// Aktiv erzwingen
|
||||||
if (in_array('admin_active', $privileges)) {
|
if (in_array('admin_active', $privileges)) {
|
||||||
$html .= ' <tr><td>' . __('Force active') . '</td><td>' . "\n";
|
$html .= ' <tr><td>' . __('Force active') . '</td><td>' . "\n";
|
||||||
$html .= html_options('force_active', $options, $user_source['force_active']) . '</td></tr>' . "\n";
|
$html .= html_options('force_active', $options, $user_source->state->force_active) . '</td></tr>' . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// T-Shirt bekommen?
|
// T-Shirt bekommen?
|
||||||
$html .= ' <tr><td>T-Shirt</td><td>' . "\n";
|
$html .= ' <tr><td>T-Shirt</td><td>' . "\n";
|
||||||
$html .= html_options('eTshirt', $options, $user_source['Tshirt']) . '</td></tr>' . "\n";
|
$html .= html_options('eTshirt', $options, $user_source->personalData->shirt_size) . '</td></tr>' . "\n";
|
||||||
|
|
||||||
$html .= ' <tr><td>Hometown</td><td>' . '<input size="40" name="Hometown" value="' . $user_source['Hometown'] . '" class="form-control"></td></tr>' . "\n";
|
|
||||||
|
|
||||||
$html .= '</table>' . "\n" . '</td><td valign="top"></td></tr>';
|
$html .= '</table>' . "\n" . '</td><td valign="top"></td></tr>';
|
||||||
|
|
||||||
|
@ -165,7 +162,7 @@ function admin_user()
|
||||||
}
|
}
|
||||||
|
|
||||||
$html .= buttons([
|
$html .= buttons([
|
||||||
button(user_delete_link($user_source['UID']), glyph('lock') . __('delete'), 'btn-danger')
|
button(user_delete_link($user_source->id), glyph('lock') . __('delete'), 'btn-danger')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$html .= "<hr />";
|
$html .= "<hr />";
|
||||||
|
@ -227,7 +224,7 @@ function admin_user()
|
||||||
$user_groups_info[] = $groups[$group]['Name'];
|
$user_groups_info[] = $groups[$group]['Name'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$user_source = User($user_id);
|
$user_source = User::find($user_id);
|
||||||
engelsystem_log(
|
engelsystem_log(
|
||||||
'Set groups of ' . User_Nick_render($user_source) . ' to: '
|
'Set groups of ' . User_Nick_render($user_source) . ' to: '
|
||||||
. join(', ', $user_groups_info)
|
. join(', ', $user_groups_info)
|
||||||
|
@ -243,7 +240,7 @@ function admin_user()
|
||||||
|
|
||||||
case 'save':
|
case 'save':
|
||||||
$force_active = $user->state->force_active;
|
$force_active = $user->state->force_active;
|
||||||
$user_source = User($user_id);
|
$user_source = User::find($user_id);
|
||||||
if (in_array('admin_active', $privileges)) {
|
if (in_array('admin_active', $privileges)) {
|
||||||
$force_active = $request->input('force_active');
|
$force_active = $request->input('force_active');
|
||||||
}
|
}
|
||||||
|
@ -252,37 +249,29 @@ function admin_user()
|
||||||
`Nick` = ?,
|
`Nick` = ?,
|
||||||
`Name` = ?,
|
`Name` = ?,
|
||||||
`Vorname` = ?,
|
`Vorname` = ?,
|
||||||
`Telefon` = ?,
|
|
||||||
`Handy` = ?,
|
`Handy` = ?,
|
||||||
`Alter` =?,
|
|
||||||
`DECT` = ?,
|
`DECT` = ?,
|
||||||
' . ($user_source['email_by_human_allowed']
|
' . ($user_source->settings->email_human
|
||||||
? '`email` = ' . DB::getPdo()->quote($request->postData('eemail')) . ','
|
? '`email` = ' . DB::getPdo()->quote($request->postData('eemail')) . ','
|
||||||
: '') . '
|
: '') . '
|
||||||
`jabber` = ?,
|
|
||||||
`Size` = ?,
|
`Size` = ?,
|
||||||
`Gekommen`= ?,
|
`Gekommen`= ?,
|
||||||
`Aktiv`= ?,
|
`Aktiv`= ?,
|
||||||
`force_active`= ?,
|
`force_active`= ?,
|
||||||
`Tshirt` = ?,
|
`Tshirt` = ?
|
||||||
`Hometown` = ?
|
|
||||||
WHERE `UID` = ?
|
WHERE `UID` = ?
|
||||||
LIMIT 1';
|
LIMIT 1';
|
||||||
DB::update($sql, [
|
DB::update($sql, [
|
||||||
User_validate_Nick($request->postData('eNick')),
|
User_validate_Nick($request->postData('eNick')),
|
||||||
$request->postData('eName'),
|
$request->postData('eName'),
|
||||||
$request->postData('eVorname'),
|
$request->postData('eVorname'),
|
||||||
$request->postData('eTelefon'),
|
|
||||||
$request->postData('eHandy'),
|
$request->postData('eHandy'),
|
||||||
$request->postData('eAlter'),
|
|
||||||
$request->postData('eDECT'),
|
$request->postData('eDECT'),
|
||||||
$request->postData('ejabber'),
|
|
||||||
$request->postData('eSize'),
|
$request->postData('eSize'),
|
||||||
$request->postData('eGekommen'),
|
$request->postData('eGekommen'),
|
||||||
$request->postData('eAktiv'),
|
$request->postData('eAktiv'),
|
||||||
$force_active,
|
$force_active,
|
||||||
$request->postData('eTshirt'),
|
$request->postData('eTshirt'),
|
||||||
$request->postData('Hometown'),
|
|
||||||
$user_id,
|
$user_id,
|
||||||
]);
|
]);
|
||||||
engelsystem_log(
|
engelsystem_log(
|
||||||
|
@ -300,7 +289,7 @@ function admin_user()
|
||||||
&& $request->postData('new_pw') == $request->postData('new_pw2')
|
&& $request->postData('new_pw') == $request->postData('new_pw2')
|
||||||
) {
|
) {
|
||||||
set_password($user_id, $request->postData('new_pw'));
|
set_password($user_id, $request->postData('new_pw'));
|
||||||
$user_source = User($user_id);
|
$user_source = User::find($user_id);
|
||||||
engelsystem_log('Set new password for ' . User_Nick_render($user_source));
|
engelsystem_log('Set new password for ' . User_Nick_render($user_source));
|
||||||
$html .= success('Passwort neu gesetzt.', true);
|
$html .= success('Passwort neu gesetzt.', true);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Engelsystem\Database\DB;
|
use Engelsystem\Database\DB;
|
||||||
|
use Engelsystem\Models\User\User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
|
@ -264,7 +265,7 @@ function guest_register()
|
||||||
}
|
}
|
||||||
|
|
||||||
engelsystem_log(
|
engelsystem_log(
|
||||||
'User ' . User_Nick_render(User($user_id))
|
'User ' . User_Nick_render(User::find($user_id))
|
||||||
. ' signed up as: ' . join(', ', $user_angel_types_info)
|
. ' signed up as: ' . join(', ', $user_angel_types_info)
|
||||||
);
|
);
|
||||||
success(__('Angel registration successful!'));
|
success(__('Angel registration successful!'));
|
||||||
|
@ -430,10 +431,10 @@ function guest_login()
|
||||||
if ($request->has('submit')) {
|
if ($request->has('submit')) {
|
||||||
if ($request->has('nick') && strlen(User_validate_Nick($request->input('nick'))) > 0) {
|
if ($request->has('nick') && strlen(User_validate_Nick($request->input('nick'))) > 0) {
|
||||||
$nick = User_validate_Nick($request->input('nick'));
|
$nick = User_validate_Nick($request->input('nick'));
|
||||||
$login_user = DB::selectOne('SELECT * FROM `User` WHERE `Nick`=?', [$nick]);
|
$login_user = User::whereName($nick);
|
||||||
if (!empty($login_user)) {
|
if ($login_user) {
|
||||||
if ($request->has('password')) {
|
if ($request->has('password')) {
|
||||||
if (!verify_password($request->postData('password'), $login_user['Passwort'], $login_user['UID'])) {
|
if (!verify_password($request->postData('password'), $login_user->password, $login_user->id)) {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
error(__('Your password is incorrect. Please try it again.'));
|
error(__('Your password is incorrect. Please try it again.'));
|
||||||
}
|
}
|
||||||
|
@ -450,9 +451,9 @@ function guest_login()
|
||||||
error(__('Please enter a nickname.'));
|
error(__('Please enter a nickname.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($valid && !empty($login_user)) {
|
if ($valid && $login_user) {
|
||||||
$session->set('uid', $login_user['UID']);
|
$session->set('uid', $login_user->id);
|
||||||
$session->set('locale', $login_user['Sprache']);
|
$session->set('locale', $login_user->settings->language);
|
||||||
|
|
||||||
redirect(page_link_to('news'));
|
redirect(page_link_to('news'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Engelsystem\Database\DB;
|
use Engelsystem\Database\DB;
|
||||||
|
use Engelsystem\Models\User\User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
|
@ -34,13 +35,13 @@ function user_unread_messages()
|
||||||
*/
|
*/
|
||||||
function user_messages()
|
function user_messages()
|
||||||
{
|
{
|
||||||
global $user;
|
$user = auth()->user();
|
||||||
$request = request();
|
$request = request();
|
||||||
|
|
||||||
if (!$request->has('action')) {
|
if (!$request->has('action')) {
|
||||||
$users = DB::select(
|
$users = DB::select(
|
||||||
'SELECT `UID`, `Nick` FROM `User` WHERE NOT `UID`=? ORDER BY `Nick`',
|
'SELECT `UID`, `Nick` FROM `User` WHERE NOT `UID`=? ORDER BY `Nick`',
|
||||||
[$user['UID']]
|
[$user->id]
|
||||||
);
|
);
|
||||||
|
|
||||||
$to_select_data = [
|
$to_select_data = [
|
||||||
|
@ -61,8 +62,8 @@ function user_messages()
|
||||||
ORDER BY `isRead`,`Datum` DESC
|
ORDER BY `isRead`,`Datum` DESC
|
||||||
',
|
',
|
||||||
[
|
[
|
||||||
$user['UID'],
|
$user->id,
|
||||||
$user['UID'],
|
$user->id,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -78,8 +79,8 @@ function user_messages()
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($messages as $message) {
|
foreach ($messages as $message) {
|
||||||
$sender_user_source = User($message['SUID']);
|
$sender_user_source = User::find($message['SUID']);
|
||||||
$receiver_user_source = User($message['RUID']);
|
$receiver_user_source = User::find($message['RUID']);
|
||||||
|
|
||||||
$messages_table_entry = [
|
$messages_table_entry = [
|
||||||
'new' => $message['isRead'] == 'N' ? '<span class="glyphicon glyphicon-envelope"></span>' : '',
|
'new' => $message['isRead'] == 'N' ? '<span class="glyphicon glyphicon-envelope"></span>' : '',
|
||||||
|
@ -89,7 +90,7 @@ function user_messages()
|
||||||
'text' => str_replace("\n", '<br />', $message['Text'])
|
'text' => str_replace("\n", '<br />', $message['Text'])
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($message['RUID'] == $user['UID']) {
|
if ($message['RUID'] == $user->id) {
|
||||||
if ($message['isRead'] == 'N') {
|
if ($message['isRead'] == 'N') {
|
||||||
$messages_table_entry['actions'] = button(
|
$messages_table_entry['actions'] = button(
|
||||||
page_link_to('user_messages', ['action' => 'read', 'id' => $message['id']]),
|
page_link_to('user_messages', ['action' => 'read', 'id' => $message['id']]),
|
||||||
|
@ -134,7 +135,7 @@ function user_messages()
|
||||||
'SELECT `RUID` FROM `Messages` WHERE `id`=? LIMIT 1',
|
'SELECT `RUID` FROM `Messages` WHERE `id`=? LIMIT 1',
|
||||||
[$message_id]
|
[$message_id]
|
||||||
);
|
);
|
||||||
if (!empty($message) && $message['RUID'] == $user['UID']) {
|
if (!empty($message) && $message['RUID'] == $user->id) {
|
||||||
DB::update(
|
DB::update(
|
||||||
'UPDATE `Messages` SET `isRead`=\'Y\' WHERE `id`=? LIMIT 1',
|
'UPDATE `Messages` SET `isRead`=\'Y\' WHERE `id`=? LIMIT 1',
|
||||||
[$message_id]
|
[$message_id]
|
||||||
|
@ -156,7 +157,7 @@ function user_messages()
|
||||||
'SELECT `SUID` FROM `Messages` WHERE `id`=? LIMIT 1',
|
'SELECT `SUID` FROM `Messages` WHERE `id`=? LIMIT 1',
|
||||||
[$message_id]
|
[$message_id]
|
||||||
);
|
);
|
||||||
if (!empty($message) && $message['SUID'] == $user['UID']) {
|
if (!empty($message) && $message['SUID'] == $user->id) {
|
||||||
DB::delete('DELETE FROM `Messages` WHERE `id`=? LIMIT 1', [$message_id]);
|
DB::delete('DELETE FROM `Messages` WHERE `id`=? LIMIT 1', [$message_id]);
|
||||||
redirect(page_link_to('user_messages'));
|
redirect(page_link_to('user_messages'));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Engelsystem\Database\DB;
|
use Engelsystem\Database\DB;
|
||||||
|
use Engelsystem\Models\User\User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
|
@ -31,12 +32,12 @@ function user_myshifts()
|
||||||
$shift_entry_id = $user['UID'];
|
$shift_entry_id = $user['UID'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$shifts_user = DB::selectOne('SELECT * FROM `User` WHERE `UID`=? LIMIT 1', [$shift_entry_id]);
|
$shifts_user = User::find($shift_entry_id);
|
||||||
if ($request->has('reset')) {
|
if ($request->has('reset')) {
|
||||||
if ($request->input('reset') == 'ack') {
|
if ($request->input('reset') == 'ack') {
|
||||||
User_reset_api_key($user);
|
User_reset_api_key($user);
|
||||||
success(__('Key changed.'));
|
success(__('Key changed.'));
|
||||||
redirect(page_link_to('users', ['action' => 'view', 'user_id' => $shifts_user['UID']]));
|
redirect(page_link_to('users', ['action' => 'view', 'user_id' => $shifts_user->id]));
|
||||||
}
|
}
|
||||||
return page_with_title(__('Reset API key'), [
|
return page_with_title(__('Reset API key'), [
|
||||||
error(
|
error(
|
||||||
|
@ -68,7 +69,7 @@ function user_myshifts()
|
||||||
',
|
',
|
||||||
[
|
[
|
||||||
$shift_entry_id,
|
$shift_entry_id,
|
||||||
$shifts_user['UID'],
|
$shifts_user->id,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
if (!empty($shift)) {
|
if (!empty($shift)) {
|
||||||
|
@ -87,7 +88,7 @@ function user_myshifts()
|
||||||
}
|
}
|
||||||
|
|
||||||
$comment = strip_request_item_nl('comment');
|
$comment = strip_request_item_nl('comment');
|
||||||
$user_source = User($shift['UID']);
|
$user_source = User::find($shift['UID']);
|
||||||
|
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
ShiftEntry_update([
|
ShiftEntry_update([
|
||||||
|
@ -105,7 +106,7 @@ function user_myshifts()
|
||||||
. '. Freeloaded: ' . ($freeloaded ? 'YES Comment: ' . $freeload_comment : 'NO')
|
. '. Freeloaded: ' . ($freeloaded ? 'YES Comment: ' . $freeload_comment : 'NO')
|
||||||
);
|
);
|
||||||
success(__('Shift saved.'));
|
success(__('Shift saved.'));
|
||||||
redirect(page_link_to('users', ['action' => 'view', 'user_id' => $shifts_user['UID']]));
|
redirect(page_link_to('users', ['action' => 'view', 'user_id' => $shifts_user->id]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,6 +126,6 @@ function user_myshifts()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
redirect(page_link_to('users', ['action' => 'view', 'user_id' => $shifts_user['UID']]));
|
redirect(page_link_to('users', ['action' => 'view', 'user_id' => $shifts_user->id]));
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Engelsystem\Database\DB;
|
use Engelsystem\Database\DB;
|
||||||
|
use Engelsystem\Models\User\User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
|
@ -111,9 +112,7 @@ function display_news($news)
|
||||||
}
|
}
|
||||||
$html .= '<span class="glyphicon glyphicon-time"></span> ' . date('Y-m-d H:i', $news['Datum']) . ' ';
|
$html .= '<span class="glyphicon glyphicon-time"></span> ' . date('Y-m-d H:i', $news['Datum']) . ' ';
|
||||||
|
|
||||||
$user_source = User($news['UID']);
|
$html .= User_Nick_render(User::find($news['UID']));
|
||||||
|
|
||||||
$html .= User_Nick_render($user_source);
|
|
||||||
if ($page != 'news_comments') {
|
if ($page != 'news_comments') {
|
||||||
$html .= ' <a href="' . page_link_to('news_comments', ['nid' => $news['ID']]) . '">'
|
$html .= ' <a href="' . page_link_to('news_comments', ['nid' => $news['ID']]) . '">'
|
||||||
. '<span class="glyphicon glyphicon-comment"></span> '
|
. '<span class="glyphicon glyphicon-comment"></span> '
|
||||||
|
@ -171,7 +170,7 @@ function user_news_comments()
|
||||||
[$nid]
|
[$nid]
|
||||||
);
|
);
|
||||||
foreach ($comments as $comment) {
|
foreach ($comments as $comment) {
|
||||||
$user_source = User($comment['UID']);
|
$user_source = User::find($comment['UID']);
|
||||||
|
|
||||||
$html .= '<div class="panel panel-default">';
|
$html .= '<div class="panel panel-default">';
|
||||||
$html .= '<div class="panel-body">' . nl2br(htmlspecialchars($comment['Text'])) . '</div>';
|
$html .= '<div class="panel-body">' . nl2br(htmlspecialchars($comment['Text'])) . '</div>';
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Engelsystem\Database\DB;
|
use Engelsystem\Database\DB;
|
||||||
|
use Engelsystem\Models\User\User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
|
@ -29,7 +30,7 @@ function user_questions()
|
||||||
[$user->id]
|
[$user->id]
|
||||||
);
|
);
|
||||||
foreach ($answered_questions as &$question) {
|
foreach ($answered_questions as &$question) {
|
||||||
$answer_user_source = User($question['AID']);
|
$answer_user_source = User::find($question['AID']);
|
||||||
$question['answer_user'] = User_Nick_render($answer_user_source);
|
$question['answer_user'] = User_Nick_render($answer_user_source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -217,7 +217,7 @@ function view_user_shifts()
|
||||||
}
|
}
|
||||||
|
|
||||||
$ownTypes = [];
|
$ownTypes = [];
|
||||||
foreach (UserAngelTypes_by_User($user) as $type) {
|
foreach (UserAngelTypes_by_User($user['UID']) as $type) {
|
||||||
$ownTypes[] = (int)$type['angeltype_id'];
|
$ownTypes[] = (int)$type['angeltype_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,11 +8,11 @@
|
||||||
*/
|
*/
|
||||||
function engelsystem_log($message)
|
function engelsystem_log($message)
|
||||||
{
|
{
|
||||||
global $user;
|
|
||||||
$nick = "Guest";
|
$nick = "Guest";
|
||||||
$logger = app('logger');
|
$logger = app('logger');
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
if (isset($user)) {
|
if ($user) {
|
||||||
$nick = User_Nick_render($user);
|
$nick = User_Nick_render($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,10 +75,10 @@ function Shift_editor_info_render($shift)
|
||||||
*/
|
*/
|
||||||
function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null)
|
function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null)
|
||||||
{
|
{
|
||||||
global $user;
|
$user = auth()->user();
|
||||||
|
|
||||||
if (empty($user_angeltype)) {
|
if (empty($user_angeltype)) {
|
||||||
$user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
|
$user_angeltype = UserAngelType_by_User_and_AngelType($user->id, $angeltype);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($angeltype['shift_signup_state']->isSignupAllowed()) {
|
if ($angeltype['shift_signup_state']->isSignupAllowed()) {
|
||||||
|
@ -103,7 +103,8 @@ function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null)
|
||||||
*/
|
*/
|
||||||
function Shift_view($shift, $shifttype, $room, $angeltypes_source, ShiftSignupState $shift_signup_state)
|
function Shift_view($shift, $shifttype, $room, $angeltypes_source, ShiftSignupState $shift_signup_state)
|
||||||
{
|
{
|
||||||
global $user, $privileges;
|
global $privileges;
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
$shift_admin = in_array('admin_shifts', $privileges);
|
$shift_admin = in_array('admin_shifts', $privileges);
|
||||||
$user_shift_admin = in_array('user_shifts_admin', $privileges);
|
$user_shift_admin = in_array('user_shifts_admin', $privileges);
|
||||||
|
@ -141,7 +142,7 @@ function Shift_view($shift, $shifttype, $room, $angeltypes_source, ShiftSignupSt
|
||||||
$admin_rooms ? button(room_link($room), glyph('map-marker') . $room['Name']) : '',
|
$admin_rooms ? button(room_link($room), glyph('map-marker') . $room['Name']) : '',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
$buttons[] = button(user_link($user['UID']), '<span class="icon-icon_angel"></span> ' . __('My shifts'));
|
$buttons[] = button(user_link($user->id), '<span class="icon-icon_angel"></span> ' . __('My shifts'));
|
||||||
$content[] = buttons($buttons);
|
$content[] = buttons($buttons);
|
||||||
|
|
||||||
$content[] = Shift_view_header($shift, $room);
|
$content[] = Shift_view_header($shift, $room);
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Engelsystem\Models\User\User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $user_angeltype
|
* @param array $user_angeltype
|
||||||
* @param array $user
|
* @param User $user
|
||||||
* @param array $angeltype
|
* @param array $angeltype
|
||||||
* @param bool $supporter
|
* @param bool $supporter
|
||||||
* @return string
|
* @return string
|
||||||
|
@ -89,7 +91,7 @@ function UserAngelTypes_confirm_all_view($angeltype)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $user_angeltype
|
* @param array $user_angeltype
|
||||||
* @param array $user
|
* @param User $user
|
||||||
* @param array $angeltype
|
* @param array $angeltype
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
@ -118,7 +120,7 @@ function UserAngelType_confirm_view($user_angeltype, $user, $angeltype)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $user_angeltype
|
* @param array $user_angeltype
|
||||||
* @param array $user
|
* @param User $user
|
||||||
* @param array $angeltype
|
* @param array $angeltype
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Engelsystem\Models\User\User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete work log entry.
|
* Delete work log entry.
|
||||||
*
|
*
|
||||||
* @param array $user_source
|
* @param User $user_source
|
||||||
* @param array $userWorkLog
|
* @param array $userWorkLog
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
@ -15,7 +17,7 @@ function UserWorkLog_delete_view($user_source, $userWorkLog)
|
||||||
User_Nick_render($user_source)
|
User_Nick_render($user_source)
|
||||||
), true),
|
), true),
|
||||||
buttons([
|
buttons([
|
||||||
button(user_link($user_source['UID']), glyph('remove') . __('cancel')),
|
button(user_link($user_source->id), glyph('remove') . __('cancel')),
|
||||||
button(user_worklog_delete_link($userWorkLog, [
|
button(user_worklog_delete_link($userWorkLog, [
|
||||||
'confirmed' => 1
|
'confirmed' => 1
|
||||||
]), glyph('ok') . __('delete'), 'btn-danger')
|
]), glyph('ok') . __('delete'), 'btn-danger')
|
||||||
|
|
|
@ -145,7 +145,7 @@ function User_registration_success_view($event_welcome_message)
|
||||||
/**
|
/**
|
||||||
* Gui for deleting user with password field.
|
* Gui for deleting user with password field.
|
||||||
*
|
*
|
||||||
* @param array $user
|
* @param User $user
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function User_delete_view($user)
|
function User_delete_view($user)
|
||||||
|
@ -153,7 +153,7 @@ function User_delete_view($user)
|
||||||
return page_with_title(sprintf(__('Delete %s'), User_Nick_render($user)), [
|
return page_with_title(sprintf(__('Delete %s'), User_Nick_render($user)), [
|
||||||
msg(),
|
msg(),
|
||||||
buttons([
|
buttons([
|
||||||
button(user_edit_link($user['UID']), glyph('chevron-left') . __('back'))
|
button(user_edit_link($user->id), glyph('chevron-left') . __('back'))
|
||||||
]),
|
]),
|
||||||
error(
|
error(
|
||||||
__('Do you really want to delete the user including all his shifts and every other piece of his data?'),
|
__('Do you really want to delete the user including all his shifts and every other piece of his data?'),
|
||||||
|
@ -292,7 +292,7 @@ function User_shift_state_render($user)
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$upcoming_shifts = ShiftEntries_upcoming_for_user($user);
|
$upcoming_shifts = ShiftEntries_upcoming_for_user($user['UID']);
|
||||||
|
|
||||||
if (empty($upcoming_shifts)) {
|
if (empty($upcoming_shifts)) {
|
||||||
return '<span class="text-success">' . __('Free') . '</span>';
|
return '<span class="text-success">' . __('Free') . '</span>';
|
||||||
|
@ -823,15 +823,25 @@ function User_groups_render($user_groups)
|
||||||
/**
|
/**
|
||||||
* Render a user nickname.
|
* Render a user nickname.
|
||||||
*
|
*
|
||||||
* @param array $user_source
|
* @param array|User $user
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function User_Nick_render($user_source)
|
function User_Nick_render($user)
|
||||||
{
|
{
|
||||||
|
if ($user instanceof User) {
|
||||||
|
$id = $user->id;
|
||||||
|
$name = $user->name;
|
||||||
|
$arrived = $user->state->arrived;
|
||||||
|
} else {
|
||||||
|
$id = $user['UID'];
|
||||||
|
$name = $user['Nick'];
|
||||||
|
$arrived = $user['Gekommen'];
|
||||||
|
}
|
||||||
|
|
||||||
return render_profile_link(
|
return render_profile_link(
|
||||||
'<span class="icon-icon_angel"></span> ' . htmlspecialchars($user_source['Nick']) . '</a>',
|
'<span class="icon-icon_angel"></span> ' . htmlspecialchars($name) . '</a>',
|
||||||
$user_source['UID'],
|
$id,
|
||||||
($user_source['Gekommen'] ? '' : 'text-muted')
|
($arrived ? '' : 'text-muted')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -861,9 +871,7 @@ function render_profile_link($text, $user_id = null, $class = '')
|
||||||
*/
|
*/
|
||||||
function render_user_departure_date_hint()
|
function render_user_departure_date_hint()
|
||||||
{
|
{
|
||||||
global $user;
|
if (!auth()->user()->personalData->planned_departure_date) {
|
||||||
|
|
||||||
if (!isset($user['planned_departure_date']) || empty($user['planned_departure_date'])) {
|
|
||||||
$text = __('Please enter your planned date of departure on your settings page to give us a feeling for teardown capacities.');
|
$text = __('Please enter your planned date of departure on your settings page to give us a feeling for teardown capacities.');
|
||||||
return render_profile_link($text, null, 'alert-link');
|
return render_profile_link($text, null, 'alert-link');
|
||||||
}
|
}
|
||||||
|
@ -895,9 +903,9 @@ function render_user_freeloader_hint()
|
||||||
*/
|
*/
|
||||||
function render_user_arrived_hint()
|
function render_user_arrived_hint()
|
||||||
{
|
{
|
||||||
global $user;
|
$user = auth()->user();
|
||||||
|
|
||||||
if ($user['Gekommen'] == 0) {
|
if (!$user->state->arrived) {
|
||||||
/** @var Carbon $buildup */
|
/** @var Carbon $buildup */
|
||||||
$buildup = config('buildup_start');
|
$buildup = config('buildup_start');
|
||||||
if (!empty($buildup) && $buildup->lessThan(new Carbon())) {
|
if (!empty($buildup) && $buildup->lessThan(new Carbon())) {
|
||||||
|
@ -913,9 +921,9 @@ function render_user_arrived_hint()
|
||||||
*/
|
*/
|
||||||
function render_user_tshirt_hint()
|
function render_user_tshirt_hint()
|
||||||
{
|
{
|
||||||
global $user;
|
$user = auth()->user();
|
||||||
|
|
||||||
if (config('enable_tshirt_size') && $user['Size'] == '') {
|
if (config('enable_tshirt_size') && !$user->personalData->shirt_size) {
|
||||||
$text = __('You need to specify a tshirt size in your settings!');
|
$text = __('You need to specify a tshirt size in your settings!');
|
||||||
return render_profile_link($text, null, 'alert-link');
|
return render_profile_link($text, null, 'alert-link');
|
||||||
}
|
}
|
||||||
|
@ -928,9 +936,9 @@ function render_user_tshirt_hint()
|
||||||
*/
|
*/
|
||||||
function render_user_dect_hint()
|
function render_user_dect_hint()
|
||||||
{
|
{
|
||||||
global $user;
|
$user = auth()->user();
|
||||||
|
|
||||||
if ($user['Gekommen'] == 1 && $user['DECT'] == '') {
|
if ($user->state->arrived && !$user->contact->dect) {
|
||||||
$text = __('You need to specify a DECT phone number in your settings! If you don\'t have a DECT phone, just enter \'-\'.');
|
$text = __('You need to specify a DECT phone number in your settings! If you don\'t have a DECT phone, just enter \'-\'.');
|
||||||
return render_profile_link($text, null, 'alert-link');
|
return render_profile_link($text, null, 'alert-link');
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,9 @@ use Engelsystem\Models\BaseModel;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property integer $user_id
|
* @property integer $user_id
|
||||||
|
*
|
||||||
|
* @property-read \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\User $user
|
||||||
*
|
*
|
||||||
* @method static \Illuminate\Database\Query\Builder|static whereUserId($value)
|
* @method static \Illuminate\Database\Query\Builder|static whereUserId($value)
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue