Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
fsfahrttool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sarah Kleest-Meißner
fsfahrttool
Commits
76785d38
Commit
76785d38
authored
8 years ago
by
Tim Repke
Browse files
Options
Downloads
Patches
Plain Diff
rough outline for fahrt class
parent
bb83ad30
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
registration-system/frameworks/Environment.php
+1
-18
1 addition, 18 deletions
registration-system/frameworks/Environment.php
registration-system/frameworks/Fahrt.php
+133
-0
133 additions, 0 deletions
registration-system/frameworks/Fahrt.php
with
134 additions
and
18 deletions
registration-system/frameworks/
e
nvironment.php
→
registration-system/frameworks/
E
nvironment.php
+
1
−
18
View file @
76785d38
...
...
@@ -256,22 +256,5 @@ class Environment {
return
true
;
}
private
function
feedbackHelper
(
$mail_langs
,
$to
,
$hash
,
$fid
)
{
global
$config_baseurl
;
if
(
!
is_array
(
$mail_langs
))
$mail_langs
=
[
$mail_langs
];
$from
=
$this
->
database
->
get
(
"fahrten"
,
[
"kontakt"
,
"leiter"
,
"paydeadline"
,
"payinfo"
,
"wikilink"
],
[
"fahrt_id"
=>
$fid
]);
foreach
(
$mail_langs
as
$mail_lang
)
{
$mail
=
comm_get_lang
(
$mail_lang
,
[
"
{
{url}
}
"
=>
$config_baseurl
.
"status.php?hash="
.
$hash
,
"
{
{organisator}
}
"
=>
$from
[
'leiter'
],
"
{
{paydeadline}
}
"
=>
$from
[
'paydeadline'
],
"
{
{payinfo}
}
"
=>
$from
[
'payinfo'
],
"
{
{wikilink}
}
"
=>
$from
[
'wikilink'
]]);
$bcc
=
$mail_lang
===
"lang_payinfomail"
?
$from
[
'kontakt'
]
:
NULL
;
comm_send_mail
(
$this
->
database
,
$to
,
$mail
,
$from
[
'kontakt'
],
$bcc
);
}
}
}
This diff is collapsed.
Click to expand it.
registration-system/frameworks/Fahrt.php
0 → 100644
+
133
−
0
View file @
76785d38
<?php
require_once
'Bachelor.php'
;
class
Fahrt
{
const
STATUS_IS_OPEN_NOT_FULL
=
0
;
const
STATUS_IS_OPEN_FULL
=
1
;
const
STATUS_IS_CLOSED
=
2
;
const
ALLOWED_FIELDS
=
[
'fahrt_id'
,
'titel'
,
'ziel'
,
'vom'
,
'bis'
,
'regopen'
,
'beschreibung'
,
'leiter'
,
'kontakt'
,
'map_pin'
,
'max_bachelor'
,
'wikilink'
,
'paydeadline'
,
'payinfo'
,
'opentime'
];
private
$environment
;
private
$fid
;
private
$data
;
function
__construct
(
$fid
)
{
$this
->
environment
=
Environment
::
getEnv
();
$this
->
fid
=
$fid
;
$this
->
data
=
null
;
}
private
function
getBachelorsSelector
(
$params
)
{
$conditions
=
[
'fahrt_id'
=>
$this
->
fid
];
if
(
isset
(
$params
[
'waiting'
]))
{
$conditions
[
'transferred'
.
((
$params
[
'waiting'
])
?
''
:
'[!]'
)]
=
null
;
$conditions
[
'on_waitlist'
]
=
(
$params
[
'waiting'
])
?
1
:
0
;
}
if
(
isset
(
$params
[
'essen'
]))
$conditions
[
'essen'
]
=
$params
[
'essen'
];
if
(
isset
(
$params
[
'studityp'
]))
$conditions
[
'studityp'
]
=
$params
[
'studityp'
];
if
(
isset
(
$params
[
'virgin'
]))
$conditions
[
'virgin'
]
=
(
$params
[
'virgin'
])
?
1
:
0
;
if
(
isset
(
$params
[
'backstepped'
]))
$conditions
[
'backstepped'
.
((
$params
[
'backstepped'
])
?
'[!]'
:
''
)]
=
null
;
if
(
isset
(
$params
[
'paid'
]))
$conditions
[
'paid'
.
((
$params
[
'paid'
])
?
'[!]'
:
''
)]
=
null
;
if
(
isset
(
$params
[
'repaid'
]))
$conditions
[
'repaid'
.
((
$params
[
'backstepped'
])
?
'[!]'
:
''
)]
=
null
;
if
(
isset
(
$params
[
'public'
]))
$conditions
[
'public'
]
=
(
$params
[
'public'
])
?
1
:
0
;
$selector
=
[
'table'
=>
'bachelor'
,
'fields'
=>
!
isset
(
$params
[
'fields'
])
?
Bachelor
::
ALLOWED_FIELDS
:
$params
[
'fields'
],
'where'
=>
[
'AND'
=>
$conditions
]
];
return
$selector
;
}
/**
* This function returns participants of this fahrt.
* Set parameters to filter, keep unset means 'dont care'.
*
* Form the param array as follows:
* - $fields (array[string]) columns you want to select
* - $waiting (bool) is on the waitlist and not transferred
* - $essen (str) has specific food preferences
* - $studityp (int) is of specific studityp
* - $virgin (bool) is <18 or not
* - $backstepped (bool) stepped back or not
* - $paid (bool) paid or not
* - $repaid (bool) got money back or not
* - $public (bool) publically visible
*
* @param array $params params for the selector
*
* @return medoo result
*/
public
function
getBachelors
(
$params
)
{
$selector
=
$this
->
getBachelorsSelector
(
$params
);
return
$this
->
environment
->
database
->
select
(
$selector
[
'table'
],
$selector
[
'fields'
],
$selector
[
'where'
]);
}
public
function
getBachelor
(
$bid
)
{
return
Bachelor
::
makeFromDB
(
$this
->
fid
,
$bid
);
}
public
function
getFahrtDetails
()
{
if
(
!
is_null
(
$this
->
data
))
return
$this
->
data
;
$this
->
data
=
$this
->
environment
->
database
->
get
(
'fahrten'
,
Fahrt
::
ALLOWED_FIELDS
,
[
'fahrt_id'
=>
$this
->
fid
]);
return
$this
->
data
;
}
public
function
getID
()
{
return
$this
->
fid
;
}
public
function
getPossibleDates
(){
$details
=
$this
->
getFahrtDetails
();
$end
=
new
DateTime
(
$details
[
'bis'
]);
$period
=
new
DatePeriod
(
new
DateTime
(
$details
[
'von'
]),
new
DateInterval
(
'P1D'
),
$end
->
modify
(
'+1 day'
)
);
$ret
=
[];
foreach
(
$period
as
$d
){
array_push
(
$ret
,
$d
->
format
(
"d.m.Y"
));
}
return
$ret
;
}
public
function
getRegistrationState
()
{
comm_verbose
(
3
,
'checking if fid '
.
$this
->
fid
.
' is open'
);
if
(
!
$this
->
environment
->
database
->
has
(
'fahrten'
,
[
'AND'
=>
[
'fahrt_id'
=>
$this
->
fid
,
'regopen'
=>
1
]]))
return
Fahrt
::
STATUS_IS_CLOSED
;
$selector
=
$this
->
getBachelorsSelector
([
'backstepped'
=>
false
,
'waiting'
=>
false
]);
$cnt
=
$this
->
environment
->
database
->
count
(
'bachelor'
,
$selector
[
'where'
]);
$max
=
$this
->
getFahrtDetails
()[
'max_bachelor'
];
if
(
$cnt
<
$max
)
return
Fahrt
::
STATUS_IS_OPEN_NOT_FULL
;
return
Fahrt
::
STATUS_IS_OPEN_FULL
;
}
public
function
isRegistrationOpen
()
{
$state
=
$this
->
getRegistrationState
();
return
$state
==
Fahrt
::
STATUS_IS_OPEN_FULL
or
$state
==
Fahrt
::
STATUS_IS_OPEN_NOT_FULL
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment