Merge branch 'pr/316' into feature-igel-rewrite
commit
56814fa2fd
@ -1,6 +0,0 @@
|
||||
[submodule "vendor/parsedown"]
|
||||
path = vendor/parsedown
|
||||
url = https://github.com/erusev/parsedown.git
|
||||
[submodule "vendor/bootstrap"]
|
||||
path = themes/assets/bootstrap
|
||||
url = https://github.com/twbs/bootstrap.git
|
||||
@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "engelsystem/engelsystem",
|
||||
"description": "Shift planning system for chaos events",
|
||||
"type": "project",
|
||||
"license": "GPL-2.0",
|
||||
"authors": [
|
||||
{
|
||||
"name": "msquare",
|
||||
"email": "msquare@notrademark.de"
|
||||
},
|
||||
{
|
||||
"name": "MyIgel",
|
||||
"email": "igor.scheller@igorshp.de"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.4",
|
||||
"erusev/parsedown": "1.6.*",
|
||||
"twbs/bootstrap": "^3.3"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Engelsystem\\": "src/"
|
||||
},
|
||||
"files": [
|
||||
"src/helpers.php"
|
||||
]
|
||||
}
|
||||
}
|
||||
@ -1,104 +1,129 @@
|
||||
<?php
|
||||
|
||||
function mail_shift_change($old_shift, $new_shift) {
|
||||
$users = ShiftEntries_by_shift($old_shift["SID"]);
|
||||
$old_room = Room($old_shift["RID"]);
|
||||
$new_room = Room($new_shift["RID"]);
|
||||
|
||||
$noticable_changes = false;
|
||||
|
||||
$message = _("A Shift you are registered on has changed:");
|
||||
/**
|
||||
* @param array $old_shift
|
||||
* @param array $new_shift
|
||||
*/
|
||||
function mail_shift_change($old_shift, $new_shift)
|
||||
{
|
||||
$users = ShiftEntries_by_shift($old_shift['SID']);
|
||||
$old_room = Room($old_shift['RID']);
|
||||
$new_room = Room($new_shift['RID']);
|
||||
|
||||
$noticeable_changes = false;
|
||||
|
||||
$message = _('A Shift you are registered on has changed:');
|
||||
$message .= "\n";
|
||||
|
||||
if ($old_shift["name"] != $new_shift["name"]) {
|
||||
$message .= sprintf(_("* Shift type changed from %s to %s"), $old_shift["name"], $new_shift["name"]) . "\n";
|
||||
$noticable_changes = true;
|
||||
if ($old_shift['name'] != $new_shift['name']) {
|
||||
$message .= sprintf(_('* Shift type changed from %s to %s'), $old_shift['name'], $new_shift['name']) . "\n";
|
||||
$noticeable_changes = true;
|
||||
}
|
||||
|
||||
if ($old_shift["title"] != $new_shift["title"]) {
|
||||
$message .= sprintf(_("* Shift title changed from %s to %s"), $old_shift["title"], $new_shift["title"]) . "\n";
|
||||
$noticable_changes = true;
|
||||
if ($old_shift['title'] != $new_shift['title']) {
|
||||
$message .= sprintf(_('* Shift title changed from %s to %s'), $old_shift['title'], $new_shift['title']) . "\n";
|
||||
$noticeable_changes = true;
|
||||
}
|
||||
|
||||
if ($old_shift["start"] != $new_shift["start"]) {
|
||||
$message .= sprintf(_("* Shift Start changed from %s to %s"), date("Y-m-d H:i", $old_shift["start"]), date("Y-m-d H:i", $new_shift["start"])) . "\n";
|
||||
$noticable_changes = true;
|
||||
if ($old_shift['start'] != $new_shift['start']) {
|
||||
$message .= sprintf(
|
||||
_('* Shift Start changed from %s to %s'),
|
||||
date('Y-m-d H:i', $old_shift['start']),
|
||||
date('Y-m-d H:i', $new_shift['start'])
|
||||
) . "\n";
|
||||
$noticeable_changes = true;
|
||||
}
|
||||
|
||||
if ($old_shift["end"] != $new_shift["end"]) {
|
||||
$message .= sprintf(_("* Shift End changed from %s to %s"), date("Y-m-d H:i", $old_shift["end"]), date("Y-m-d H:i", $new_shift["end"])) . "\n";
|
||||
$noticable_changes = true;
|
||||
if ($old_shift['end'] != $new_shift['end']) {
|
||||
$message .= sprintf(
|
||||
_('* Shift End changed from %s to %s'),
|
||||
date('Y-m-d H:i', $old_shift['end']),
|
||||
date('Y-m-d H:i', $new_shift['end'])
|
||||
) . "\n";
|
||||
$noticeable_changes = true;
|
||||
}
|
||||
|
||||
if ($old_shift["RID"] != $new_shift["RID"]) {
|
||||
$message .= sprintf(_("* Shift Location changed from %s to %s"), $old_room["Name"], $new_room["Name"]) . "\n";
|
||||
$noticable_changes = true;
|
||||
if ($old_shift['RID'] != $new_shift['RID']) {
|
||||
$message .= sprintf(_('* Shift Location changed from %s to %s'), $old_room['Name'], $new_room['Name']) . "\n";
|
||||
$noticeable_changes = true;
|
||||
}
|
||||
|
||||
if (! $noticable_changes) {
|
||||
if (!$noticeable_changes) {
|
||||
// There are no changes worth sending an E-Mail
|
||||
return;
|
||||
}
|
||||
|
||||
$message .= "\n";
|
||||
$message .= _("The updated Shift:") . "\n";
|
||||
$message .= _('The updated Shift:') . "\n";
|
||||
|
||||
$message .= $new_shift["name"] . "\n";
|
||||
$message .= $new_shift["title"] . "\n";
|
||||
$message .= date("Y-m-d H:i", $new_shift["start"]) . " - " . date("H:i", $new_shift["end"]) . "\n";
|
||||
$message .= $new_room["Name"] . "\n";
|
||||
$message .= $new_shift['name'] . "\n";
|
||||
$message .= $new_shift['title'] . "\n";
|
||||
$message .= date('Y-m-d H:i', $new_shift['start']) . ' - ' . date('H:i', $new_shift['end']) . "\n";
|
||||
$message .= $new_room['Name'] . "\n";
|
||||
|
||||
foreach ($users as $user) {
|
||||
if ($user["email_shiftinfo"]) {
|
||||
engelsystem_email_to_user($user, '[engelsystem] ' . _("Your Shift has changed"), $message, true);
|
||||
if ($user['email_shiftinfo']) {
|
||||
engelsystem_email_to_user($user, '[engelsystem] ' . _('Your Shift has changed'), $message, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function mail_shift_delete($shift) {
|
||||
$users = ShiftEntries_by_shift($shift["SID"]);
|
||||
$room = Room($shift["RID"]);
|
||||
/**
|
||||
* @param array $shift
|
||||
*/
|
||||
function mail_shift_delete($shift)
|
||||
{
|
||||
$users = ShiftEntries_by_shift($shift['SID']);
|
||||
$room = Room($shift['RID']);
|
||||
|
||||
$message = _("A Shift you are registered on was deleted:") . "\n";
|
||||
$message = _('A Shift you are registered on was deleted:') . "\n";
|
||||
|
||||
$message .= $shift["name"] . "\n";
|
||||
$message .= $shift["title"] . "\n";
|
||||
$message .= date("Y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n";
|
||||
$message .= $room["Name"] . "\n";
|
||||
$message .= $shift['name'] . "\n";
|
||||
$message .= $shift['title'] . "\n";
|
||||
$message .= date('Y-m-d H:i', $shift['start']) . ' - ' . date('H:i', $shift['end']) . "\n";
|
||||
$message .= $room['Name'] . "\n";
|
||||
|
||||
foreach ($users as $user) {
|
||||
if ($user["email_shiftinfo"]) {
|
||||
engelsystem_email_to_user($user, '[engelsystem] ' . _("Your Shift was deleted"), $message, true);
|
||||
if ($user['email_shiftinfo']) {
|
||||
engelsystem_email_to_user($user, '[engelsystem] ' . _('Your Shift was deleted'), $message, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function mail_shift_assign($user, $shift) {
|
||||
if ($user["email_shiftinfo"]) {
|
||||
$room = Room($shift["RID"]);
|
||||
/**
|
||||
* @param array $user
|
||||
* @param array $shift
|
||||
*/
|
||||
function mail_shift_assign($user, $shift)
|
||||
{
|
||||
if (!$user['email_shiftinfo']) {
|
||||
return;
|
||||
}
|
||||
|
||||
$room = Room($shift['RID']);
|
||||
|
||||
$message = _("You have been assigned to a Shift:") . "\n";
|
||||
$message .= $shift["name"] . "\n";
|
||||
$message .= $shift["title"] . "\n";
|
||||
$message .= date("Y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n";
|
||||
$message .= $room["Name"] . "\n";
|
||||
$message = _('You have been assigned to a Shift:') . "\n";
|
||||
$message .= $shift['name'] . "\n";
|
||||
$message .= $shift['title'] . "\n";
|
||||
$message .= date('Y-m-d H:i', $shift['start']) . ' - ' . date('H:i', $shift['end']) . "\n";
|
||||
$message .= $room['Name'] . "\n";
|
||||
|
||||
engelsystem_email_to_user($user, '[engelsystem] ' . _("Assigned to Shift"), $message, true);
|
||||
}
|
||||
engelsystem_email_to_user($user, '[engelsystem] ' . _('Assigned to Shift'), $message, true);
|
||||
}
|
||||
|
||||
function mail_shift_removed($user, $shift) {
|
||||
if ($user["email_shiftinfo"]) {
|
||||
$room = Room($shift["RID"]);
|
||||
function mail_shift_removed($user, $shift)
|
||||
{
|
||||
if (!$user['email_shiftinfo']) {
|
||||
return;
|
||||
}
|
||||
|
||||
$message = _("You have been removed from a Shift:") . "\n";
|
||||
$message .= $shift["name"] . "\n";
|
||||
$message .= $shift["title"] . "\n";
|
||||
$message .= date("Y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n";
|
||||
$message .= $room["Name"] . "\n";
|
||||
$room = Room($shift['RID']);
|
||||
|
||||
engelsystem_email_to_user($user, '[engelsystem] ' . _("Removed from Shift"), $message, true);
|
||||
}
|
||||
}
|
||||
$message = _('You have been removed from a Shift:') . "\n";
|
||||
$message .= $shift['name'] . "\n";
|
||||
$message .= $shift['title'] . "\n";
|
||||
$message .= date('Y-m-d H:i', $shift['start']) . ' - ' . date('H:i', $shift['end']) . "\n";
|
||||
$message .= $room['Name'] . "\n";
|
||||
|
||||
?>
|
||||
engelsystem_email_to_user($user, '[engelsystem] ' . _('Removed from Shift'), $message, true);
|
||||
}
|
||||
|
||||
@ -1,9 +1,14 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @param User $user_source
|
||||
* @param array $user
|
||||
* @return bool
|
||||
*/
|
||||
function mail_user_delete($user) {
|
||||
engelsystem_email_to_user($user, '[engelsystem] ' . _("Your account has been deleted"), _("Your angelsystem account has been deleted. If you have any questions regarding your account deletion, please contact heaven."));
|
||||
function mail_user_delete($user)
|
||||
{
|
||||
return engelsystem_email_to_user(
|
||||
$user,
|
||||
'[engelsystem] ' . _('Your account has been deleted'),
|
||||
_('Your angelsystem account has been deleted. If you have any questions regarding your account deletion, please contact heaven.')
|
||||
);
|
||||
}
|
||||
?>
|
||||
@ -1,60 +1,82 @@
|
||||
<?php
|
||||
|
||||
use Engelsystem\Database\DB;
|
||||
|
||||
/**
|
||||
* returns a list of rooms.
|
||||
*
|
||||
* @param boolean $show_all returns also hidden rooms when true
|
||||
* @return array
|
||||
*/
|
||||
function Rooms($show_all = false) {
|
||||
return sql_select("SELECT * FROM `Room`" . ($show_all ? "" : " WHERE `show`='Y'") . " ORDER BY `Name`");
|
||||
function Rooms($show_all = false)
|
||||
{
|
||||
return DB::select('SELECT * FROM `Room`' . ($show_all ? '' : ' WHERE `show`=\'Y\'') . ' ORDER BY `Name`');
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a room
|
||||
*
|
||||
* @param int $room_id
|
||||
* @return bool
|
||||
*/
|
||||
function Room_delete($room_id) {
|
||||
return sql_query("DELETE FROM `Room` WHERE `RID`=" . sql_escape($room_id));
|
||||
function Room_delete($room_id)
|
||||
{
|
||||
return DB::delete('DELETE FROM `Room` WHERE `RID` = ?', [$room_id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new room
|
||||
*
|
||||
* @param string $name
|
||||
* Name of the room
|
||||
* @param boolean $from_frab
|
||||
* Is this a frab imported room?
|
||||
* @param boolean $public
|
||||
* Is the room visible for angels?
|
||||
* @param string $name Name of the room
|
||||
* @param boolean $from_frab Is this a frab imported room?
|
||||
* @param boolean $public Is the room visible for angels?
|
||||
* @param int $number Room number
|
||||
* @return false|int
|
||||
*/
|
||||
function Room_create($name, $from_frab, $public) {
|
||||
$result = sql_query("
|
||||
INSERT INTO `Room` SET
|
||||
`Name`='" . sql_escape($name) . "',
|
||||
`FromPentabarf`='" . sql_escape($from_frab ? 'Y' : '') . "',
|
||||
`show`='" . sql_escape($public ? 'Y' : '') . "',
|
||||
`Number`=0");
|
||||
if ($result === false) {
|
||||
function Room_create($name, $from_frab, $public, $number = null)
|
||||
{
|
||||
$result = DB::insert('
|
||||
INSERT INTO `Room` (`Name`, `FromPentabarf`, `show`, `Number`)
|
||||
VALUES (?, ?, ?, ?)
|
||||
',
|
||||
[
|
||||
$name,
|
||||
$from_frab ? 'Y' : '',
|
||||
$public ? 'Y' : '',
|
||||
(int)$number,
|
||||
]
|
||||
);
|
||||
if (!$result) {
|
||||
return false;
|
||||
}
|
||||
return sql_id();
|
||||
|
||||
return DB::getPdo()->lastInsertId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns room by id.
|
||||
*
|
||||
* @param $room_id RID
|
||||
* @param int $room_id RID
|
||||
* @param bool $show_only
|
||||
* @return array|false
|
||||
*/
|
||||
function Room($room_id) {
|
||||
$room_source = sql_select("SELECT * FROM `Room` WHERE `RID`='" . sql_escape($room_id) . "'");
|
||||
function Room($room_id, $show_only = true)
|
||||
{
|
||||
$room_source = DB::select('
|
||||
SELECT *
|
||||
FROM `Room`
|
||||
WHERE `RID` = ?
|
||||
' . ($show_only ? 'AND `show` = \'Y\'' : ''),
|
||||
[$room_id]
|
||||
);
|
||||
|
||||
if ($room_source === false) {
|
||||
if (DB::getStm()->errorCode() != '00000') {
|
||||
return false;
|
||||
}
|
||||
if (count($room_source) > 0) {
|
||||
return $room_source[0];
|
||||
}
|
||||
|
||||
if (empty($room_source)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
return array_shift($room_source);
|
||||
}
|
||||
|
||||
@ -1,17 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Engelsystem\Database\DB;
|
||||
|
||||
/**
|
||||
* Returns users groups
|
||||
* @param User $user
|
||||
*
|
||||
* @param array $user
|
||||
* @return array
|
||||
*/
|
||||
function User_groups($user) {
|
||||
return sql_select("
|
||||
function User_groups($user)
|
||||
{
|
||||
return DB::select('
|
||||
SELECT `Groups`.*
|
||||
FROM `UserGroups`
|
||||
JOIN `Groups` ON `Groups`.`UID`=`UserGroups`.`group_id`
|
||||
WHERE `UserGroups`.`uid`='" . sql_escape($user['UID']) . "'
|
||||
WHERE `UserGroups`.`uid`=?
|
||||
ORDER BY `UserGroups`.`group_id`
|
||||
");
|
||||
',
|
||||
[$user['UID']]
|
||||
);
|
||||
}
|
||||
|
||||
?>
|
||||
@ -1,216 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Close connection.
|
||||
*/
|
||||
function sql_close() {
|
||||
global $sql_connection;
|
||||
|
||||
return $sql_connection->close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return NULL if given value is null.
|
||||
*/
|
||||
function sql_null($value = null) {
|
||||
return $value == null ? 'NULL' : ("'" . sql_escape($value) . "'");
|
||||
}
|
||||
|
||||
/**
|
||||
* Start new transaction.
|
||||
*/
|
||||
function sql_transaction_start() {
|
||||
global $sql_nested_transaction_level;
|
||||
|
||||
if ($sql_nested_transaction_level ++ == 0) {
|
||||
return sql_query("BEGIN");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Commit transaction.
|
||||
*/
|
||||
function sql_transaction_commit() {
|
||||
global $sql_nested_transaction_level;
|
||||
|
||||
if (-- $sql_nested_transaction_level == 0) {
|
||||
return sql_query("COMMIT");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop transaction, revert database.
|
||||
*/
|
||||
function sql_transaction_rollback() {
|
||||
global $sql_nested_transaction_level;
|
||||
|
||||
if (-- $sql_nested_transaction_level == 0) {
|
||||
return sql_query("ROLLBACK");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs an sql error.
|
||||
*
|
||||
* @param string $message
|
||||
* @return false
|
||||
*/
|
||||
function sql_error($message) {
|
||||
sql_close();
|
||||
|
||||
$message = trim($message) . "\n";
|
||||
$message .= debug_string_backtrace() . "\n";
|
||||
|
||||
error_log('mysql_provider error: ' . $message);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect to mysql server.
|
||||
*
|
||||
* @param string $host
|
||||
* Host
|
||||
* @param string $user
|
||||
* Username
|
||||
* @param string $pass
|
||||
* Password
|
||||
* @param string $db_name
|
||||
* DB to select
|
||||
* @return mysqli The connection handler
|
||||
*/
|
||||
function sql_connect($host, $user, $pass, $db_name) {
|
||||
global $sql_connection;
|
||||
|
||||
$sql_connection = new mysqli($host, $user, $pass, $db_name);
|
||||
if ($sql_connection->connect_errno) {
|
||||
error("Unable to connect to MySQL: " . $sql_connection->connect_error);
|
||||
return sql_error("Unable to connect to MySQL: " . $sql_connection->connect_error);
|
||||
}
|
||||
|
||||
$result = $sql_connection->query("SET CHARACTER SET utf8;");
|
||||
if (! $result) {
|
||||
return sql_error("Unable to set utf8 character set (" . $sql_connection->errno . ") " . $sql_connection->error);
|
||||
}
|
||||
|
||||
$result = $sql_connection->set_charset('utf8');
|
||||
if (! $result) {
|
||||
return sql_error("Unable to set utf8 names (" . $sql_connection->errno . ") " . $sql_connection->error);
|
||||
}
|
||||
|
||||
return $sql_connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the selected db in current mysql-connection.
|
||||
*
|
||||
* @param
|
||||
* $db_name
|
||||
* @return bool true on success, false on error
|
||||
*/
|
||||
function sql_select_db($db_name) {
|
||||
global $sql_connection;
|
||||
if (! $sql_connection->select_db($db_name)) {
|
||||
return sql_error("No database selected.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* MySQL SELECT query
|
||||
*
|
||||
* @param string $query
|
||||
* @return Result array or false on error
|
||||
*/
|
||||
function sql_select($query) {
|
||||
global $sql_connection;
|
||||
|
||||
// echo $query . ";\n";
|
||||
// echo debug_string_backtrace() . "\n";
|
||||
|
||||
$result = $sql_connection->query($query);
|
||||
if ($result) {
|
||||
$data = [];
|
||||
while ($line = $result->fetch_assoc()) {
|
||||
array_push($data, $line);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
return sql_error("MySQL-query error: " . $query . " (" . $sql_connection->errno . ") " . $sql_connection->error);
|
||||
}
|
||||
|
||||
/**
|
||||
* MySQL execute a query
|
||||
*
|
||||
* @param string $query
|
||||
* @return mysqli_result boolean resource or false on error
|
||||
*/
|
||||
function sql_query($query) {
|
||||
global $sql_connection;
|
||||
|
||||
$result = $sql_connection->query($query);
|
||||
if ($result) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
return sql_error("MySQL-query error: " . $query . " (" . $sql_connection->errno . ") " . $sql_connection->error);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns last inserted id.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
function sql_id() {
|
||||
global $sql_connection;
|
||||
return $sql_connection->insert_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape a string for a sql query.
|
||||
*
|
||||
* @param string $query
|
||||
* @return string
|
||||
*/
|
||||
function sql_escape($query) {
|
||||
global $sql_connection;
|
||||
return $sql_connection->real_escape_string($query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a boolean for mysql-queries.
|
||||
*
|
||||
* @param boolean $boolean
|
||||
* @return string
|
||||
*/
|
||||
function sql_bool($boolean) {
|
||||
return $boolean == true ? 'TRUE' : 'FALSE';
|
||||
}
|
||||
|
||||
/**
|
||||
* Count query result lines.
|
||||
*
|
||||
* @param string $query
|
||||
* @return int Count of result lines
|
||||
*/
|
||||
function sql_num_query($query) {
|
||||
return sql_query($query)->num_rows;
|
||||
}
|
||||
|
||||
function sql_select_single_col($query) {
|
||||
$result = sql_select($query);
|
||||
return array_map('array_shift', $result);
|
||||
}
|
||||
|
||||
function sql_select_single_cell($query) {
|
||||
return array_shift(array_shift(sql_select($query)));
|
||||
}
|
||||
|
||||
?>
|
||||
@ -1,67 +1,82 @@
|
||||
<?php
|
||||
|
||||
function admin_news() {
|
||||
use Engelsystem\Database\DB;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function admin_news()
|
||||
{
|
||||
global $user;
|
||||
|
||||
if (! isset($_GET["action"])) {
|
||||
redirect(page_link_to("news"));
|
||||
if (!isset($_GET['action'])) {
|
||||
redirect(page_link_to('news'));
|
||||
}
|
||||
|
||||
$html = '<div class="col-md-12"><h1>' . _("Edit news entry") . '</h1>' . msg();
|
||||
if (isset($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id'])) {
|
||||
$html = '<div class="col-md-12"><h1>' . _('Edit news entry') . '</h1>' . msg();
|
||||
if (isset($_REQUEST['id']) && preg_match('/^\d{1,11}$/', $_REQUEST['id'])) {
|
||||
$news_id = $_REQUEST['id'];
|
||||
} else {
|
||||
return error("Incomplete call, missing News ID.", true);
|
||||
return error('Incomplete call, missing News ID.', true);
|
||||
}
|
||||
|
||||
$news = sql_select("SELECT * FROM `News` WHERE `ID`='" . sql_escape($news_id) . "' LIMIT 1");
|
||||
$news = DB::select('SELECT * FROM `News` WHERE `ID`=? LIMIT 1', [$news_id]);
|
||||
if (empty($news)) {
|
||||
return error("No News found.", true);
|
||||
return error('No News found.', true);
|
||||
}
|
||||
switch ($_REQUEST["action"]) {
|
||||
default:
|
||||
redirect(page_link_to('news'));
|
||||
case 'edit':
|
||||
list($news) = $news;
|
||||
|
||||
switch ($_REQUEST['action']) {
|
||||
case 'edit':
|
||||
$news = array_shift($news);
|
||||
$user_source = User($news['UID']);
|
||||
|
||||
$html .= form([
|
||||
form_info(_("Date"), date("Y-m-d H:i", $news['Datum'])),
|
||||
form_info(_("Author"), User_Nick_render($user_source)),
|
||||
form_text('eBetreff', _("Subject"), $news['Betreff']),
|
||||
form_textarea('eText', _("Message"), $news['Text']),
|
||||
form_checkbox('eTreffen', _("Meeting"), $news['Treffen'] == 1, 1),
|
||||
form_submit('submit', _("Save"))
|
||||
form_info(_('Date'), date('Y-m-d H:i', $news['Datum'])),
|
||||
form_info(_('Author'), User_Nick_render($user_source)),
|
||||
form_text('eBetreff', _('Subject'), $news['Betreff']),
|
||||
form_textarea('eText', _('Message'), $news['Text']),
|
||||
form_checkbox('eTreffen', _('Meeting'), $news['Treffen'] == 1, 1),
|
||||
form_submit('submit', _('Save'))
|
||||
], page_link_to('admin_news&action=save&id=' . $news_id));
|
||||
|
||||
$html .= '<a class="btn btn-danger" href="' . page_link_to('admin_news&action=delete&id=' . $news_id) . '"><span class="glyphicon glyphicon-trash"></span> ' . _("Delete") . '</a>';
|
||||
$html .= '<a class="btn btn-danger" href="' . page_link_to('admin_news&action=delete&id=' . $news_id) . '">'
|
||||
. '<span class="glyphicon glyphicon-trash"></span> ' . _('Delete')
|
||||
. '</a>';
|
||||
break;
|
||||
|
||||
case 'save':
|
||||
list($news) = $news;
|
||||
|
||||
sql_query("UPDATE `News` SET
|
||||
`Datum`='" . sql_escape(time()) . "',
|
||||
`Betreff`='" . sql_escape($_POST["eBetreff"]) . "',
|
||||
`Text`='" . sql_escape($_POST["eText"]) . "',
|
||||
`UID`='" . sql_escape($user['UID']) . "',
|
||||
`Treffen`='" . sql_escape($_POST["eTreffen"]) . "'
|
||||
WHERE `ID`='" . sql_escape($news_id) . "'");
|
||||
engelsystem_log("News updated: " . $_POST["eBetreff"]);
|
||||
success(_("News entry updated."));
|
||||
redirect(page_link_to("news"));
|
||||
DB::update('
|
||||
UPDATE `News` SET
|
||||
`Datum`=?,
|
||||
`Betreff`=?,
|
||||
`Text`=?,
|
||||
`UID`=?,
|
||||
`Treffen`=?
|
||||
WHERE `ID`=?
|
||||
',
|
||||
[
|
||||
time(),
|
||||
$_POST["eBetreff"],
|
||||
$_POST["eText"],
|
||||
$user['UID'],
|
||||
isset($_POST["eTreffen"]) ? 1 : 0,
|
||||
$news_id
|
||||
]
|
||||
);
|
||||
engelsystem_log('News updated: ' . $_POST['eBetreff']);
|
||||
success(_('News entry updated.'));
|
||||
redirect(page_link_to('news'));
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
list($news) = $news;
|
||||
|
||||
sql_query("DELETE FROM `News` WHERE `ID`='" . sql_escape($news_id) . "' LIMIT 1");
|
||||
engelsystem_log("News deleted: " . $news['Betreff']);
|
||||
success(_("News entry deleted."));
|
||||
redirect(page_link_to("news"));
|
||||
$news = array_shift($news);
|
||||
DB::delete('DELETE FROM `News` WHERE `ID`=? LIMIT 1', [$news_id]);
|
||||
engelsystem_log('News deleted: ' . $news['Betreff']);
|
||||
success(_('News entry deleted.'));
|
||||
redirect(page_link_to('news'));
|
||||
break;
|
||||
default:
|
||||
redirect(page_link_to('news'));
|
||||
}
|
||||
return $html . '</div>';
|
||||
}
|
||||
?>
|
||||
@ -1,9 +1,17 @@
|
||||
<?php
|
||||
function credits_title() {
|
||||
return _("Credits");
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function credits_title()
|
||||
{
|
||||
return _('Credits');
|
||||
}
|
||||
|
||||
function guest_credits() {
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function guest_credits()
|
||||
{
|
||||
return template_render(__DIR__ . '/../../templates/guest_credits.html', []);
|
||||
}
|
||||
?>
|
||||
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
function guest_start() {
|
||||
function guest_start()
|
||||
{
|
||||
redirect(page_link_to('login'));
|
||||
return true;
|
||||
}
|
||||
?>
|
||||
@ -1,57 +1,85 @@
|
||||
<?php
|
||||
|
||||
function questions_title() {
|
||||
return _("Ask the Heaven");
|
||||
use Engelsystem\Database\DB;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function questions_title()
|
||||
{
|
||||
return _('Ask the Heaven');
|
||||
}
|
||||
|
||||
function user_questions() {
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function user_questions()
|
||||
{
|
||||
global $user;
|
||||
|
||||
if (! isset($_REQUEST['action'])) {
|
||||
$open_questions = sql_select("SELECT * FROM `Questions` WHERE `AID` IS NULL AND `UID`='" . sql_escape($user['UID']) . "'");
|
||||
if (!isset($_REQUEST['action'])) {
|
||||
$open_questions = DB::select(
|
||||
'SELECT * FROM `Questions` WHERE `AID` IS NULL AND `UID`=?',
|
||||
[$user['UID']]
|
||||
);
|
||||
|
||||
$answered_questions = sql_select("SELECT * FROM `Questions` WHERE NOT `AID` IS NULL AND `UID`='" . sql_escape($user['UID']) . "'");
|
||||
$answered_questions = DB::select(
|
||||
'SELECT * FROM `Questions` WHERE NOT `AID` IS NULL AND `UID`=?',
|
||||
[$user['UID']]
|
||||
);
|
||||
foreach ($answered_questions as &$question) {
|
||||
$answer_user_source = User($question['AID']);
|
||||
$question['answer_user'] = User_Nick_render($answer_user_source);
|
||||
}
|
||||
|
||||
return Questions_view($open_questions, $answered_questions, page_link_to("user_questions") . '&action=ask');
|
||||
return Questions_view($open_questions, $answered_questions, page_link_to('user_questions') . '&action=ask');
|
||||
} else {
|
||||
switch ($_REQUEST['action']) {
|
||||
case 'ask':
|
||||
$question = strip_request_item_nl('question');
|
||||
if ($question != "") {
|
||||
$result = sql_query("INSERT INTO `Questions` SET `UID`='" . sql_escape($user['UID']) . "', `Question`='" . sql_escape($question) . "'");
|
||||
if ($result === false) {
|
||||
engelsystem_error(_("Unable to save question."));
|
||||
if ($question != '') {
|
||||
$result = DB::insert('
|
||||
INSERT INTO `Questions` (`UID`, `Question`)
|
||||
VALUES (?, ?)
|
||||
',
|
||||
[$user['UID'], $question]
|
||||
);
|
||||
if (!$result) {
|
||||
engelsystem_error(_('Unable to save question.'));
|
||||
}
|
||||
success(_("You question was saved."));
|
||||
redirect(page_link_to("user_questions"));
|
||||
success(_('You question was saved.'));
|
||||
redirect(page_link_to('user_questions'));
|
||||
} else {
|
||||
return page_with_title(questions_title(), [
|
||||
error(_("Please enter a question!"), true)
|
||||
error(_('Please enter a question!'), true)
|
||||
]);
|
||||
}
|
||||
break;
|
||||
case 'delete':
|
||||
if (isset($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id'])) {
|
||||
if (isset($_REQUEST['id']) && preg_match('/^\d{1,11}$/', $_REQUEST['id'])) {
|
||||
$question_id = $_REQUEST['id'];
|
||||
} else {
|
||||
return error(_("Incomplete call, missing Question ID."), true);
|
||||
return error(_('Incomplete call, missing Question ID.'), true);
|
||||
}
|
||||
|
||||
$question = sql_select("SELECT * FROM `Questions` WHERE `QID`='" . sql_escape($question_id) . "' LIMIT 1");
|
||||
$question = DB::select(
|
||||
'SELECT `UID` FROM `Questions` WHERE `QID`=? LIMIT 1',
|
||||
[$question_id]
|
||||
);
|
||||
if (count($question) > 0 && $question[0]['UID'] == $user['UID']) {
|
||||
sql_query("DELETE FROM `Questions` WHERE `QID`='" . sql_escape($question_id) . "' LIMIT 1");
|
||||
redirect(page_link_to("user_questions"));
|
||||
DB::delete(
|
||||
'DELETE FROM `Questions` WHERE `QID`=? LIMIT 1',
|
||||
[$question_id]
|
||||
);
|
||||
redirect(page_link_to('user_questions'));
|
||||
} else {
|
||||
return page_with_title(questions_title(), [
|
||||
error(_("No question found."), true)
|
||||
error(_('No question found.'), true)
|
||||
]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
?>
|
||||
@ -1,37 +1,42 @@
|
||||
<?php
|
||||
|
||||
function Questions_view($open_questions, $answered_questions, $ask_action) {
|
||||
/**
|
||||
* @param array[] $open_questions
|
||||
* @param array[] $answered_questions
|
||||
* @param string $ask_action
|
||||
* @return string
|
||||
*/
|
||||
function Questions_view($open_questions, $answered_questions, $ask_action)
|
||||
{
|
||||
foreach ($open_questions as &$question) {
|
||||
$question['actions'] = '<a href="' . page_link_to("user_questions") . '&action=delete&id=' . $question['QID'] . '">' . _("delete") . '</a>';
|
||||
$question['actions'] = '<a href="' . page_link_to('user_questions') . '&action=delete&id=' . $question['QID'] . '">' . _('delete') . '</a>';
|
||||
$question['Question'] = str_replace("\n", '<br />', $question['Question']);
|
||||
}
|
||||
|
||||
foreach ($answered_questions as &$question) {
|
||||
$question['Question'] = str_replace("\n", '<br />', $question['Question']);
|
||||
$question['Answer'] = str_replace("\n", '<br />', $question['Answer']);
|
||||
$question['actions'] = '<a href="' . page_link_to("user_questions") . '&action=delete&id=' . $question['QID'] . '">' . _("delete") . '</a>';
|
||||
$question['actions'] = '<a href="' . page_link_to('user_questions') . '&action=delete&id=' . $question['QID'] . '">' . _('delete') . '</a>';
|
||||
}
|
||||
|
||||
return page_with_title(questions_title(), [
|
||||
msg(),
|
||||
heading(_("Open questions"), 2),
|
||||
heading(_('Open questions'), 2),
|
||||
table([
|
||||
'Question' => _("Question"),
|
||||
'actions' => ""
|
||||
'Question' => _('Question'),
|
||||
'actions' => ''
|
||||
], $open_questions),
|
||||
heading(_("Answered questions"), 2),
|
||||
heading(_('Answered questions'), 2),
|
||||
table([
|
||||
'Question' => _("Question"),
|
||||
'answer_user' => _("Answered by"),
|
||||
'Answer' => _("Answer"),
|
||||
'actions' => ""
|
||||
'Question' => _('Question'),
|
||||
'answer_user' => _('Answered by'),
|
||||
'Answer' => _('Answer'),
|
||||
'actions' => ''
|
||||
], $answered_questions),
|
||||
heading(_("Ask the Heaven"), 2),
|
||||
heading(_('Ask the Heaven'), 2),
|
||||
form([
|
||||
form_textarea('question', _("Your Question:"), ""),
|
||||
form_submit('submit', _("Save"))
|
||||
form_textarea('question', _('Your Question:'), ''),
|
||||
form_submit('submit', _('Save'))
|
||||
], $ask_action)
|
||||
]);
|
||||
}
|
||||
|
||||
?>
|
||||
@ -1,20 +1,30 @@
|
||||
<?php
|
||||
use Engelsystem\ShiftsFilterRenderer;
|
||||
use Engelsystem\ShiftCalendarRenderer;
|
||||
use Engelsystem\ShiftsFilterRenderer;
|
||||
|
||||
function Room_view($room, ShiftsFilterRenderer $shiftsFilterRenderer, ShiftCalendarRenderer $shiftCalendarRenderer) {
|
||||
/**
|
||||
* @param array $room
|
||||
* @param ShiftsFilterRenderer $shiftsFilterRenderer
|
||||
* @param ShiftCalendarRenderer $shiftCalendarRenderer
|
||||
* @return string
|
||||
*/
|
||||
function Room_view($room, ShiftsFilterRenderer $shiftsFilterRenderer, ShiftCalendarRenderer $shiftCalendarRenderer)
|
||||
{
|
||||
return page_with_title(glyph('map-marker') . $room['Name'], [
|
||||
$shiftsFilterRenderer->render(room_link($room)) ,
|
||||
$shiftsFilterRenderer->render(room_link($room)),
|
||||
$shiftCalendarRenderer->render()
|
||||
]);
|
||||
}
|
||||
|
||||
function Room_name_render($room) {
|
||||
/**
|
||||
* @param array $room
|
||||
* @return string
|
||||
*/
|
||||
function Room_name_render($room)
|
||||
{
|
||||
global $privileges;
|
||||
if (in_array('view_rooms', $privileges)) {
|
||||
return '<a href="' . room_link($room) . '">' . glyph('map-marker') . $room['Name'] . '</a>';
|
||||
}
|
||||
return glyph('map-marker') . $room['Name'];
|
||||
}
|
||||
|
||||
?>
|
||||
@ -1,88 +1,164 @@
|
||||
<?php
|
||||
|
||||
function UserAngelType_update_view($user_angeltype, $user, $angeltype, $supporter) {
|
||||
return page_with_title($supporter ? _("Add supporter rights") : _("Remove supporter rights"), [
|
||||
/**
|
||||
* @param array $user_angeltype
|
||||
* @param array $user
|
||||
* @param array $angeltype
|
||||
* @param bool $supporter
|
||||
* @return string
|
||||
*/
|
||||
function UserAngelType_update_view($user_angeltype, $user, $angeltype, $supporter)
|
||||
{
|
||||
return page_with_title($supporter ? _('Add supporter rights') : _('Remove supporter rights'), [
|
||||
msg(),
|
||||
info(sprintf($supporter ? _("Do you really want to add supporter rights for %s to %s?") : _("Do you really want to remove supporter rights for %s from %s?"), $angeltype['name'], User_Nick_render($user)), true),
|
||||
info(sprintf(
|
||||
$supporter
|
||||
? _('Do you really want to add supporter rights for %s to %s?')
|
||||
: _('Do you really want to remove supporter rights for %s from %s?'),
|
||||
$angeltype['name'],
|
||||
User_Nick_render($user)
|
||||
), true),
|
||||
buttons([
|
||||
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
|
||||
button(page_link_to('user_angeltypes') . '&action=update&user_angeltype_id=' . $user_angeltype['id'] . '&supporter=' . ($supporter ? '1' : '0') . '&confirmed', _("yes"), 'ok')
|
||||
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _('cancel'), 'cancel'),
|
||||
button(
|
||||
page_link_to('user_angeltypes')
|
||||
. '&action=update&user_angeltype_id=' . $user_angeltype['id']
|
||||
. '&supporter=' . ($supporter ? '1' : '0')
|
||||
. '&confirmed',
|
||||
_('yes'),
|
||||
'ok'
|
||||
)
|
||||
])
|
||||
]);
|
||||
}
|
||||
|
||||
function UserAngelTypes_delete_all_view($angeltype) {
|
||||
return page_with_title(_("Deny all users"), [
|
||||
/**
|
||||
* @param array $angeltype
|
||||
* @return string
|
||||
*/
|
||||
function UserAngelTypes_delete_all_view($angeltype)
|
||||
{
|
||||
return page_with_title(_('Deny all users'), [
|
||||
msg(),
|
||||
info(sprintf(_("Do you really want to deny all users for %s?"), $angeltype['name']), true),
|
||||
info(sprintf(_('Do you really want to deny all users for %s?'), $angeltype['name']), true),
|
||||
buttons([
|
||||
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
|
||||
button(page_link_to('user_angeltypes') . '&action=delete_all&angeltype_id=' . $angeltype['id'] . '&confirmed', _("yes"), 'ok')
|
||||
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _('cancel'), 'cancel'),
|
||||
button(
|
||||
page_link_to('user_angeltypes') . '&action=delete_all&angeltype_id=' . $angeltype['id'] . '&confirmed',
|
||||
_('yes'),
|
||||
'ok'
|
||||
)
|
||||
])
|
||||
]);
|
||||
}
|
||||
|
||||
function UserAngelTypes_confirm_all_view($angeltype) {
|
||||
return page_with_title(_("Confirm all users"), [
|
||||
/**
|
||||
* @param array $angeltype
|
||||
* @return string
|
||||
*/
|
||||
function UserAngelTypes_confirm_all_view($angeltype)
|
||||
{
|
||||
return page_with_title(_('Confirm all users'), [
|
||||
msg(),
|
||||
info(sprintf(_("Do you really want to confirm all users for %s?"), $angeltype['name']), true),
|
||||
info(sprintf(_('Do you really want to confirm all users for %s?'), $angeltype['name']), true),
|
||||
buttons([
|
||||
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
|
||||
button(page_link_to('user_angeltypes') . '&action=confirm_all&angeltype_id=' . $angeltype['id'] . '&confirmed', _("yes"), 'ok')
|
||||
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _('cancel'), 'cancel'),
|
||||
button(
|
||||
page_link_to('user_angeltypes') . '&action=confirm_all&angeltype_id=' . $angeltype['id'] . '&confirmed',
|
||||
_('yes'),
|
||||
'ok'
|
||||
)
|
||||
])
|
||||
]);
|
||||
}
|
||||
|
||||
function UserAngelType_confirm_view($user_angeltype, $user, $angeltype) {
|
||||
return page_with_title(_("Confirm angeltype for user"), [
|
||||
/**
|
||||
* @param array $user_angeltype
|
||||
* @param array $user
|
||||
* @param array $angeltype
|
||||
* @return string
|
||||
*/
|
||||
function UserAngelType_confirm_view($user_angeltype, $user, $angeltype)
|
||||
{
|
||||
return page_with_title(_('Confirm angeltype for user'), [
|
||||
msg(),
|
||||
info(sprintf(_("Do you really want to confirm %s for %s?"), User_Nick_render($user), $angeltype['name']), true),
|
||||
info(sprintf(_('Do you really want to confirm %s for %s?'), User_Nick_render($user), $angeltype['name']), true),
|
||||
buttons([
|
||||
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
|
||||
button(page_link_to('user_angeltypes') . '&action=confirm&user_angeltype_id=' . $user_angeltype['id'] . '&confirmed', _("yes"), 'ok')
|
||||
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _('cancel'), 'cancel'),
|
||||
button(
|
||||
page_link_to('user_angeltypes') . '&action=confirm&user_angeltype_id=' . $user_angeltype['id'] . '&confirmed',
|
||||
_('yes'),
|
||||
'ok'
|
||||
)
|
||||
])
|
||||
]);
|
||||
}
|
||||
|
||||
function UserAngelType_delete_view($user_angeltype, $user, $angeltype) {
|
||||
return page_with_title(_("Remove angeltype"), [
|
||||
/**
|
||||
* @param array $user_angeltype
|
||||
* @param array $user
|
||||
* @param array $angeltype
|
||||
* @return string
|
||||
*/
|
||||
function UserAngelType_delete_view($user_angeltype, $user, $angeltype)
|
||||
{
|
||||
return page_with_title(_('Remove angeltype'), [
|
||||
msg(),
|
||||
info(sprintf(_("Do you really want to delete %s from %s?"), User_Nick_render($user), $angeltype['name']), true),
|
||||
info(sprintf(_('Do you really want to delete %s from %s?'), User_Nick_render($user), $angeltype['name']), true),
|
||||
buttons([
|
||||
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
|
||||
button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $user_angeltype['id'] . '&confirmed', _("yes"), 'ok')
|
||||
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _('cancel'), 'cancel'),
|
||||
button(
|
||||
page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $user_angeltype['id'] . '&confirmed',
|
||||
_('yes'),
|
||||
'ok'
|
||||
)
|
||||
])
|
||||
]);
|
||||
}
|
||||
|
||||
function UserAngelType_add_view($angeltype, $users_source, $user_id) {
|
||||
/**
|
||||
* @param array $angeltype
|
||||
* @param array[] $users_source
|
||||
* @param int $user_id
|
||||
* @return string
|
||||
*/
|
||||
function UserAngelType_add_view($angeltype, $users_source, $user_id)
|
||||
{
|
||||
$users = [];
|
||||
foreach ($users_source as $user_source) {
|
||||
$users[$user_source['UID']] = User_Nick_render($user_source);
|
||||
}
|
||||
|
||||
return page_with_title(_("Add user to angeltype"), [
|
||||
return page_with_title(_('Add user to angeltype'), [
|
||||
msg(),
|
||||
buttons([
|
||||
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("back"), 'back')
|
||||
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _('back'), 'back')
|
||||
]),
|
||||
form([
|
||||
form_info(_("Angeltype"), $angeltype['name']),
|
||||
form_select('user_id', _("User"), $users, $user_id),
|
||||
form_submit('submit', _("Add"))
|
||||
form_info(_('Angeltype'), $angeltype['name']),
|
||||
form_select('user_id', _('User'), $users, $user_id),
|
||||
form_submit('submit', _('Add'))
|
||||
])
|
||||
]);
|
||||
}
|
||||
|
||||
function UserAngelType_join_view($user, $angeltype) {
|
||||
return page_with_title(sprintf(_("Become a %s"), $angeltype['name']), [
|
||||
/**
|
||||
* @param array $user
|
||||
* @param array $angeltype
|
||||
* @return string
|
||||
*/
|
||||
function UserAngelType_join_view($user, $angeltype)
|
||||
{
|
||||
return page_with_title(sprintf(_('Become a %s'), $angeltype['name']), [
|
||||
msg(),
|
||||
info(sprintf(_("Do you really want to add %s to %s?"), User_Nick_render($user), $angeltype['name']), true),
|
||||
info(sprintf(_('Do you really want to add %s to %s?'), User_Nick_render($user), $angeltype['name']), true),
|
||||
buttons([
|
||||
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
|
||||
button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'] . '&user_id=' . $user['UID'] . '&confirmed', _("save"), 'ok')
|
||||
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _('cancel'), 'cancel'),
|
||||
button(
|
||||
page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'] . '&user_id=' . $user['UID'] . '&confirmed',
|
||||
_('save'),
|
||||
'ok'
|
||||
)
|
||||
])
|
||||
]);
|
||||
}
|
||||
|
||||
?>
|
||||
@ -1 +1 @@
|
||||
../../themes/assets/bootstrap/dist
|
||||
../../vendor/twbs/bootstrap/dist
|
||||
@ -0,0 +1,128 @@
|
||||
<?php
|
||||
|
||||
namespace Engelsystem\Config;
|
||||
|
||||
use ErrorException;
|
||||
|
||||
class Config
|
||||
{
|
||||
/**
|
||||
* @var self
|
||||
*/
|
||||
protected static $instance;
|
||||
|
||||
/**
|
||||
* The config values
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $data = [];
|
||||
|
||||
/**
|
||||
* @param string|null $key
|
||||
* @param mixed $default
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($key, $default = null)
|
||||
{
|
||||
if (is_null($key)) {
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
if ($this->has($key)) {
|
||||
return $this->data[$key];
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|array $key
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function set($key, $value = null)
|
||||
{
|
||||
if (is_array($key)) {
|
||||
foreach ($key as $configKey => $configValue) {
|
||||
$this->set($configKey, $configValue);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->data[$key] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public function has($key)
|
||||
{
|
||||
return isset($this->data[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
*/
|
||||
public function remove($key)
|
||||
{
|
||||
unset($this->data[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get($key)
|
||||
{
|
||||
return $this->get($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function __set($key, $value)
|
||||
{
|
||||
$this->set($key, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public function __isset($key)
|
||||
{
|
||||
return $this->has($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
*/
|
||||
public function __unset($key)
|
||||
{
|
||||
$this->remove($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Config
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
if (!self::$instance instanceof self) {
|
||||
throw new ErrorException('Config not initialized');
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param self $instance
|
||||
*/
|
||||
public static function setInstance($instance)
|
||||
{
|
||||
self::$instance = $instance;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,170 @@
|
||||
<?php
|
||||
|
||||
namespace Engelsystem\Database;
|
||||
|
||||
use PDO;
|
||||
use PDOException;
|
||||
use PDOStatement;
|
||||
|
||||
class Db
|
||||
{
|
||||
/** @var PDO */
|
||||
protected static $db;
|
||||
|
||||
/** @var PDOStatement */
|
||||
protected static $stm = null;
|
||||
|
||||
/** @var bool */
|
||||
protected static $lastStatus = true;
|
||||
|
||||
/**
|
||||
* Connect to database
|
||||
*
|
||||
* @param string $dsn
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @param array $options
|
||||
* @return bool
|
||||
*/
|
||||
public static function connect($dsn, $username = null, $password = null, $options = [])
|
||||
{
|
||||
try {
|
||||
self::$db = new PDO($dsn, $username, $password, $options);
|
||||
} catch (PDOException $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a prepared query
|
||||
*
|
||||
* @param string $query
|
||||
* @param array $bindings
|
||||
* @return PDOStatement
|
||||
*/
|
||||
public static function query($query, array $bindings = [])
|
||||
{
|
||||
self::$stm = self::$db->prepare($query);
|
||||
self::$lastStatus = self::$stm->execute($bindings);
|
||||
|
||||
return self::$stm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a sql query
|
||||
*
|
||||
* @param string $query
|
||||
* @return bool
|
||||
*/
|
||||
public static function unprepared($query)
|
||||
{
|
||||
self::$stm = self::$db->query($query);
|
||||
self::$lastStatus = (self::$stm instanceof PDOStatement);
|
||||
|
||||
return self::$lastStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a select query
|
||||
*
|
||||
* @param string $query
|
||||
* @param array $bindings
|
||||
* @return array
|
||||
*/
|
||||
public static function select($query, array $bindings = [])
|
||||
{
|
||||
self::query($query, $bindings);
|
||||
|
||||
return self::$stm->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a insert query
|
||||
*
|
||||
* @param string $query
|
||||
* @param array $bindings
|
||||
* @return bool
|
||||
*/
|
||||
public static function insert($query, array $bindings = [])
|
||||
{
|
||||
self::query($query, $bindings);
|
||||
|
||||
return self::$lastStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a update query
|
||||
*
|
||||
* @param string $query
|
||||
* @param array $bindings
|
||||
* @return int|null
|
||||
*/
|
||||
public static function update($query, array $bindings = [])
|
||||
{
|
||||
self::query($query, $bindings);
|
||||
|
||||
return (self::$lastStatus ? self::$stm->rowCount() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a delete query
|
||||
*
|
||||
* @param string $query
|
||||
* @param array $bindings
|
||||
* @return int|null
|
||||
*/
|
||||
public static function delete($query, array $bindings = [])
|
||||
{
|
||||
self::query($query, $bindings);
|
||||
|
||||
return (self::$lastStatus ? self::$stm->rowCount() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a single statement
|
||||
*
|
||||
* @param string $query
|
||||
* @param array $bindings
|
||||
* @return bool
|
||||
*/
|
||||
public static function statement($query, array $bindings = [])
|
||||
{
|
||||
self::query($query, $bindings);
|
||||
|
||||
return self::$lastStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last error
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getError()
|
||||
{
|
||||
if (!self::$stm instanceof PDOStatement) {
|
||||
return [-1, null, null];
|
||||
}
|
||||
|
||||
return self::$stm->errorInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the PDO instance
|
||||
*
|
||||
* @return PDO
|
||||
*/
|
||||
public static function getPdo()
|
||||
{
|
||||
return self::$db;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PDOStatement|false|null
|
||||
*/
|
||||
public static function getStm()
|
||||
{
|
||||
return self::$stm;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace Engelsystem\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class Handler
|
||||
{
|
||||
/** @var string */
|
||||
protected $environment;
|
||||
|
||||
const ENV_PRODUCTION = 'prod';
|
||||
const ENV_DEVELOPMENT = 'dev';
|
||||
|
||||
/**
|
||||
* Handler constructor.
|
||||
*
|
||||
* @param string $environment production|development
|
||||
*/
|
||||
public function __construct($environment = self::ENV_PRODUCTION)
|
||||
{
|
||||
$this->environment = $environment;
|
||||
|
||||
set_error_handler([$this, 'errorHandler']);
|
||||
set_exception_handler([$this, 'exceptionHandler']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $number
|
||||
* @param string $string
|
||||
* @param string $file
|
||||
* @param int $line
|
||||
* @param array $context
|
||||
*/
|
||||
public function errorHandler($number, $string, $file, $line, $context)
|
||||
{
|
||||
$this->handle('error', $number, $string, $file, $line, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Exception $e
|
||||
*/
|
||||
public function exceptionHandler(Exception $e)
|
||||
{
|
||||
$this->handle(
|
||||
'exception',
|
||||
$e->getCode(),
|
||||
get_class($e) . ': ' . $e->getMessage(),
|
||||
$e->getFile(),
|
||||
$e->getLine(),
|
||||
['exception' => $e]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
* @param int $number
|
||||
* @param string $string
|
||||
* @param string $file
|
||||
* @param int $line
|
||||
* @param array $context
|
||||
*/
|
||||
protected function handle($type, $number, $string, $file, $line, $context = [])
|
||||
{
|
||||
error_log(sprintf('%s: Number: %s, String: %s, File: %s:%u, Context: %s',
|
||||
$type,
|
||||
$number,
|
||||
$string,
|
||||
$file,
|
||||
$line,
|
||||
json_encode($context)
|
||||
));
|
||||
|
||||
if ($this->environment == self::ENV_DEVELOPMENT) {
|
||||
echo '<pre style="background-color:#333;color:#ccc;z-index:1000;position:fixed;bottom:1em;padding:1em;width:97%;overflow-y:auto;">';
|
||||
echo sprintf('%s: (%s)' . PHP_EOL, ucfirst($type), $number);
|
||||
var_export([
|
||||
'string' => $string,
|
||||
'file' => $file . ':' . $line,
|
||||
'context' => ($this->environment == self::ENV_DEVELOPMENT ? $context : null),
|
||||
]);
|
||||
echo '</pre>';
|
||||
die();
|
||||
}
|
||||
|
||||
echo 'An <del>un</del>expected error occurred, a team of untrained monkeys has been dispatched to deal with it.';
|
||||
die();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $environment
|
||||
*/
|
||||
public function setEnvironment($environment)
|
||||
{
|
||||
$this->environment = $environment;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
// Some useful functions
|
||||
|
||||
use Engelsystem\Config\Config;
|
||||
|
||||
/**
|
||||
* Get or set config values
|
||||
*
|
||||
* @param string|array $key
|
||||
* @param mixed $default
|
||||
* @return mixed|Config
|
||||
*/
|
||||
function config($key = null, $default = null)
|
||||
{
|
||||
if (empty($key)) {
|
||||
return Config::getInstance();
|
||||
}
|
||||
|
||||
if (is_array($key)) {
|
||||
Config::getInstance()->set($key);
|
||||
}
|
||||
|
||||
return Config::getInstance()->get($key, $default);
|
||||
}
|
||||
@ -1,53 +1,60 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>%title% - Engelsystem</title>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" type="text/css" href="css/theme%theme%.css" />
|
||||
<link rel="stylesheet" type="text/css" href="vendor/icomoon/style.css" />
|
||||
<link rel="stylesheet" type="text/css" href="vendor/bootstrap-datepicker-1.4.0/css/bootstrap-datepicker3.min.css" />
|
||||
<script type="text/javascript" src="vendor/jquery-2.1.1.min.js"></script>
|
||||
<script type="text/javascript" src="vendor/jquery-ui.min.js"></script>
|
||||
%atom_link%
|
||||
<title>%title% - Engelsystem</title>
|
||||
<meta charset="UTF-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" type="text/css" href="css/theme%theme%.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="vendor/icomoon/style.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="vendor/bootstrap-datepicker-1.4.0/css/bootstrap-datepicker3.min.css"/>
|
||||
<script type="text/javascript" src="vendor/jquery-2.1.1.min.js"></script>
|
||||
<script type="text/javascript" src="vendor/jquery-ui.min.js"></script>
|
||||
%atom_link%
|
||||
</head>
|
||||
<body>
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="container-fluid">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse-1">
|
||||
<span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span>
|
||||
<button type="button" class="navbar-toggle collapsed"
|
||||
data-toggle="collapse" data-target="#navbar-collapse-1">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="?"><span class="icon-icon_angel"></span> <strong class="visible-lg-inline">ENGELSYSTEM</strong></a>
|
||||
</div>
|
||||
<div class="collapse navbar-collapse" id="navbar-collapse-1">%menu% %header_toolbar%</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container-fluid">
|
||||
</div>
|
||||
<div class="container-fluid">
|
||||
<div class="row">%content%</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<hr />
|
||||
<hr/>
|
||||
<div class="text-center footer" style="margin-bottom: 10px;">
|
||||
%event_info%
|
||||
<a href="%faq_url%">FAQ</a> · <a href="%contact_email%"><span class="glyphicon glyphicon-envelope"></span> Contact</a> · <a href="https://github.com/engelsystem/engelsystem/issues">Bugs / Features</a> · <a href="https://github.com/engelsystem/engelsystem/">Development
|
||||
Platform</a> · <a href="?p=credits">Credits</a>
|
||||
</div>
|
||||
<a href="%faq_url%">FAQ</a>
|
||||
· <a href="%contact_email%"><span class="glyphicon glyphicon-envelope"></span> Contact</a>
|
||||
· <a href="https://github.com/engelsystem/engelsystem/issues">Bugs / Features</a>
|
||||
· <a href="https://github.com/engelsystem/engelsystem/">Development Platform</a>
|
||||
· <a href="?p=credits">Credits</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript" src="vendor/bootstrap/js/bootstrap.min.js"></script>
|
||||
<script type="text/javascript" src="vendor/bootstrap-datepicker-1.4.0/js/bootstrap-datepicker.min.js"></script>
|
||||
<script type="text/javascript" src="vendor/bootstrap-datepicker-1.4.0/locales/bootstrap-datepicker.de.min.js"></script>
|
||||
<script type="text/javascript" src="vendor/Chart.min.js"></script>
|
||||
<script type="text/javascript" src="js/forms.js"></script>
|
||||
<script type="text/javascript" src="vendor/moment-with-locales.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
</div>
|
||||
<script type="text/javascript" src="vendor/bootstrap/js/bootstrap.min.js"></script>
|
||||
<script type="text/javascript" src="vendor/bootstrap-datepicker-1.4.0/js/bootstrap-datepicker.min.js"></script>
|
||||
<script type="text/javascript" src="vendor/bootstrap-datepicker-1.4.0/locales/bootstrap-datepicker.de.min.js"></script>
|
||||
<script type="text/javascript" src="vendor/Chart.min.js"></script>
|
||||
<script type="text/javascript" src="js/forms.js"></script>
|
||||
<script type="text/javascript" src="vendor/moment-with-locales.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
moment.locale("%locale%");
|
||||
});
|
||||
</script>
|
||||
<script type="text/javascript" src="js/moment-countdown.js"></script>
|
||||
<script type="text/javascript" src="js/sticky-headers.js"></script>
|
||||
</script>
|
||||
<script type="text/javascript" src="js/moment-countdown.js"></script>
|
||||
<script type="text/javascript" src="js/sticky-headers.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue