summaryrefslogtreecommitdiff
path: root/includes/model
diff options
context:
space:
mode:
authormsquare <msquare@notrademark.de>2017-12-26 10:29:16 +0100
committerGitHub <noreply@github.com>2017-12-26 10:29:16 +0100
commitde61c88d6de67d12d5de5b6dd0ab6b8c82e5a290 (patch)
treeaac6a43cb88e3d803da5809ab37885b41bc811c6 /includes/model
parent879918864a9c6da0fe9be1aca6c443ec8df0afc3 (diff)
parentf8d0a7c5b00a58c646871e355b5876dcc5890be5 (diff)
Merge pull request #388 from MyIgel/master
Formatting, Docstrings, and fixup
Diffstat (limited to 'includes/model')
-rw-r--r--includes/model/AngelType_model.php13
-rw-r--r--includes/model/NeededAngelTypes_model.php12
-rw-r--r--includes/model/Room_model.php66
-rw-r--r--includes/model/ShiftEntry_model.php15
-rw-r--r--includes/model/ShiftSignupState.php8
-rw-r--r--includes/model/ShiftTypes_model.php2
-rw-r--r--includes/model/ShiftsFilter.php1
-rw-r--r--includes/model/Shifts_model.php75
-rw-r--r--includes/model/Stats.php44
-rw-r--r--includes/model/UserAngelTypes_model.php8
-rw-r--r--includes/model/UserGroups_model.php2
-rw-r--r--includes/model/User_model.php32
12 files changed, 152 insertions, 126 deletions
diff --git a/includes/model/AngelType_model.php b/includes/model/AngelType_model.php
index f6e2a9cf..3641f125 100644
--- a/includes/model/AngelType_model.php
+++ b/includes/model/AngelType_model.php
@@ -25,13 +25,14 @@ function AngelType_new()
/**
* Checks if the angeltype has any contact information.
- *
- * @param Angeltype $angeltype
+ *
+ * @param array $angeltype Angeltype
* @return bool
*/
-function AngelType_has_contact_info($angeltype) {
- return !empty($angeltype['contact_name'])
- || !empty($angeltype['contact_dect'])
+function AngelType_has_contact_info($angeltype)
+{
+ return !empty($angeltype['contact_name'])
+ || !empty($angeltype['contact_dect'])
|| !empty($angeltype['contact_email']);
}
@@ -139,6 +140,7 @@ function AngelType_create($angeltype)
. $angeltype['contact_email'] . ', '
. $angeltype['show_on_dashboard']
);
+
return $angeltype;
}
@@ -172,6 +174,7 @@ function AngelType_validate_name($name, $angeltype)
FROM `AngelTypes`
WHERE `name`=?
LIMIT 1', [$name])) == 0);
+
return new ValidationResult($valid, $name);
}
diff --git a/includes/model/NeededAngelTypes_model.php b/includes/model/NeededAngelTypes_model.php
index 53313fe8..53f783c1 100644
--- a/includes/model/NeededAngelTypes_model.php
+++ b/includes/model/NeededAngelTypes_model.php
@@ -56,11 +56,12 @@ function NeededAngelTypes_delete_by_room($room_id)
/**
* Returns all needed angeltypes by room.
- *
+ *
* @param int $room_id
* @return array
*/
-function NeededAngelTypes_by_room($room_id) {
+function NeededAngelTypes_by_room($room_id)
+{
return DB::select(
'SELECT `angel_type_id`, `count` FROM `NeededAngelTypes` WHERE `room_id`=?',
[$room_id]
@@ -76,7 +77,12 @@ function NeededAngelTypes_by_room($room_id) {
function NeededAngelTypes_by_shift($shiftId)
{
$needed_angeltypes_source = DB::select('
- SELECT `NeededAngelTypes`.*, `AngelTypes`.`id`, `AngelTypes`.`name`, `AngelTypes`.`restricted`, `AngelTypes`.`no_self_signup`
+ SELECT
+ `NeededAngelTypes`.*,
+ `AngelTypes`.`id`,
+ `AngelTypes`.`name`,
+ `AngelTypes`.`restricted`,
+ `AngelTypes`.`no_self_signup`
FROM `NeededAngelTypes`
JOIN `AngelTypes` ON `AngelTypes`.`id` = `NeededAngelTypes`.`angel_type_id`
WHERE `shift_id` = ?
diff --git a/includes/model/Room_model.php b/includes/model/Room_model.php
index b23e35d1..f153cd52 100644
--- a/includes/model/Room_model.php
+++ b/includes/model/Room_model.php
@@ -1,14 +1,13 @@
<?php
+
use Engelsystem\Database\DB;
use Engelsystem\ValidationResult;
/**
* Validate a name for a room.
*
- * @param string $name
- * The new name
- * @param int $room_id
- * The room id
+ * @param string $name The new name
+ * @param int $room_id The room id
* @return ValidationResult
*/
function Room_validate_name($name, $room_id)
@@ -17,10 +16,11 @@ function Room_validate_name($name, $room_id)
if (empty($name)) {
$valid = false;
}
+
if (count(DB::select('SELECT RID FROM `Room` WHERE `Name`=? AND NOT `RID`=?', [
- $name,
- $room_id
- ])) > 0) {
+ $name,
+ $room_id
+ ])) > 0) {
$valid = false;
}
return new ValidationResult($valid, $name);
@@ -50,7 +50,7 @@ function Room_ids()
/**
* Delete a room
*
- * @param int $room_id
+ * @param int $room_id
*/
function Room_delete($room_id)
{
@@ -64,7 +64,7 @@ function Room_delete($room_id)
/**
* Delete a room by its name
*
- * @param string $name
+ * @param string $name
*/
function Room_delete_by_name($name)
{
@@ -77,14 +77,10 @@ function Room_delete_by_name($name)
/**
* Create a new room
*
- * @param string $name
- * Name of the room
- * @param boolean $from_frab
- * Is this a frab imported room?
- * @param string $map_url
- * URL to a map tha can be displayed in an iframe
- * @param
- * description markdown description
+ * @param string $name Name of the room
+ * @param boolean $from_frab Is this a frab imported room?
+ * @param string $map_url URL to a map tha can be displayed in an iframe
+ * @param string description Markdown description
* @return false|int
*/
function Room_create($name, $from_frab, $map_url, $description)
@@ -94,33 +90,31 @@ function Room_create($name, $from_frab, $map_url, $description)
VALUES (?, ?, ?, ?)
', [
$name,
- (int) $from_frab,
+ (int)$from_frab,
$map_url,
$description
]);
$result = DB::getPdo()->lastInsertId();
-
+
engelsystem_log(
'Room created: ' . $name
. ', frab import: ' . ($from_frab ? 'Yes' : '')
. ', map_url: ' . $map_url
. ', description: ' . $description
);
-
+
return $result;
}
/**
* update a room
*
- * @param string $name
- * Name of the room
- * @param boolean $from_frab
- * Is this a frab imported room?
- * @param string $map_url
- * URL to a map tha can be displayed in an iframe
- * @param
- * description markdown description
+ * @param int $room_id The rooms id
+ * @param string $name Name of the room
+ * @param boolean $from_frab Is this a frab imported room?
+ * @param string $map_url URL to a map tha can be displayed in an iframe
+ * @param string $description Markdown description
+ * @return int
*/
function Room_update($room_id, $name, $from_frab, $map_url, $description)
{
@@ -134,28 +128,26 @@ function Room_update($room_id, $name, $from_frab, $map_url, $description)
WHERE `RID`=?
LIMIT 1', [
$name,
- (int) $from_frab,
+ (int)$from_frab,
$map_url,
$description,
$room_id
]);
-
+
engelsystem_log(
- 'Room updated: ' . $name .
- ', frab import: ' . ($from_frab ? 'Yes' : '') .
- ', map_url: ' . $map_url .
+ 'Room updated: ' . $name .
+ ', frab import: ' . ($from_frab ? 'Yes' : '') .
+ ', map_url: ' . $map_url .
', description: ' . $description
);
-
+
return $result;
}
/**
* Returns room by id.
*
- * @param int $room_id
- * RID
- * @param bool $onlyVisible
+ * @param int $room_id RID
* @return array|false
*/
function Room($room_id)
diff --git a/includes/model/ShiftEntry_model.php b/includes/model/ShiftEntry_model.php
index 38db5959..bb9db49d 100644
--- a/includes/model/ShiftEntry_model.php
+++ b/includes/model/ShiftEntry_model.php
@@ -26,7 +26,7 @@ function ShiftEntry_new()
*
* @return int
*/
-function ShiftEntries_freeleaded_count()
+function ShiftEntries_freeloaded_count()
{
$result = DB::selectOne('SELECT COUNT(*) FROM `ShiftEntry` WHERE `freeloaded` = 1');
@@ -38,7 +38,7 @@ function ShiftEntries_freeleaded_count()
}
/**
- * List users subsribed to a given shift.
+ * List users subscribed to a given shift.
*
* @param int $shift_id
* @return array
@@ -102,7 +102,8 @@ function ShiftEntry_create($shift_entry)
. ' signed up for shift ' . $shift['name']
. ' from ' . date('Y-m-d H:i', $shift['start'])
. ' to ' . date('Y-m-d H:i', $shift['end'])
- );
+ );
+
return $result;
}
@@ -149,20 +150,20 @@ function ShiftEntry_delete($shiftEntry)
{
mail_shift_removed(User($shiftEntry['UID']), Shift($shiftEntry['SID']));
DB::delete('DELETE FROM `ShiftEntry` WHERE `id` = ?', [$shiftEntry['id']]);
-
+
$signout_user = User($shiftEntry['UID']);
$shift = Shift($shiftEntry['SID']);
$shifttype = ShiftType($shift['shifttype_id']);
$room = Room($shift['RID']);
$angeltype = AngelType($shiftEntry['TID']);
-
+
engelsystem_log(
- 'Shift signout: '. User_Nick_render($signout_user) . ' from shift ' . $shifttype['name']
+ 'Shift signout: ' . User_Nick_render($signout_user) . ' from shift ' . $shifttype['name']
. ' at ' . $room['Name']
. ' from ' . date('Y-m-d H:i', $shift['start'])
. ' to ' . date('Y-m-d H:i', $shift['end'])
. ' as ' . $angeltype['name']
- );
+ );
}
/**
diff --git a/includes/model/ShiftSignupState.php b/includes/model/ShiftSignupState.php
index 1ab7c362..8d588de3 100644
--- a/includes/model/ShiftSignupState.php
+++ b/includes/model/ShiftSignupState.php
@@ -42,12 +42,12 @@ class ShiftSignupState
* User is already signed up
*/
const SIGNED_UP = 'SIGNED_UP';
-
+
/**
* User has to be arrived
*/
const NOT_ARRIVED = 'NOT_ARRIVED';
-
+
/** @var string */
private $state;
@@ -69,8 +69,7 @@ class ShiftSignupState
/**
* Combine this state with another state from the same shift.
*
- * @param ShiftSignupState $shiftSignupState
- * The other state to combine
+ * @param ShiftSignupState $shiftSignupState The other state to combine
*/
public function combineWith(ShiftSignupState $shiftSignupState)
{
@@ -122,6 +121,7 @@ class ShiftSignupState
case ShiftSignupState::ADMIN:
return true;
}
+
return false;
}
diff --git a/includes/model/ShiftTypes_model.php b/includes/model/ShiftTypes_model.php
index 227df367..3d2dc9fe 100644
--- a/includes/model/ShiftTypes_model.php
+++ b/includes/model/ShiftTypes_model.php
@@ -76,7 +76,7 @@ function ShiftType($shifttype_id)
/**
* Get all shift types.
*
- * @return array
+ * @return array[]
*/
function ShiftTypes()
{
diff --git a/includes/model/ShiftsFilter.php b/includes/model/ShiftsFilter.php
index 3b691b55..5ad7a9b3 100644
--- a/includes/model/ShiftsFilter.php
+++ b/includes/model/ShiftsFilter.php
@@ -50,7 +50,6 @@ class ShiftsFilter
*/
public function __construct($user_shifts_admin, $rooms, $types)
{
- $this->user_shifts_admin = $user_shifts_admin;
$this->rooms = $rooms;
$this->types = $types;
diff --git a/includes/model/Shifts_model.php b/includes/model/Shifts_model.php
index fd229be6..62335882 100644
--- a/includes/model/Shifts_model.php
+++ b/includes/model/Shifts_model.php
@@ -8,7 +8,8 @@ use Engelsystem\ShiftSignupState;
* @param array $angeltype
* @return array
*/
-function Shifts_by_angeltype($angeltype) {
+function Shifts_by_angeltype($angeltype)
+{
return DB::select('
SELECT DISTINCT `Shifts`.* FROM `Shifts`
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id` = `Shifts`.`SID`
@@ -27,7 +28,11 @@ function Shifts_by_angeltype($angeltype) {
}
/**
- * Returns every shift with needed angels in the given time range.
+ * Returns every shift with needed angels in the given time range.
+ *
+ * @param int $start timestamp
+ * @param int $end timestamp
+ * @return array
*/
function Shifts_free($start, $end)
{
@@ -48,14 +53,14 @@ function Shifts_free($start, $end)
AND (SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`room_id`=`Shifts`.`RID`)
> (SELECT COUNT(*) FROM `ShiftEntry` WHERE `ShiftEntry`.`SID`=`Shifts`.`SID` AND `freeloaded`=0)
AND NOT `Shifts`.`PSID` IS NULL
- ) as `tmp`
+ ) AS `tmp`
ORDER BY `tmp`.`start`
", [
- $start,
- $end,
- $start,
- $end
- ]);
+ $start,
+ $end,
+ $start,
+ $end
+ ]);
$free_shifts = [];
foreach ($shifts as $shift) {
$free_shifts[] = Shift($shift['SID']);
@@ -65,14 +70,17 @@ function Shifts_free($start, $end)
/**
* Returns all shifts with a PSID (from frab import)
+ *
+ * @return array[]
*/
-function Shifts_from_frab() {
+function Shifts_from_frab()
+{
return DB::select('SELECT * FROM `Shifts` WHERE `PSID` IS NOT NULL ORDER BY `start`');
}
/**
* @param array $room
- * @return array
+ * @return array[]
*/
function Shifts_by_room($room)
{
@@ -220,7 +228,7 @@ function NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype)
/**
* @param ShiftsFilter $shiftsFilter
- * @return array
+ * @return array[]
*/
function ShiftEntries_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
{
@@ -404,33 +412,33 @@ function Shift_signup_allowed_admin($needed_angeltype, $shift_entries)
/**
* Check if an angel can signout from a shift.
- *
- * @param $shift The shift
- * @param $angeltype The angeltype
- * @param $signout_user The user that was signed up for the shift
- *
+ *
+ * @param array $shift The shift
+ * @param array $angeltype The angeltype
+ * @param array $signout_user The user that was signed up for the shift
* @return bool
*/
-function Shift_signout_allowed($shift, $angeltype, $signout_user) {
+function Shift_signout_allowed($shift, $angeltype, $signout_user)
+{
global $user, $privileges;
-
+
// user shifts admin can sign out any user at any time
if (in_array('user_shifts_admin', $privileges)) {
return true;
}
-
+
// angeltype supporter can sign out any user at any time from their supported angeltype
if (
in_array('shiftentry_edit_angeltype_supporter', $privileges)
&& User_is_AngelType_supporter($user, $angeltype)
- ) {
+ ) {
return true;
}
-
- if($signout_user['UID'] == $user['UID'] && $shift['start'] > time() + config('last_unsubscribe') * 3600) {
+
+ if ($signout_user['UID'] == $user['UID'] && $shift['start'] > time() + config('last_unsubscribe') * 3600) {
return true;
}
-
+
return false;
}
@@ -496,9 +504,8 @@ function Shift_delete_by_psid($shift_psid)
*/
function Shift_delete($shift_id)
{
- mail_shift_delete(Shift($shift_id));
-
DB::delete('DELETE FROM `Shifts` WHERE `SID`=?', [$shift_id]);
+ mail_shift_delete(Shift($shift_id));
}
/**
@@ -606,15 +613,23 @@ function Shift_create($shift)
*
* @param array $user
* @param bool $include_freeload_comments
- * @return array
+ * @return array[]
*/
function Shifts_by_user($user, $include_freeload_comments = false)
{
return DB::select('
- SELECT `ShiftTypes`.`id` AS `shifttype_id`, `ShiftTypes`.`name`,
- `ShiftEntry`.`id`, `ShiftEntry`.`SID`, `ShiftEntry`.`TID`, `ShiftEntry`.`UID`, `ShiftEntry`.`freeloaded`, `ShiftEntry`.`Comment`,
- ' . ($include_freeload_comments ? '`ShiftEntry`.`freeload_comment`, ' : '') . '
- `Shifts`.*, `Room`.*
+ SELECT
+ `ShiftTypes`.`id` AS `shifttype_id`,
+ `ShiftTypes`.`name`,
+ `ShiftEntry`.`id`,
+ `ShiftEntry`.`SID`,
+ `ShiftEntry`.`TID`,
+ `ShiftEntry`.`UID`,
+ `ShiftEntry`.`freeloaded`,
+ `ShiftEntry`.`Comment`,
+ ' . ($include_freeload_comments ? '`ShiftEntry`.`freeload_comment`, ' : '') . '
+ `Shifts`.*,
+ `Room`.*
FROM `ShiftEntry`
JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID`)
JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`)
diff --git a/includes/model/Stats.php b/includes/model/Stats.php
index 0c581fa9..4ff376c6 100644
--- a/includes/model/Stats.php
+++ b/includes/model/Stats.php
@@ -1,36 +1,43 @@
<?php
+
use Engelsystem\Database\Db;
/**
* Returns the number of angels currently working.
+ *
+ * @return int|string
*/
function stats_currently_working()
{
$result = Db::selectOne("
SELECT SUM(
(SELECT COUNT(*) FROM `ShiftEntry` WHERE `ShiftEntry`.`SID`=`Shifts`.`SID` AND `freeloaded`=0)
- ) as `count`
+ ) AS `count`
FROM `Shifts`
WHERE (`end` >= ? AND `start` <= ?)", [
time(),
time()
]);
+
if (empty($result['count'])) {
return '-';
}
+
return $result['count'];
}
/**
* Return the number of hours still to work.
+ *
+ * @return int|string
*/
function stats_hours_to_work()
{
$result = Db::selectOne("
- SELECT ROUND(SUM(`count`)) as `count` FROM (
+ SELECT ROUND(SUM(`count`)) AS `count` FROM (
SELECT
(SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`)
- * (`Shifts`.`end` - `Shifts`.`start`)/3600 as `count`
+ * (`Shifts`.`end` - `Shifts`.`start`)/3600 AS `count`
FROM `Shifts`
WHERE `end` >= ?
AND `Shifts`.`PSID` IS NULL
@@ -39,11 +46,11 @@ function stats_hours_to_work()
SELECT
(SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`room_id`=`Shifts`.`RID`)
- * (`Shifts`.`end` - `Shifts`.`start`)/3600 as `count`
+ * (`Shifts`.`end` - `Shifts`.`start`)/3600 AS `count`
FROM `Shifts`
WHERE `end` >= ?
AND NOT `Shifts`.`PSID` IS NULL
- ) as `tmp`
+ ) AS `tmp`
", [
time(),
time()
@@ -56,17 +63,19 @@ function stats_hours_to_work()
/**
* Returns the number of needed angels in the next 3 hours
+ *
+ * @return int|string
*/
function stats_angels_needed_three_hours()
{
$now = time();
$in3hours = $now + 3 * 60 * 60;
$result = Db::selectOne("
- SELECT SUM(`count`) as `count` FROM (
+ SELECT SUM(`count`) AS `count` FROM (
SELECT
(SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`)
- (SELECT COUNT(*) FROM `ShiftEntry` WHERE `ShiftEntry`.`SID`=`Shifts`.`SID` AND `freeloaded`=0)
- as `count`
+ AS `count`
FROM `Shifts`
WHERE `end` > ? AND `start` < ?
AND `Shifts`.`PSID` IS NULL
@@ -76,11 +85,11 @@ function stats_angels_needed_three_hours()
SELECT
(SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`room_id`=`Shifts`.`RID`)
- (SELECT COUNT(*) FROM `ShiftEntry` WHERE `ShiftEntry`.`SID`=`Shifts`.`SID` AND `freeloaded`=0)
- as `count`
+ AS `count`
FROM `Shifts`
WHERE `end` > ? AND `start` < ?
AND NOT `Shifts`.`PSID` IS NULL
- ) as `tmp`", [
+ ) AS `tmp`", [
$now,
$in3hours,
$now,
@@ -94,17 +103,22 @@ function stats_angels_needed_three_hours()
/**
* Returns the number of needed angels for nightshifts (between 2 and 8)
+ *
+ * @return int|string
*/
function stats_angels_needed_for_nightshifts()
{
- $night_start = parse_date('Y-m-d H:i', date('Y-m-d', time() + 12 * 60 * 60) . ' 02:00');
+ $night_start = parse_date(
+ 'Y-m-d H:i',
+ date('Y-m-d', time() + 12 * 60 * 60) . ' 02:00'
+ );
$night_end = $night_start + 6 * 60 * 60;
$result = Db::selectOne("
- SELECT SUM(`count`) as `count` FROM (
+ SELECT SUM(`count`) AS `count` FROM (
SELECT
(SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`)
- (SELECT COUNT(*) FROM `ShiftEntry` WHERE `ShiftEntry`.`SID`=`Shifts`.`SID` AND `freeloaded`=0)
- as `count`
+ AS `count`
FROM `Shifts`
WHERE `end` > ? AND `start` < ?
AND `Shifts`.`PSID` IS NULL
@@ -114,11 +128,11 @@ function stats_angels_needed_for_nightshifts()
SELECT
(SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`room_id`=`Shifts`.`RID`)
- (SELECT COUNT(*) FROM `ShiftEntry` WHERE `ShiftEntry`.`SID`=`Shifts`.`SID` AND `freeloaded`=0)
- as `count`
+ AS `count`
FROM `Shifts`
WHERE `end` > ? AND `start` < ?
AND NOT `Shifts`.`PSID` IS NULL
- ) as `tmp`", [
+ ) AS `tmp`", [
$night_start,
$night_end,
$night_start,
@@ -129,5 +143,3 @@ function stats_angels_needed_for_nightshifts()
}
return $result['count'];
}
-
-?> \ No newline at end of file
diff --git a/includes/model/UserAngelTypes_model.php b/includes/model/UserAngelTypes_model.php
index 42742f54..7b22e347 100644
--- a/includes/model/UserAngelTypes_model.php
+++ b/includes/model/UserAngelTypes_model.php
@@ -27,7 +27,7 @@ function UserAngelType_exists($user, $angeltype)
* List users angeltypes.
*
* @param array $user
- * @return array
+ * @return array[]
*/
function User_angeltypes($user)
{
@@ -43,7 +43,7 @@ function User_angeltypes($user)
* Gets unconfirmed user angeltypes for angeltypes of which the given user is a supporter.
*
* @param array $user
- * @return array
+ * @return array[]
*/
function User_unconfirmed_AngelTypes($user)
{
@@ -76,6 +76,7 @@ function User_is_AngelType_supporter(&$user, $angeltype)
if (!isset($user['privileges'])) {
$user['privileges'] = privileges_for_user($user['UID']);
}
+
return (count(DB::select('
SELECT `id`
FROM `UserAngelTypes`
@@ -105,7 +106,7 @@ function UserAngelType_update($user_angeltype_id, $supporter)
SET `supporter`=?
WHERE `id`=?
LIMIT 1
- ', [(int) $supporter, $user_angeltype_id]);
+ ', [(int)$supporter, $user_angeltype_id]);
}
/**
@@ -143,7 +144,6 @@ function UserAngelTypes_confirm_all($angeltype_id, $confirm_user)
*
* @param int $user_angeltype_id
* @param array $confirm_user
- * @return bool
*/
function UserAngelType_confirm($user_angeltype_id, $confirm_user)
{
diff --git a/includes/model/UserGroups_model.php b/includes/model/UserGroups_model.php
index d4baf638..9d67770c 100644
--- a/includes/model/UserGroups_model.php
+++ b/includes/model/UserGroups_model.php
@@ -6,7 +6,7 @@ use Engelsystem\Database\DB;
* Returns users groups
*
* @param array $user
- * @return array
+ * @return array[]
*/
function User_groups($user)
{
diff --git a/includes/model/User_model.php b/includes/model/User_model.php
index 2d1767e6..33fca639 100644
--- a/includes/model/User_model.php
+++ b/includes/model/User_model.php
@@ -209,7 +209,7 @@ function User_is_freeloader($user)
* Returns all users that are not member of given angeltype.
*
* @param array $angeltype Angeltype
- * @return array
+ * @return array[]
*/
function Users_by_angeltype_inverted($angeltype)
{
@@ -231,7 +231,7 @@ function Users_by_angeltype_inverted($angeltype)
* Returns all members of given angeltype.
*
* @param array $angeltype
- * @return array
+ * @return array[]
*/
function Users_by_angeltype($angeltype)
{
@@ -258,7 +258,7 @@ function Users_by_angeltype($angeltype)
/**
* Returns User id array
*
- * @return array
+ * @return array[]
*/
function User_ids()
{
@@ -268,6 +268,7 @@ function User_ids()
/**
* Strip unwanted characters from a users nick. Allowed are letters, numbers, connecting punctuation and simple space.
* Nick is trimmed.
+ *
* @param string $nick
* @return string
*/
@@ -279,8 +280,7 @@ function User_validate_Nick($nick)
/**
* Validate user email address.
*
- * @param string $mail
- * The email address to validate
+ * @param string $mail The email address to validate
* @return ValidationResult
*/
function User_validate_mail($mail)
@@ -292,8 +292,7 @@ function User_validate_mail($mail)
/**
* Validate user jabber address
*
- * @param string $jabber
- * Jabber-ID to validate
+ * @param string $jabber Jabber-ID to validate
* @return ValidationResult
*/
function User_validate_jabber($jabber)
@@ -337,10 +336,8 @@ function User_validate_planned_arrival_date($planned_arrival_date)
/**
* Validate the planned departure date
*
- * @param int $planned_arrival_date
- * Unix timestamp
- * @param int $planned_departure_date
- * Unix timestamp
+ * @param int $planned_arrival_date Unix timestamp
+ * @param int $planned_departure_date Unix timestamp
* @return ValidationResult
*/
function User_validate_planned_departure_date($planned_arrival_date, $planned_departure_date)
@@ -383,8 +380,7 @@ function User($user_id)
/**
* Returns User by api_key.
*
- * @param string $api_key
- * User api key
+ * @param string $api_key User api key
* @return array|null Matching user, null if not found
*/
function User_by_api_key($api_key)
@@ -396,7 +392,7 @@ function User_by_api_key($api_key)
* Returns User by email.
*
* @param string $email
- * @return array|null Matching user, null or false on error
+ * @return array|null Matching user, null on error
*/
function User_by_email($email)
{
@@ -460,7 +456,9 @@ function User_generate_password_recovery_token(&$user)
$user['UID'],
]
);
+
engelsystem_log('Password recovery for ' . User_Nick_render($user) . ' started.');
+
return $user['password_recovery_token'];
}
@@ -474,10 +472,10 @@ function User_get_eligable_voucher_count(&$user)
$shifts_done = count(ShiftEntries_finished_by_user($user));
$earned_vouchers = $user['got_voucher'] - $voucher_settings['initial_vouchers'];
- $elegible_vouchers = $shifts_done / $voucher_settings['shifts_per_voucher'] - $earned_vouchers;
- if ($elegible_vouchers < 0) {
+ $eligable_vouchers = $shifts_done / $voucher_settings['shifts_per_voucher'] - $earned_vouchers;
+ if ($eligable_vouchers < 0) {
return 0;
}
- return $elegible_vouchers;
+ return $eligable_vouchers;
}