Merge branch 'dev'
This commit is contained in:
commit
caeadadb27
|
@ -2,3 +2,5 @@ includes_old
|
|||
www-ssl_old
|
||||
.project
|
||||
.buildpath
|
||||
.*.swp
|
||||
_vimrc_local.vim
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
if(sql_num_query("SHOW TABLES LIKE 'LogEntries'") == 0) {
|
||||
sql_query("CREATE TABLE `LogEntries` (
|
||||
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
|
||||
`timestamp` INT NOT NULL ,
|
||||
`nick` VARCHAR( 23 ) NOT NULL ,
|
||||
`message` TEXT NOT NULL ,
|
||||
INDEX ( `timestamp` )
|
||||
) ENGINE = InnoDB;");
|
||||
$applied = true;
|
||||
}
|
||||
|
||||
if(sql_num_query("SHOW TABLES LIKE 'ChangeLog'") == 0) {
|
||||
sql_query("DROP TABLE `ChangeLog`");
|
||||
$applied = true;
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,4 @@
|
|||
<?php
|
||||
mysql_query("INSERT IGNORE INTO `Privileges` (`name`, `desc`) VALUES ('atom', ' Atom news export')");
|
||||
$applied = mysql_affected_rows() > 0;
|
||||
?>
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Creates a log entry.
|
||||
* @param $nick Username
|
||||
* @param $message Log Message
|
||||
*/
|
||||
function LogEntry_create($nick, $message) {
|
||||
$timestamp = time();
|
||||
|
||||
sql_query("INSERT INTO `LogEntries` SET `timestamp`=" . sql_escape($timestamp) . ", `nick`='" . sql_escape($nick) . "', `message`='" . sql_escape($message) . "'");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns log entries of the last 24 hours with maximum count of 1000.
|
||||
*/
|
||||
function LogEntries() {
|
||||
$log_entries_source = sql_select("SELECT * FROM `LogEntries` WHERE `timestamp` > " . (time() - 24*60*60) . " ORDER BY `timestamp` DESC LIMIT 1000");
|
||||
return $log_entries_source;
|
||||
}
|
||||
|
||||
|
||||
?>
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Returns user by id.
|
||||
* @param $id UID
|
||||
*/
|
||||
function User($id) {
|
||||
$user_source = sql_select("SELECT * FROM `User` WHERE `UID`=" . sql_escape($id) . " LIMIT 1");
|
||||
if(count($user_source) > 0)
|
||||
return $user_source[0];
|
||||
return null;
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
function admin_active() {
|
||||
global $tshirt_sizes;
|
||||
global $tshirt_sizes, $shift_sum_formula;
|
||||
|
||||
$msg = "";
|
||||
$search = "";
|
||||
|
@ -24,9 +24,13 @@ function admin_active() {
|
|||
$limit = " LIMIT " . $count;
|
||||
if (isset ($_REQUEST['ack'])) {
|
||||
sql_query("UPDATE `User` SET `Aktiv` = 0 WHERE `Tshirt` = 0");
|
||||
$users = sql_select("SELECT `User`.*, COUNT(`ShiftEntry`.`id`) as `shift_count`, SUM(`end`-`start`) as `shift_length` FROM `User` LEFT JOIN `ShiftEntry` ON `User`.`UID` = `ShiftEntry`.`UID` LEFT JOIN `Shifts` ON `ShiftEntry`.`SID` = `Shifts`.`SID` WHERE `User`.`Gekommen` = 1 GROUP BY `User`.`UID` ORDER BY `shift_length` DESC" . $limit);
|
||||
foreach ($users as $usr)
|
||||
$users = sql_select("SELECT `User`.*, COUNT(`ShiftEntry`.`id`) as `shift_count`, ${shift_sum_formula} as `shift_length` FROM `User` LEFT JOIN `ShiftEntry` ON `User`.`UID` = `ShiftEntry`.`UID` LEFT JOIN `Shifts` ON `ShiftEntry`.`SID` = `Shifts`.`SID` WHERE `User`.`Gekommen` = 1 GROUP BY `User`.`UID` ORDER BY `shift_length` DESC" . $limit);
|
||||
$user_nicks = array();
|
||||
foreach ($users as $usr) {
|
||||
sql_query("UPDATE `User` SET `Aktiv` = 1 WHERE `UID`=" . sql_escape($usr['UID']));
|
||||
$user_nicks[] = $usr['Nick'];
|
||||
}
|
||||
engelsystem_log("These angels are active now: " . join(", ", $user_nicks));
|
||||
|
||||
$limit = "";
|
||||
$msg = success("Marked angels.", true);
|
||||
|
@ -37,26 +41,46 @@ function admin_active() {
|
|||
|
||||
if (isset ($_REQUEST['active']) && preg_match("/^[0-9]+$/", $_REQUEST['active'])) {
|
||||
$id = $_REQUEST['active'];
|
||||
$user_source = User($id);
|
||||
if($user_source != null) {
|
||||
sql_query("UPDATE `User` SET `Aktiv`=1 WHERE `UID`=" . sql_escape($id) . " LIMIT 1");
|
||||
engelsystem_log("User " . $user_source['Nick'] . " is active now.");
|
||||
$msg = success("Angel has been marked as active.", true);
|
||||
}
|
||||
else $msg = error("Angel not found.", true);
|
||||
}
|
||||
elseif (isset ($_REQUEST['not_active']) && preg_match("/^[0-9]+$/", $_REQUEST['not_active'])) {
|
||||
$id = $_REQUEST['not_active'];
|
||||
$user_source = User($id);
|
||||
if($user_source != null) {
|
||||
sql_query("UPDATE `User` SET `Aktiv`=0 WHERE `UID`=" . sql_escape($id) . " LIMIT 1");
|
||||
engelsystem_log("User " . $user_source['Nick'] . " is NOT active now.");
|
||||
$msg = success("Angel has been marked as not active.", true);
|
||||
}
|
||||
else $msg = error("Angel not found.", true);
|
||||
}
|
||||
elseif (isset ($_REQUEST['tshirt']) && preg_match("/^[0-9]+$/", $_REQUEST['tshirt'])) {
|
||||
$id = $_REQUEST['tshirt'];
|
||||
$user_source = User($id);
|
||||
if($user_source != null) {
|
||||
sql_query("UPDATE `User` SET `Tshirt`=1 WHERE `UID`=" . sql_escape($id) . " LIMIT 1");
|
||||
engelsystem_log("User " . $user_source['Nick'] . " has tshirt now.");
|
||||
$msg = success("Angel has got a t-shirt.", true);
|
||||
}
|
||||
else $msg = error("Angel not found.", true);
|
||||
}
|
||||
elseif (isset ($_REQUEST['not_tshirt']) && preg_match("/^[0-9]+$/", $_REQUEST['not_tshirt'])) {
|
||||
$id = $_REQUEST['not_tshirt'];
|
||||
$user_source = User($id);
|
||||
if($user_source != null) {
|
||||
sql_query("UPDATE `User` SET `Tshirt`=0 WHERE `UID`=" . sql_escape($id) . " LIMIT 1");
|
||||
engelsystem_log("User " . $user_source['Nick'] . " NO tshirt.");
|
||||
$msg = success("Angel has got no t-shirt.", true);
|
||||
}
|
||||
else $msg = error("Angel not found.", true);
|
||||
}
|
||||
|
||||
$users = sql_select("SELECT `User`.*, COUNT(`ShiftEntry`.`id`) as `shift_count`, SUM(`end`-`start`) as `shift_length` FROM `User` LEFT JOIN `ShiftEntry` ON `User`.`UID` = `ShiftEntry`.`UID` LEFT JOIN `Shifts` ON `ShiftEntry`.`SID` = `Shifts`.`SID` WHERE `User`.`Gekommen` = 1 GROUP BY `User`.`UID` ORDER BY `shift_length` DESC" . $limit);
|
||||
$users = sql_select("SELECT `User`.*, COUNT(`ShiftEntry`.`id`) as `shift_count`, ${shift_sum_formula} as `shift_length` FROM `User` LEFT JOIN `ShiftEntry` ON `User`.`UID` = `ShiftEntry`.`UID` LEFT JOIN `Shifts` ON `ShiftEntry`.`SID` = `Shifts`.`SID` WHERE `User`.`Gekommen` = 1 GROUP BY `User`.`UID` ORDER BY `shift_length` DESC" . $limit);
|
||||
|
||||
$table = "";
|
||||
if ($search == "")
|
||||
|
|
|
@ -47,10 +47,13 @@ function admin_angel_types() {
|
|||
$restricted = 0;
|
||||
|
||||
if ($ok) {
|
||||
if (isset ($id))
|
||||
if (isset ($id)) {
|
||||
sql_query("UPDATE `AngelTypes` SET `name`='" . sql_escape($name) . "', `restricted`=" . sql_escape($restricted) . " WHERE `id`=" . sql_escape($id) . " LIMIT 1");
|
||||
else
|
||||
engelsystem_log("Updated angeltype: " . $name . ", restricted: " . $restricted);
|
||||
} else {
|
||||
sql_query("INSERT INTO `AngelTypes` SET `name`='" . sql_escape($name) . "', `restricted`=" . sql_escape($restricted));
|
||||
engelsystem_log("Created angeltype: " . $name . ", restricted: " . $restricted);
|
||||
}
|
||||
|
||||
success("Angel type saved.");
|
||||
redirect(page_link_to('admin_angel_types'));
|
||||
|
@ -76,6 +79,7 @@ function admin_angel_types() {
|
|||
sql_query("DELETE FROM `ShiftEntry` WHERE `TID`=" . sql_escape($id) . " LIMIT 1");
|
||||
sql_query("DELETE FROM `AngelTypes` WHERE `id`=" . sql_escape($id) . " LIMIT 1");
|
||||
sql_query("DELETE FROM `UserAngelTypes` WHERE `angeltype_id`=" . sql_escape($id) . " LIMIT 1");
|
||||
engelsystem_log("Deleted angel type: " . $name);
|
||||
success(sprintf("Angel type %s deleted.", $name));
|
||||
redirect(page_link_to('admin_angel_types'));
|
||||
}
|
||||
|
|
|
@ -7,13 +7,21 @@ function admin_arrive() {
|
|||
|
||||
if (isset ($_REQUEST['reset']) && preg_match("/^[0-9]*$/", $_REQUEST['reset'])) {
|
||||
$id = $_REQUEST['reset'];
|
||||
$user_source = User($id);
|
||||
if($user_source != null) {
|
||||
sql_query("UPDATE `User` SET `Gekommen`=0 WHERE `UID`=" . sql_escape($id) . " LIMIT 1");
|
||||
engelsystem_log("User set to not arrived: " . $user_source['Nick']);
|
||||
$msg = success("Reset done. Angel has not arrived.", true);
|
||||
} else $msg = error("Angel not found.", true);
|
||||
}
|
||||
elseif (isset ($_REQUEST['arrived']) && preg_match("/^[0-9]*$/", $_REQUEST['arrived'])) {
|
||||
$id = $_REQUEST['arrived'];
|
||||
$user_source = User($id);
|
||||
if($user_source != null) {
|
||||
sql_query("UPDATE `User` SET `Gekommen`=1 WHERE `UID`=" . sql_escape($id) . " LIMIT 1");
|
||||
engelsystem_log("User set has arrived: " . $user_source['Nick']);
|
||||
$msg = success("Angel has been marked as arrived.", true);
|
||||
} else $msg = error("Angel not found.", true);
|
||||
}
|
||||
|
||||
$users = sql_select("SELECT * FROM `User` ORDER BY `Nick`");
|
||||
|
|
|
@ -6,7 +6,22 @@ function admin_free() {
|
|||
if (isset ($_REQUEST['search']))
|
||||
$search = strip_request_item('search');
|
||||
|
||||
$users = sql_select("SELECT `User`.* FROM `User` LEFT JOIN `ShiftEntry` ON `User`.`UID` = `ShiftEntry`.`UID` LEFT JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID` AND `Shifts`.`start` < " . sql_escape(time()) . " AND `Shifts`.`end` > " . sql_escape(time()) . ") WHERE `User`.`Gekommen` = 1 AND `Shifts`.`SID` IS NULL GROUP BY `User`.`UID` ORDER BY `Nick`");
|
||||
$angeltypesearch = "";
|
||||
if (empty ($_REQUEST['angeltype']))
|
||||
$_REQUEST['angeltype'] = '';
|
||||
else {
|
||||
$angeltypesearch = " INNER JOIN `UserAngelTypes` ON (`UserAngelTypes`.`angeltype_id` = '" . sql_escape($_REQUEST['angeltype']) . "' AND `UserAngelTypes`.`user_id` = `User`.`UID`";
|
||||
if (isset ($_REQUEST['confirmed_only']))
|
||||
$angeltypesearch .= " AND `UserAngelTypes`.`confirm_user_id`";
|
||||
$angeltypesearch .= ") ";
|
||||
}
|
||||
|
||||
$angel_types_source = sql_select("SELECT `id`, `name` FROM `AngelTypes` ORDER BY `name`");
|
||||
$angel_types = array('' => 'alle Typen');
|
||||
foreach ($angel_types_source as $angel_type)
|
||||
$angel_types[$angel_type['id']] = $angel_type['name'];
|
||||
|
||||
$users = sql_select("SELECT `User`.* FROM `User` ${angeltypesearch} LEFT JOIN `ShiftEntry` ON `User`.`UID` = `ShiftEntry`.`UID` LEFT JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID` AND `Shifts`.`start` < " . sql_escape(time()) . " AND `Shifts`.`end` > " . sql_escape(time()) . ") WHERE `User`.`Gekommen` = 1 AND `Shifts`.`SID` IS NULL GROUP BY `User`.`UID` ORDER BY `Nick`");
|
||||
|
||||
$table = "";
|
||||
if ($search == "")
|
||||
|
@ -41,6 +56,8 @@ function admin_free() {
|
|||
}
|
||||
return template_render('../templates/admin_free.html', array (
|
||||
'search' => $search,
|
||||
'angeltypes' => html_select_key('angeltype', 'angeltype', $angel_types, $_REQUEST['angeltype']),
|
||||
'confirmed_only' => isset($_REQUEST['confirmed_only'])? 'checked' : '',
|
||||
'table' => $table,
|
||||
'link' => page_link_to('admin_free')
|
||||
));
|
||||
|
|
|
@ -77,9 +77,17 @@ function admin_groups() {
|
|||
if (count($room) > 0) {
|
||||
list ($room) = $room;
|
||||
sql_query("DELETE FROM `GroupPrivileges` WHERE `group_id`=" . sql_escape($id));
|
||||
foreach ($_REQUEST['privileges'] as $priv)
|
||||
if (preg_match("/^[0-9]{1,}$/", $priv) && sql_num_query("SELECT * FROM `Privileges` WHERE `id`=" . sql_escape($priv)) > 0)
|
||||
$privilege_names = array();
|
||||
foreach ($_REQUEST['privileges'] as $priv) {
|
||||
if (preg_match("/^[0-9]{1,}$/", $priv)) {
|
||||
$group_privileges_source = sql_select("SELECT * FROM `Privileges` WHERE `id`=" . sql_escape($priv) . " LIMIT 1");
|
||||
if(count($group_privileges_source) > 0) {
|
||||
sql_query("INSERT INTO `GroupPrivileges` SET `group_id`=" . sql_escape($id) . ", `privilege_id`=" . sql_escape($priv));
|
||||
$privilege_names[] = $group_privileges_source[0]['name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
engelsystem_log("Group privileges of group " . $room['Name'] . " edited: " . join(", ", $privilege_names));
|
||||
header("Location: " . page_link_to("admin_groups"));
|
||||
} else
|
||||
return error("No Group found.", true);
|
||||
|
|
|
@ -155,6 +155,8 @@ function admin_import() {
|
|||
sql_query("DELETE FROM `Shifts` WHERE `PSID`=" .
|
||||
sql_escape($event['PSID']) . " LIMIT 1");
|
||||
|
||||
engelsystem_log("Pentabarf import done");
|
||||
|
||||
unlink($import_file);
|
||||
|
||||
$html .= template_render('../templates/admin_import_import.html', array ());
|
||||
|
|
|
@ -1,76 +1,20 @@
|
|||
<?php
|
||||
function admin_log() {
|
||||
require_once ("includes/funktion_db_list.php");
|
||||
|
||||
$html = "";
|
||||
$SQL = "SELECT * FROM `ChangeLog` ORDER BY `Time` DESC LIMIT 0,10000";
|
||||
$Erg = sql_query($SQL);
|
||||
|
||||
if (mysql_num_rows($Erg) > 0) {
|
||||
$html .= "<table border=1>\n";
|
||||
$html .= "<tr>\n\t<th>Time</th>\n\t<th>User</th>\n\t<th>Commend</th>\n\t<th>SQL Command</th>\n</tr>\n";
|
||||
for ($n = 0; $n < mysql_num_rows($Erg); $n++) {
|
||||
$html .= "<tr>\n";
|
||||
$html .= "\t<td>" . mysql_result($Erg, $n, "Time") . "</td>\n";
|
||||
$html .= "\t<td>" . UID2Nick(mysql_result($Erg, $n, "UID")) . displayavatar(mysql_result($Erg, $n, "UID")) . "</td>\n";
|
||||
$html .= "\t<td>" . mysql_result($Erg, $n, "Commend") . "</td>\n";
|
||||
$html .= "\t<td>" . mysql_result($Erg, $n, "SQLCommad") . "</td>\n";
|
||||
$html .= "</tr>\n";
|
||||
$log_entries_source = LogEntries();
|
||||
$log_entries = array();
|
||||
foreach($log_entries_source as $log_entry) {
|
||||
$log_entry['date'] = date("H:i", $log_entry['timestamp']);
|
||||
$log_entries[] = $log_entry;
|
||||
}
|
||||
$html .= "</table>\n";
|
||||
} else {
|
||||
$html .= "Log is empty...";
|
||||
}
|
||||
$html .= "<hr />";
|
||||
|
||||
$html .= "<h1>Web Counter</h1>";
|
||||
$html .= funktion_db_list("Counter");
|
||||
|
||||
/*
|
||||
$html .= "<h1>Raeume</h1> <br />";
|
||||
funktion_db_list("Raeume");
|
||||
|
||||
$html .= "<h1>Schichtbelegung</h1> <br />";
|
||||
funktion_db_list("Schichtbelegung");
|
||||
|
||||
$html .= "<h1>Schichtplan</h1> <br />Hier findest du alle bisher eingetragenen Schichten:";
|
||||
funktion_db_list("Schichtplan");
|
||||
|
||||
$html .= "<h1>User</h1> <br />";
|
||||
funktion_db_list("User");
|
||||
|
||||
$html .= "<h1>News</h1> <br />";
|
||||
funktion_db_list("News");
|
||||
|
||||
$html .= "<h1>FAQ</h1> <br />";
|
||||
funktion_db_list("FAQ");
|
||||
|
||||
$html .= "Deaktiviert";
|
||||
*/
|
||||
|
||||
$html .= "<hr>\n";
|
||||
$html .= funktion_db_element_list_2row("Tshirt-Size aller engel", "SELECT `Size`, COUNT(`Size`) FROM `User` GROUP BY `Size`");
|
||||
$html .= "<br />\n";
|
||||
$html .= funktion_db_element_list_2row("Tshirt ausgegeben", "SELECT `Size`, COUNT(`Size`) FROM `User` WHERE `Tshirt`='1' GROUP BY `Size`");
|
||||
$html .= "<br />\n";
|
||||
$html .= funktion_db_element_list_2row("Tshirt nicht ausgegeben (Gekommen=1)", "SELECT COUNT(`Size`), `Size` FROM `User` WHERE `Gekommen`='1' and `Tshirt`='0' GROUP BY `Size`");
|
||||
|
||||
$html .= "<hr>\n";
|
||||
$html .= funktion_db_element_list_2row("Hometown", "SELECT COUNT(`Hometown`), `Hometown` FROM `User` GROUP BY `Hometown`");
|
||||
$html .= "<br />\n";
|
||||
$html .= funktion_db_element_list_2row("Engeltypen", "SELECT COUNT(`Art`), `Art` FROM `User` GROUP BY `Art`");
|
||||
|
||||
$html .= "<hr>\n";
|
||||
$html .= funktion_db_element_list_2row("Gesamte Arbeit", "SELECT COUNT(*) AS `Count [x]`, SUM(Shifts.Len) as `Sum [h]` from Shifts LEFT JOIN ShiftEntry USING(SID)");
|
||||
$html .= "<br />\n";
|
||||
$html .= funktion_db_element_list_2row("Geleistete Arbeit", "SELECT COUNT(*) AS `Count [x]`, SUM(Shifts.Len) as `Sum [h]` from Shifts LEFT JOIN ShiftEntry USING(SID) WHERE (ShiftEntry.UID!=0)");
|
||||
|
||||
$html .= "<hr>\n";
|
||||
$html .= funktion_db_element_list_2row("Gesamte Arbeit (Ohne Raum Aufbau (RID=7)", "SELECT COUNT(*) AS `Count [x]`, SUM(Shifts.Len) as `Sum [h]` from Shifts LEFT JOIN ShiftEntry USING(SID) WHERE (Shifts.RID!=7)");
|
||||
$html .= "<br />\n";
|
||||
$html .= funktion_db_element_list_2row("Geleistete Arbeit (Ohne Raum Aufbau (RID=7)", "SELECT COUNT(*) AS `Count [x]`, SUM(Shifts.Len) as `Sum [h]` from Shifts LEFT JOIN ShiftEntry USING(SID) WHERE (ShiftEntry.UID!=0) AND (Shifts.RID!=7)");
|
||||
|
||||
return $html;
|
||||
return page(array(
|
||||
msg(),
|
||||
table(array(
|
||||
'date' => "Time",
|
||||
'nick' => "Angel",
|
||||
'message' => "Log Entry"
|
||||
), $log_entries)
|
||||
));
|
||||
}
|
||||
?>
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@ function admin_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($id)." LIMIT 1");
|
||||
engelsystem_log("News updated: " . $_POST["eBetreff"]);
|
||||
header("Location: " . page_link_to("news"));
|
||||
} else
|
||||
return error("No News found.", true);
|
||||
|
@ -76,6 +77,7 @@ function admin_news() {
|
|||
list ($news) = $news;
|
||||
|
||||
sql_query("DELETE FROM `News` WHERE `ID`=" . sql_escape($id) . " LIMIT 1");
|
||||
engelsystem_log("News deleted: " . $news['Betreff']);
|
||||
header("Location: " . page_link_to("news"));
|
||||
} else
|
||||
return error("No News found.", true);
|
||||
|
|
|
@ -60,6 +60,7 @@ function admin_questions() {
|
|||
|
||||
if ($answer != "") {
|
||||
sql_query("UPDATE `Questions` SET `AID`=" . sql_escape($user['UID']) . ", `Answer`='" . sql_escape($answer) . "' WHERE `QID`=" . sql_escape($id) . " LIMIT 1");
|
||||
engelsystem_log("Question " . $question[0]['Question'] . " answered: " . $answer);
|
||||
header("Location: " . page_link_to("admin_questions"));
|
||||
} else
|
||||
return error("Gib eine Antwort ein!", true);
|
||||
|
@ -75,6 +76,7 @@ function admin_questions() {
|
|||
$question = sql_select("SELECT * FROM `Questions` WHERE `QID`=" . sql_escape($id) . " LIMIT 1");
|
||||
if (count($question) > 0) {
|
||||
sql_query("DELETE FROM `Questions` WHERE `QID`=" . sql_escape($id) . " LIMIT 1");
|
||||
engelsystem_log("Question deleted: " . $question[0]['Question']);
|
||||
header("Location: " . page_link_to("admin_questions"));
|
||||
} else
|
||||
return error("No question found.", true);
|
||||
|
|
|
@ -77,17 +77,26 @@ function admin_rooms() {
|
|||
}
|
||||
|
||||
if ($ok) {
|
||||
if(isset($id))
|
||||
if(isset($id)) {
|
||||
sql_query("UPDATE `Room` SET `Name`='" . sql_escape($name) . "', `FromPentabarf`='" . sql_escape($from_pentabarf) . "', `show`='" . sql_escape($public) . "', `Number`='" . sql_escape($number) . "' WHERE `RID`=" . sql_escape($id) . " LIMIT 1");
|
||||
else {
|
||||
engelsystem_log("Room updated: " . $name . ", pentabarf import: " . $from_pentabarf . ", public: " . $public . ", number: " . $number);
|
||||
} else {
|
||||
sql_query("INSERT INTO `Room` SET `Name`='" . sql_escape($name) . "', `FromPentabarf`='" . sql_escape($from_pentabarf) . "', `show`='" . sql_escape($public) . "', `Number`='" . sql_escape($number) . "'");
|
||||
$id = sql_id();
|
||||
engelsystem_log("Room created: " . $name . ", pentabarf import: " . $from_pentabarf . ", public: " . $public . ", number: " . $number);
|
||||
}
|
||||
|
||||
sql_query("DELETE FROM `NeededAngelTypes` WHERE `room_id`=" . sql_escape($id));
|
||||
foreach ($angeltypes_count as $angeltype_id => $angeltype_count)
|
||||
$needed_angeltype_info = array();
|
||||
foreach ($angeltypes_count as $angeltype_id => $angeltype_count) {
|
||||
$angeltype_source = sql_select("SELECT * FROM `AngelTypes` WHERE `id`=" . sql_escape($angeltype_id) . " LIMIT 1");
|
||||
if(count($angeltype_source) > 0) {
|
||||
sql_query("INSERT INTO `NeededAngelTypes` SET `room_id`=" . sql_escape($id) . ", `angel_type_id`=" . sql_escape($angeltype_id) . ", `count`=" . sql_escape($angeltype_count));
|
||||
$needed_angeltype_info[] = $angeltypes_source[0]['name'] . ": " . $angeltype_count;
|
||||
}
|
||||
}
|
||||
|
||||
engelsystem_log("Set needed angeltypes of room " . $name . " to: " . join(", ", $needed_angeltype_info));
|
||||
success("Room saved.");
|
||||
redirect(page_link_to("admin_rooms"));
|
||||
}
|
||||
|
@ -116,6 +125,8 @@ function admin_rooms() {
|
|||
if (isset ($_REQUEST['ack'])) {
|
||||
sql_query("DELETE FROM `Room` WHERE `RID`=" . sql_escape($id) . " LIMIT 1");
|
||||
sql_query("DELETE FROM `NeededAngelTypes` WHERE `room_id`=" . sql_escape($id) . " LIMIT 1");
|
||||
|
||||
engelsystem_log("Room deleted: " . $name);
|
||||
success(sprintf("Room %s deleted.", $name));
|
||||
redirect(page_link_to('admin_rooms'));
|
||||
}
|
||||
|
|
|
@ -233,11 +233,18 @@ function admin_shifts() {
|
|||
foreach ($_SESSION['admin_shifts_shifts'] as $shift) {
|
||||
sql_query("INSERT INTO `Shifts` SET `start`=" . sql_escape($shift['start']) . ", `end`=" . sql_escape($shift['end']) . ", `RID`=" . sql_escape($shift['RID']) . ", `name`='" . sql_escape($shift['name']) . "'");
|
||||
$shift_id = sql_id();
|
||||
engelsystem_log("Shift created: " . $shift['name'] . " from " . date("Y-m-d H:i", $shift['start']) . " to " . date("Y-m-d H:i", $shift['end']));
|
||||
$needed_angel_types_info = array();
|
||||
foreach ($_SESSION['admin_shifts_types'] as $type_id => $count) {
|
||||
$angel_type_source = sql_select("SELECT * FROM `AngelTypes` WHERE `id`=" . sql_escape($type_id) . " LIMIT 1");
|
||||
if(count($angel_type_source) > 0) {
|
||||
sql_query("INSERT INTO `NeededAngelTypes` SET `shift_id`=" . sql_escape($shift_id) . ", `angel_type_id`=" . sql_escape($type_id) . ", `count`=" . sql_escape($count));
|
||||
$needed_angel_types_info[] = $angel_type_source[0]['name'] . ": " . $count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
engelsystem_log("Shift needs following angel types: " . join(", ", $needed_angel_types_info));
|
||||
$msg = success("Schichten angelegt.", true);
|
||||
} else {
|
||||
unset ($_SESSION['admin_shifts_shifts']);
|
||||
|
|
|
@ -92,46 +92,55 @@ function admin_user() {
|
|||
// UserAngelType subform
|
||||
list ($user_source) = sql_select($SQL);
|
||||
|
||||
$selected_angel_types_source = sql_select("SELECT * FROM `UserAngelTypes` WHERE `user_id`=" . sql_escape($user_source['UID']));
|
||||
$selected_angel_types = array ();
|
||||
foreach ($selected_angel_types_source as $selected_angel_type)
|
||||
$selected_angel_types[] = $selected_angel_type['angeltype_id'];
|
||||
$selected_angel_types = sql_select_single_col("SELECT `angeltype_id` FROM `UserAngelTypes` WHERE `user_id`=" . sql_escape($user_source['UID']));
|
||||
$accepted_angel_types = sql_select_single_col("SELECT `angeltype_id` FROM `UserAngelTypes` WHERE `user_id`=" . sql_escape($user_source['UID']) . " AND `confirm_user_id` IS NOT NULL");
|
||||
$nonrestricted_angel_types = sql_select_single_col("SELECT `id` FROM `AngelTypes` WHERE `restricted` = 0");
|
||||
|
||||
$angel_types_source = sql_select("SELECT * FROM `AngelTypes` ORDER BY `name`");
|
||||
$angel_types = array ();
|
||||
$angel_types_source = sql_select("SELECT `id`, `name` FROM `AngelTypes` ORDER BY `name`");
|
||||
$angel_types = array();
|
||||
foreach ($angel_types_source as $angel_type)
|
||||
$angel_types[$angel_type['id']] = $angel_type['name'] . ($angel_type['restricted'] ? " (restricted)" : "");
|
||||
$angel_types[$angel_type['id']] = $angel_type['name'];
|
||||
|
||||
if (isset ($_REQUEST['submit_user_angeltypes'])) {
|
||||
$selected_angel_types = array ();
|
||||
foreach ($angel_types as $angel_type_id => $angel_type_name) {
|
||||
if (isset ($_REQUEST['angel_types_' . $angel_type_id]))
|
||||
$selected_angel_types[] = $angel_type_id;
|
||||
}
|
||||
$selected_angel_types = array_intersect($_REQUEST['selected_angel_types'], array_keys($angel_types));
|
||||
$accepted_angel_types = array_unique(array_diff(array_intersect($_REQUEST['accepted_angel_types'], array_keys($angel_types)), $nonrestricted_angel_types));
|
||||
if (in_array("admin_user_angeltypes", $privileges))
|
||||
$selected_angel_types = array_merge((array) $selected_angel_types, $accepted_angel_types);
|
||||
$selected_angel_types = array_unique($selected_angel_types);
|
||||
|
||||
// Assign angel-types
|
||||
foreach ($angel_types_source as $angel_type) {
|
||||
if (!in_array($angel_type['id'], $selected_angel_types))
|
||||
sql_query("DELETE FROM `UserAngelTypes` WHERE `user_id`=" . sql_escape($user_source['UID']) . " AND `angeltype_id`=" . sql_escape($angel_type['id']) . " LIMIT 1");
|
||||
}
|
||||
|
||||
sql_start_transaction();
|
||||
sql_query("DELETE FROM `UserAngelTypes` WHERE `user_id`=" . sql_escape($user_source['UID']));
|
||||
$user_angel_type_info = array();
|
||||
if (!empty($selected_angel_types)) {
|
||||
$SQL = "INSERT INTO `UserAngelTypes` (`user_id`, `angeltype_id`) VALUES ";
|
||||
foreach ($selected_angel_types as $selected_angel_type_id) {
|
||||
if (sql_num_query("SELECT * FROM `UserAngelTypes` WHERE `user_id`=" . sql_escape($user_source['UID']) . " AND `angeltype_id`=" . sql_escape($selected_angel_type_id) . " LIMIT 1") == 0) {
|
||||
$SQL .= "(" . $user_source['UID'] . ", " . $selected_angel_type_id . "),";
|
||||
$user_angel_type_info[] = $angel_types[$selected_angel_type_id] . (in_array($selected_angel_type_id, $accepted_angel_types) ? ' (confirmed)' : '');
|
||||
}
|
||||
// remove superfluous comma
|
||||
$SQL = substr($SQL, 0, -1);
|
||||
sql_query($SQL);
|
||||
}
|
||||
if (in_array("admin_user_angeltypes", $privileges)) {
|
||||
sql_query("INSERT INTO `UserAngelTypes` SET `confirm_user_id`=" . sql_escape($user['UID']) . ", `user_id`=" . sql_escape($user_source['UID']) . ", `angeltype_id`=" . sql_escape($selected_angel_type_id));
|
||||
} else {
|
||||
sql_query("INSERT INTO `UserAngelTypes` SET `user_id`=" . sql_escape($user_source['UID']) . ", `angeltype_id`=" . sql_escape($selected_angel_type_id));
|
||||
}
|
||||
}
|
||||
sql_query("UPDATE `UserAngelTypes` SET `confirm_user_id` = NULL WHERE `user_id` = " . sql_escape($user_source['UID']));
|
||||
if (!empty($accepted_angel_types))
|
||||
sql_query("UPDATE `UserAngelTypes` SET `confirm_user_id` = '" . sql_escape($user['UID']) . "' WHERE `user_id` = '" . sql_escape($user_source['UID']) . "' AND `angeltype_id` IN (" . implode(',', $accepted_angel_types) . ")");
|
||||
}
|
||||
sql_stop_transaction();
|
||||
|
||||
engelsystem_log("Set angeltypes of " . $user_source['Nick'] . " to: " . join(", ", $user_angel_type_info));
|
||||
success("Angeltypes saved.");
|
||||
redirect(page_link_to('admin_user') . '&id=' . $user_source['UID']);
|
||||
}
|
||||
|
||||
$html .= form(array (
|
||||
msg(),
|
||||
form_checkboxes('angel_types', "Angeltypes", $angel_types, $selected_angel_types),
|
||||
form_multi_checkboxes(array('selected_angel_types' => 'gewünscht', 'accepted_angel_types' => 'akzeptiert'),
|
||||
"Angeltypes",
|
||||
$angel_types,
|
||||
array('selected_angel_types' => $selected_angel_types, 'accepted_angel_types' => array_merge($accepted_angel_types, $nonrestricted_angel_types)),
|
||||
array('accepted_angel_types' => $nonrestricted_angel_types)),
|
||||
form_submit('submit_user_angeltypes', Get_Text("Save"))
|
||||
));
|
||||
|
||||
|
@ -188,19 +197,26 @@ function admin_user() {
|
|||
$his_highest_group = sql_select("SELECT * FROM `UserGroups` WHERE `uid`=" . sql_escape($id) . " ORDER BY `group_id`");
|
||||
|
||||
if (count($my_highest_group) > 0 && (count($his_highest_group) == 0 || ($my_highest_group[0]['group_id'] <= $his_highest_group[0]['group_id']))) {
|
||||
$groups = sql_select("SELECT * FROM `Groups` LEFT OUTER JOIN `UserGroups` ON (`UserGroups`.`group_id` = `Groups`.`UID` AND `UserGroups`.`uid` = " . sql_escape($id) . ") WHERE `Groups`.`UID` >= " . sql_escape($my_highest_group[0]['group_id']) . " ORDER BY `Groups`.`Name`");
|
||||
$groups_source = sql_select("SELECT * FROM `Groups` LEFT OUTER JOIN `UserGroups` ON (`UserGroups`.`group_id` = `Groups`.`UID` AND `UserGroups`.`uid` = " . sql_escape($id) . ") WHERE `Groups`.`UID` >= " . sql_escape($my_highest_group[0]['group_id']) . " ORDER BY `Groups`.`Name`");
|
||||
$groups = array();
|
||||
$grouplist = array ();
|
||||
foreach ($groups as $group)
|
||||
foreach ($groups_source as $group) {
|
||||
$groups[$group['UID']] = $group;
|
||||
$grouplist[] = $group['UID'];
|
||||
}
|
||||
|
||||
if (!is_array($_REQUEST['groups']))
|
||||
$_REQUEST['groups'] = array ();
|
||||
|
||||
sql_query("DELETE FROM `UserGroups` WHERE `uid`=" . sql_escape($id));
|
||||
foreach ($_REQUEST['groups'] as $group)
|
||||
if (in_array($group, $grouplist))
|
||||
sql_query("INSERT INTO `UserGroups` SET `uid`=" .
|
||||
sql_escape($id) . ", `group_id`=" . sql_escape($group));
|
||||
$user_groups_info = array();
|
||||
foreach ($_REQUEST['groups'] as $group) {
|
||||
if (in_array($group, $grouplist)) {
|
||||
sql_query("INSERT INTO `UserGroups` SET `uid`=" . sql_escape($id) . ", `group_id`=" . sql_escape($group));
|
||||
$user_groups_info[] = $groups[$group]['Name'];
|
||||
}
|
||||
}
|
||||
engelsystem_log("Set groups of " . $user_source['Nick'] . " to: " . join(", ", $user_groups_info));
|
||||
$html .= success("Benutzergruppen gespeichert.", true);
|
||||
} else {
|
||||
$html .= error("Du kannst keine Engel mit mehr Rechten bearbeiten.", true);
|
||||
|
@ -212,9 +228,11 @@ function admin_user() {
|
|||
|
||||
case 'delete' :
|
||||
if ($user['UID'] != $id) {
|
||||
$nickname = sql_select("SELECT `Nick` FROM `User` WHERE `UID` = '" . sql_escape($id) . "' LIMIT 1");
|
||||
sql_query("DELETE FROM `User` WHERE `UID`=" . sql_escape($id) . " LIMIT 1");
|
||||
sql_query("DELETE FROM `UserGroups` WHERE `uid`=" . sql_escape($id));
|
||||
sql_query("UPDATE `ShiftEntry` SET `UID`=0, `Comment`=NULL WHERE `UID`=" . sql_escape($id));
|
||||
engelsystem_log("Deleted user " . $nickname[0]['Nick']);
|
||||
$html .= success("Benutzer gelöscht!", true);
|
||||
} else {
|
||||
$html .= error("Du kannst Dich nicht selber löschen!", true);
|
||||
|
@ -240,12 +258,14 @@ function admin_user() {
|
|||
"WHERE `UID` = '" . sql_escape($id) .
|
||||
"' LIMIT 1;";
|
||||
sql_query($SQL);
|
||||
engelsystem_log("Updated user: " . $_POST["eNick"] . ", " . $_POST["eSize"] . ", arrived: " . $_POST["eGekommen"] . ", active: " . $_POST["eAktiv"] . ", tshirt: " . $_POST["eTshirt"]);
|
||||
$html .= success("Änderung wurde gespeichert...\n", true);
|
||||
break;
|
||||
|
||||
case 'change_pw' :
|
||||
if ($_REQUEST['new_pw'] != "" && $_REQUEST['new_pw'] == $_REQUEST['new_pw2']) {
|
||||
set_password($id, $_REQUEST['new_pw']);
|
||||
engelsystem_log("Set new password for " . $user_source['Nick']);
|
||||
$html .= success("Passwort neu gesetzt.", true);
|
||||
} else {
|
||||
$html .= error("Die Eingaben müssen übereinstimmen und dürfen nicht leer sein!", true);
|
||||
|
|
|
@ -8,16 +8,24 @@ function admin_user_angeltypes() {
|
|||
global $privileges;
|
||||
|
||||
if (isset ($_REQUEST['confirm']) && test_request_int('confirm') && sql_num_query("SELECT * FROM `UserAngelTypes` WHERE `id`=" . sql_escape($_REQUEST['confirm']) . " AND `confirm_user_id` IS NULL") > 0) {
|
||||
$user_angel_type_source = sql_select("SELECT `UserAngelTypes`.*, `User`.`Nick`, `AngelTypes`.`name` FROM `UserAngelTypes` JOIN `User` ON `User`.`UID`=`UserAngelTypes`.`user_id` JOIN `AngelTypes` ON `AngelTypes`.`id`=`UserAngelTypes`.`angeltype_id` WHERE `UserAngelTypes`.`id`=" . sql_escape($_REQUEST['confirm']) . " LIMIT 1");
|
||||
if(count($user_angel_type_source) > 0) {
|
||||
sql_query("UPDATE `UserAngelTypes` SET `confirm_user_id`=" . sql_escape($_SESSION['uid']) . " WHERE `id`=" . sql_escape($_REQUEST['confirm']) . " LIMIT 1");
|
||||
|
||||
engelsystem_log("Confirmed " . $user_angel_type_source[0]['Nick'] . " as " . $user_angel_type_source[0]['name']);
|
||||
success("Confirmed.");
|
||||
}
|
||||
else error("Entry not found.");
|
||||
redirect(page_link_to('admin_user_angeltypes'));
|
||||
}
|
||||
|
||||
if (isset ($_REQUEST['discard']) && test_request_int('discard') && sql_num_query("SELECT * FROM `UserAngelTypes` WHERE `id`=" . sql_escape($_REQUEST['discard']) . " AND `confirm_user_id` IS NULL") > 0) {
|
||||
$user_angel_type_source = sql_select("SELECT `UserAngelTypes`.*, `User`.`Nick`, `AngelTypes`.`name` FROM `UserAngelTypes` JOIN `User` ON `User`.`UID`=`UserAngelTypes`.`user_id` JOIN `AngelTypes` ON `AngelTypes`.`id`=`UserAngelTypes`.`angeltype_id` WHERE `UserAngelTypes`.`id`=" . sql_escape($_REQUEST['discard']) . " LIMIT 1");
|
||||
if(count($user_angel_type_source) > 0) {
|
||||
sql_query("DELETE FROM `UserAngelTypes` WHERE `id`=" . sql_escape($_REQUEST['discard']) . " LIMIT 1");
|
||||
|
||||
engelsystem_log("Discarded " . $user_angel_type_source[0]['Nick'] . " as " . $user_angel_type_source[0]['name']);
|
||||
success("Discarded.");
|
||||
}
|
||||
else error("Entry not found.");
|
||||
redirect(page_link_to('admin_user_angeltypes'));
|
||||
}
|
||||
|
||||
|
|
|
@ -116,9 +116,12 @@ function guest_register() {
|
|||
set_password($user_id, $_REQUEST['password']);
|
||||
|
||||
// Assign angel-types
|
||||
foreach ($selected_angel_types as $selected_angel_type_id)
|
||||
$user_angel_types_info = array();
|
||||
foreach ($selected_angel_types as $selected_angel_type_id) {
|
||||
sql_query("INSERT INTO `UserAngelTypes` SET `user_id`=" . sql_escape($user_id) . ", `angeltype_id`=" . sql_escape($selected_angel_type_id));
|
||||
|
||||
$user_angel_types_info[] = $angel_types[$selected_angel_type_id]['name'];
|
||||
}
|
||||
engelsystem_log("User " . $nick . " signed up as: " . join(", ", $user_angel_types_info));
|
||||
success(Get_Text("makeuser_writeOK4"));
|
||||
//if (!isset ($_SESSION['uid']))
|
||||
redirect(page_link_to('login'));
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
// publically available page to feed the news to feedreaders
|
||||
function user_atom() {
|
||||
global $ical_shifts, $user, $DISPLAY_NEWS;
|
||||
|
||||
if (isset ($_REQUEST['key']) && preg_match("/^[0-9a-f]{32}$/", $_REQUEST['key']))
|
||||
$key = $_REQUEST['key'];
|
||||
else
|
||||
die("Missing key.");
|
||||
|
||||
$user = sql_select("SELECT * FROM `User` WHERE `ical_key`='" . sql_escape($key) . "' LIMIT 1");
|
||||
if (count($user) == 0)
|
||||
die("Key invalid.");
|
||||
|
||||
$user = $user[0];
|
||||
$news = sql_select("SELECT * FROM `News` " . (empty($_REQUEST['meetings'])? '' : 'WHERE `Treffen` = 1 ') . "ORDER BY `ID` DESC LIMIT " . sql_escape($DISPLAY_NEWS));
|
||||
|
||||
header('Content-Type: application/atom+xml; charset=utf-8');
|
||||
$html = '<?xml version="1.0" encoding="utf-8"?>
|
||||
<feed xmlns="http://www.w3.org/2005/Atom">
|
||||
<title>Engelsystem</title>
|
||||
<id>' . $_SERVER['HTTP_HOST'] . htmlspecialchars(preg_replace('#[&?]key=[a-f0-9]{32}#', '', $_SERVER['REQUEST_URI'])) . '</id>
|
||||
<updated>' . date('Y-m-d\TH:i:sP', $news[0]['Datum']) . "</updated>\n";
|
||||
foreach ($news as $news_entry) {
|
||||
$html .= " <entry>
|
||||
<title>" . htmlspecialchars($news_entry['Betreff']) . "</title>
|
||||
<link href=\"" . page_link_to_absolute("news_comments&nid=") . "${news_entry['ID']}\"/>
|
||||
<id>" . preg_replace('#^https?://#', '', page_link_to_absolute("news")) . "-${news_entry['ID']}</id>
|
||||
<updated>" . date('Y-m-d\TH:i:sP', $news_entry['Datum']) . "</updated>
|
||||
<summary type=\"html\">" . htmlspecialchars($news_entry['Text']) . "</summary>
|
||||
</entry>\n";
|
||||
}
|
||||
$html .= "</feed>";
|
||||
header("Content-Length: " . strlen($html));
|
||||
echo $html;
|
||||
die();
|
||||
}
|
||||
?>
|
|
@ -28,14 +28,15 @@ function user_myshifts() {
|
|||
}
|
||||
elseif (isset ($_REQUEST['edit']) && preg_match("/^[0-9]*$/", $_REQUEST['edit'])) {
|
||||
$id = $_REQUEST['edit'];
|
||||
$shift = sql_select("SELECT `ShiftEntry`.`Comment`, `Shifts`.*, `Room`.`Name`, `AngelTypes`.`name` as `angel_type` FROM `ShiftEntry` JOIN `AngelTypes` ON (`ShiftEntry`.`TID` = `AngelTypes`.`id`) JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID`) JOIN `Room` ON (`Shifts`.`RID` = `Room`.`RID`) WHERE `ShiftEntry`.`id`=" . sql_escape($id) . " AND `UID`=" . sql_escape($shifts_user['UID']) . " LIMIT 1");
|
||||
$shift = sql_select("SELECT `ShiftEntry`.`Comment`, `ShiftEntry`.`UID`, `Shifts`.*, `Room`.`Name`, `AngelTypes`.`name` as `angel_type` FROM `ShiftEntry` JOIN `AngelTypes` ON (`ShiftEntry`.`TID` = `AngelTypes`.`id`) JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID`) JOIN `Room` ON (`Shifts`.`RID` = `Room`.`RID`) WHERE `ShiftEntry`.`id`=" . sql_escape($id) . " AND `UID`=" . sql_escape($shifts_user['UID']) . " LIMIT 1");
|
||||
if (count($shift) > 0) {
|
||||
$shift = $shift[0];
|
||||
|
||||
if (isset ($_REQUEST['submit'])) {
|
||||
$comment = strip_request_item_nl('comment');
|
||||
$user_source = User($shift['UID']);
|
||||
sql_query("UPDATE `ShiftEntry` SET `Comment`='" . sql_escape($comment) . "' WHERE `id`=" . sql_escape($id) . " LIMIT 1");
|
||||
|
||||
engelsystem_log("Updated " . $user_source['Nick'] . "'s shift " . $shift['name'] . " from " . date("y-m-d H:i", $shift['start']) . " to " . date("y-m-d H:i", $shift['end']) . " with comment " . $comment);
|
||||
success("Schicht gespeichert.");
|
||||
redirect(page_link_to('user_myshifts'));
|
||||
}
|
||||
|
@ -87,9 +88,6 @@ function user_myshifts() {
|
|||
if ($html == "")
|
||||
$html = '<tr><td>' . ucfirst(Get_Text('none')) . '...</td><td></td><td></td><td></td><td></td><td>' . sprintf(Get_Text('pub_myshifts_goto_shifts'), page_link_to('user_shifts')) . '</td></tr>';
|
||||
|
||||
if ($shifts_user['ical_key'] == "")
|
||||
user_reset_ical_key($shifts_user);
|
||||
|
||||
return msg().template_render('../templates/user_myshifts.html', array (
|
||||
'intro' => sprintf(Get_Text('pub_myshifts_intro'), $LETZTES_AUSTRAGEN),
|
||||
'shifts' => $html,
|
||||
|
@ -97,6 +95,6 @@ function user_myshifts() {
|
|||
'ical_text' => sprintf(Get_Text('inc_schicht_ical_text'),
|
||||
page_link_to_absolute('ical') . '&key=' . $shifts_user['ical_key'],
|
||||
page_link_to('user_myshifts') . '&reset'),
|
||||
));
|
||||
));
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -58,6 +58,7 @@ function user_news_comments() {
|
|||
if (isset ($_REQUEST["text"])) {
|
||||
$text = preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}\n]{1,})/ui", '', strip_tags($_REQUEST['text']));
|
||||
sql_query("INSERT INTO `news_comments` (`Refid`, `Datum`, `Text`, `UID`) VALUES ('" . sql_escape($nid) . "', '" . date("Y-m-d H:i:s") . "', '" . sql_escape($text) . "', '" . sql_escape($user["UID"]) . "')");
|
||||
engelsystem_log("Created news_comment: " . $text);
|
||||
$html .= success("Eintrag wurde gespeichert", true);
|
||||
}
|
||||
|
||||
|
@ -114,6 +115,7 @@ function user_news() {
|
|||
sql_query("INSERT INTO `News` (`Datum`, `Betreff`, `Text`, `UID`, `Treffen`) " .
|
||||
"VALUES ('" . sql_escape(time()) . "', '" . sql_escape($_POST["betreff"]) . "', '" . sql_escape($_POST["text"]) . "', '" . sql_escape($user['UID']) .
|
||||
"', '" . sql_escape($_POST["treffen"]) . "');");
|
||||
engelsystem_log("Created news: " . $_POST["betreff"] . ", treffen: " . $_POST["treffen"]);
|
||||
$html .= success(Get_Text(4), true);
|
||||
}
|
||||
|
||||
|
|
|
@ -99,14 +99,20 @@ function user_settings() {
|
|||
"', `Hometown`='" . sql_escape($hometown) . "' WHERE `UID`=" . sql_escape($user['UID']));
|
||||
|
||||
// Assign angel-types
|
||||
foreach ($angel_types_source as $angel_type)
|
||||
$user_angel_type_info = array();
|
||||
foreach ($angel_types_source as $angel_type) {
|
||||
if (!in_array($angel_type['id'], $selected_angel_types))
|
||||
sql_query("DELETE FROM `UserAngelTypes` WHERE `user_id`=" . sql_escape($user['UID']) . " AND `angeltype_id`=" . sql_escape($angel_type['id']) . " LIMIT 1");
|
||||
else
|
||||
$user_angel_type_info[] = $angel_type['name'];
|
||||
}
|
||||
|
||||
foreach ($selected_angel_types as $selected_angel_type_id)
|
||||
foreach ($selected_angel_types as $selected_angel_type_id) {
|
||||
if (sql_num_query("SELECT * FROM `UserAngelTypes` WHERE `user_id`=" . sql_escape($user['UID']) . " AND `angeltype_id`=" . sql_escape($selected_angel_type_id) . " LIMIT 1") == 0)
|
||||
sql_query("INSERT INTO `UserAngelTypes` SET `user_id`=" . sql_escape($user['UID']) . ", `angeltype_id`=" . sql_escape($selected_angel_type_id));
|
||||
}
|
||||
|
||||
engelsystem_log("Own angel types set to: " . join(", ", $user_angel_type_info));
|
||||
success("Settings saved.");
|
||||
redirect(page_link_to('user_settings'));
|
||||
}
|
||||
|
|
|
@ -9,8 +9,15 @@ function user_shifts() {
|
|||
else
|
||||
redirect(page_link_to('user_shifts'));
|
||||
|
||||
$shift_entry_source = sql_select("SELECT `User`.`Nick`, `ShiftEntry`.`Comment`, `ShiftEntry`.`UID`, `Shifts`.*, `Room`.`Name`, `AngelTypes`.`name` as `angel_type` FROM `ShiftEntry` JOIN `User` ON (`User`.`UID`=`ShiftEntry`.`UID`) JOIN `AngelTypes` ON (`ShiftEntry`.`TID` = `AngelTypes`.`id`) JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID`) JOIN `Room` ON (`Shifts`.`RID` = `Room`.`RID`) WHERE `ShiftEntry`.`id`=" . sql_escape($entry_id) . " LIMIT 1");
|
||||
if(count($shift_entry_source) > 0) {
|
||||
$shift_entry_source = $shift_entry_source[0];
|
||||
sql_query("DELETE FROM `ShiftEntry` WHERE `id`=" . sql_escape($entry_id) . " LIMIT 1");
|
||||
|
||||
engelsystem_log("Deleted " . $shift_entry_source['Nick'] . "'s shift: " . $shift_entry_source['name'] . " at " . $shift_entry_source['Name'] . " from " . date("y-m-d H:i", $shift_entry_source['start']) . " to " . date("y-m-d H:i", $shift_entry_source['end']) . " as " . $shift_entry_source['angel_type']);
|
||||
success("Der Schicht-Eintrag wurde gelöscht.");
|
||||
}
|
||||
else error("Entry not found.");
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
// Schicht bearbeiten
|
||||
|
@ -43,9 +50,12 @@ function user_shifts() {
|
|||
|
||||
// Engeltypen laden
|
||||
$types = sql_select("SELECT * FROM `AngelTypes` ORDER BY `name`");
|
||||
$angel_types = array();
|
||||
$needed_angel_types = array ();
|
||||
foreach ($types as $type)
|
||||
foreach ($types as $type) {
|
||||
$angel_types[$type['id']] = $type;
|
||||
$needed_angel_types[$type['id']] = 0;
|
||||
}
|
||||
|
||||
// Benötigte Engeltypen vom Raum
|
||||
$needed_angel_types_source = sql_select("SELECT `AngelTypes`.*, `NeededAngelTypes`.`count` FROM `AngelTypes` LEFT JOIN `NeededAngelTypes` ON (`NeededAngelTypes`.`angel_type_id` = `AngelTypes`.`id` AND `NeededAngelTypes`.`room_id`=" . sql_escape($shift['RID']) . ") ORDER BY `AngelTypes`.`name`");
|
||||
|
@ -110,8 +120,13 @@ function user_shifts() {
|
|||
if ($ok) {
|
||||
sql_query("UPDATE `Shifts` SET `start`=" . sql_escape($start) . ", `end`=" . sql_escape($end) . ", `RID`=" . sql_escape($rid) . ", `name`='" . sql_escape($name) . "' WHERE `SID`=" . sql_escape($shift_id) . " LIMIT 1");
|
||||
sql_query("DELETE FROM `NeededAngelTypes` WHERE `shift_id`=" . sql_escape($shift_id));
|
||||
foreach ($needed_angel_types as $type_id => $count)
|
||||
$needed_angel_types_info = array();
|
||||
foreach ($needed_angel_types as $type_id => $count) {
|
||||
sql_query("INSERT INTO `NeededAngelTypes` SET `shift_id`=" . sql_escape($shift_id) . ", `angel_type_id`=" . sql_escape($type_id) . ", `count`=" . sql_escape($count));
|
||||
$needed_angel_types_info[] = $angel_types[$type_id]['name'] . ": " . $count;
|
||||
}
|
||||
|
||||
engelsystem_log("Updated shift '" . $name . "' from " . date("y-m-d H:i", $start) . " to " . date("y-m-d H:i", $end) . " with angel types " . join(", ", $needed_angel_types_info));
|
||||
success("Schicht gespeichert.");
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
|
@ -155,6 +170,7 @@ function user_shifts() {
|
|||
sql_query("DELETE FROM `NeededAngelTypes` WHERE `shift_id`=" . sql_escape($shift_id));
|
||||
sql_query("DELETE FROM `Shifts` WHERE `SID`=" . sql_escape($shift_id) . " LIMIT 1");
|
||||
|
||||
engelsystem_log("Deleted shift " . $shift['name'] . " from " . date("y-m-d H:i", $shift['start']) . " to " . date("y-m-d H:i", $shift['end']));
|
||||
success("Die Schicht wurde gelöscht.");
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
|
@ -191,7 +207,7 @@ function user_shifts() {
|
|||
if (in_array('user_shifts_admin', $privileges))
|
||||
$type = sql_select("SELECT * FROM `AngelTypes` WHERE `id`=" . sql_escape($type_id) . " LIMIT 1");
|
||||
else
|
||||
$type = sql_select("SELECT * FROM `UserAngelTypes` JOIN `AngelTypes` ON (`UserAngelTypes`.`angeltype_id` = `AngelTypes`.`id`) WHERE `AngelTypes`.`id` = " . sql_escape($type_id) . " AND `UserAngelTypes`.`user_id` = " . sql_escape($user['UID']) . " AND (`AngelTypes`.`restricted` = 0 OR NOT `UserAngelTypes`.`confirm_user_id` IS NULL) LIMIT 1");
|
||||
$type = sql_select("SELECT * FROM `UserAngelTypes` JOIN `AngelTypes` ON (`UserAngelTypes`.`angeltype_id` = `AngelTypes`.`id`) WHERE `AngelTypes`.`id` = " . sql_escape($type_id) . " AND (`AngelTypes`.`restricted` = 0 OR (`UserAngelTypes`.`user_id` = " . sql_escape($user['UID']) . " AND NOT `UserAngelTypes`.`confirm_user_id` IS NULL)) LIMIT 1");
|
||||
|
||||
if (count($type) == 0)
|
||||
header("Location: " . page_link_to('user_shifts'));
|
||||
|
@ -214,14 +230,16 @@ function user_shifts() {
|
|||
$user_id = $user['UID'];
|
||||
|
||||
// TODO: Kollisionserkennung, andere Schichten zur gleichen Uhrzeit darf der Engel auch nicht belegt haben...
|
||||
$entries = sql_select("SELECT * FROM `ShiftEntry` WHERE `SID`=" . sql_escape($shift['SID']));
|
||||
foreach ($entries as $entry)
|
||||
if ($entry['UID'] == $user_id)
|
||||
if (sql_num_query("SELECT * FROM `ShiftEntry` WHERE `SID`='" . sql_escape($shift['SID']) . "' AND `UID` = '" . sql_escape($user_id) . "'"))
|
||||
return error("This angel does already have an entry for this shift.", true);
|
||||
|
||||
$comment = strip_request_item_nl('comment');
|
||||
sql_query("INSERT INTO `ShiftEntry` SET `Comment`='" . sql_escape($comment) . "', `UID`=" . sql_escape($user_id) . ", `TID`=" . sql_escape($selected_type_id) . ", `SID`=" . sql_escape($shift_id));
|
||||
if (sql_num_query("SELECT * FROM `UserAngelTypes` INNER JOIN `AngelTypes` ON `AngelTypes`.`id` = `UserAngelTypes`.`angeltype_id` WHERE `AngelTypes`.`restricted` = 0 AND `user_id` = '" . sql_escape($user_id) . "' AND `angeltype_id` = '" . sql_escape($selected_type_id) . "'") == 0)
|
||||
sql_query("INSERT INTO `UserAngelTypes` (`user_id`, `angeltype_id`) VALUES ('" . sql_escape($user_id) . "', '" . sql_escape($selected_type_id) . "')");
|
||||
|
||||
$user_source = User($user_id);
|
||||
engelsystem_log("User " . $user_source['Nick'] . " signed up for shift " . $shift['name'] . " from " . date("y-m-d H:i", $shift['start']) . " to " . date("y-m-d H:i", $shift['end']));
|
||||
success("Du bist eingetragen. Danke!" . ' <a href="' . page_link_to('user_myshifts') . '">Meine Schichten »</a>');
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Write a log entry. This should be used to log user's activity.
|
||||
* @param $message
|
||||
*/
|
||||
function engelsystem_log($message) {
|
||||
global $user;
|
||||
|
||||
if(isset($user)) {
|
||||
$nick = $user['Nick'];
|
||||
} else {
|
||||
$nick = "Guest";
|
||||
}
|
||||
|
||||
LogEntry_create($nick, $message);
|
||||
}
|
||||
|
||||
?>
|
|
@ -31,6 +31,12 @@ function sql_select($query) {
|
|||
}
|
||||
}
|
||||
|
||||
function sql_select_single_col($query) {
|
||||
$result = sql_select($query);
|
||||
return array_map('array_pop', $result);
|
||||
|
||||
}
|
||||
|
||||
// Execute a query
|
||||
function sql_query($query) {
|
||||
global $con;
|
||||
|
@ -59,4 +65,17 @@ function sql_error() {
|
|||
global $con;
|
||||
return mysql_error($con);
|
||||
}
|
||||
|
||||
$sql_transaction_counter = 0;
|
||||
function sql_start_transaction() {
|
||||
global $sql_transaction_counter;
|
||||
if ($sql_transaction_counter++ == 0)
|
||||
sql_query("START TRANSACTION");
|
||||
}
|
||||
|
||||
function sql_stop_transaction() {
|
||||
global $sql_transaction_counter;
|
||||
if ($sql_transaction_counter-- == 1)
|
||||
sql_query("COMMIT");
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -36,6 +36,34 @@ function form_checkboxes($name, $label, $items, $selected) {
|
|||
return form_element($label, $html);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rendert eine Tabelle von Checkboxen für ein Formular
|
||||
* @param names Assoziatives Array mit Namen der Checkboxen als Keys und Überschriften als Values
|
||||
* @param label Die Beschriftung der gesamten Tabelle
|
||||
* @param items Array mit den Beschriftungen der Zeilen
|
||||
* @param selected Mehrdimensionales Array, wobei $selected[foo] ein Array der in der Datenreihe foo markierten Checkboxen ist
|
||||
* @param disabled Wie selected, nur dass die entsprechenden Checkboxen deaktiviert statt markiert sind
|
||||
*/
|
||||
function form_multi_checkboxes($names, $label, $items, $selected, $disabled = array()) {
|
||||
$html = "<table><thead><tr>";
|
||||
foreach ($names as $title)
|
||||
$html .= "<th>$title</th>";
|
||||
$html .= "</tr></thead><tbody>";
|
||||
foreach ($items as $key => $item) {
|
||||
$html .= "<tr>";
|
||||
foreach ($names as $name => $title) {
|
||||
$id = $name . '_' . $key;
|
||||
$sel = array_search($key, $selected[$name]) !== false ? ' checked="checked"' : "";
|
||||
if (!empty($disabled) && !empty($disabled[$name]) && array_search($key, $disabled[$name]) !== false)
|
||||
$sel .= ' disabled="disabled"';
|
||||
$html .= '<td style="text-align: center;"><input type="checkbox" id="' . $id . '" name="' . $name . '[]" value="' . $key . '"' . $sel . ' /></td>';
|
||||
}
|
||||
$html .= '<td><label for="' . $id . '">' . $item . '</label></td></tr>';
|
||||
}
|
||||
$html .= "</tbody></table>";
|
||||
return form_element($label, $html);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rendert eine Checkbox
|
||||
*/
|
||||
|
|
|
@ -23,6 +23,7 @@ $tshirt_sizes = array (
|
|||
function user_reset_ical_key($user) {
|
||||
$user['ical_key'] = md5($user['Nick'] . time() . rand());
|
||||
sql_query("UPDATE `User` SET `ical_key`='" . sql_escape($user['ical_key']) . "' WHERE `UID`='" . sql_escape($user['UID']) . "' LIMIT 1");
|
||||
engelsystem_log("iCal key resetted.");
|
||||
}
|
||||
|
||||
function UID2Nick($UID) {
|
||||
|
|
|
@ -37,10 +37,6 @@ $gmdateOffset=3600;
|
|||
// für Developen 1, sonst = 0
|
||||
$debug = 0;
|
||||
|
||||
// SSL Cert-KEY
|
||||
$show_SSLCERT = "MD5:<br>MD5SED<br>\n".
|
||||
"SHA1:<br>SHA1SED";
|
||||
|
||||
//globale const. fuer schischtplan
|
||||
$GlobalZeileProStunde = 4;
|
||||
|
||||
|
@ -61,4 +57,15 @@ $PentabarfXMLEventID = "31";
|
|||
/// Passord for external Authorization, function only active if the var is defined
|
||||
//$CurrentExternAuthPass = 23;
|
||||
|
||||
// multiply "night shifts" (start or end between 2 and 6 exclusive) by 2
|
||||
$shift_sum_formula = "SUM(
|
||||
(1+(
|
||||
(HOUR(FROM_UNIXTIME(`Shifts`.`end`)) > 2 AND HOUR(FROM_UNIXTIME(`Shifts`.`end`)) < 6)
|
||||
OR (HOUR(FROM_UNIXTIME(`Shifts`.`start`)) > 2 AND HOUR(FROM_UNIXTIME(`Shifts`.`start`)) < 6)
|
||||
OR (HOUR(FROM_UNIXTIME(`Shifts`.`start`)) <= 2 AND HOUR(FROM_UNIXTIME(`Shifts`.`end`)) >= 6)
|
||||
))*(`Shifts`.`end` - `Shifts`.`start`)
|
||||
)";
|
||||
|
||||
// weigh every shift the same
|
||||
//$shift_sum_formula = "SUM(`end` - `start`)";
|
||||
?>
|
||||
|
|
|
@ -3,6 +3,7 @@ require_once ('bootstrap.php');
|
|||
require_once ('includes/sys_auth.php');
|
||||
require_once ('includes/sys_counter.php');
|
||||
require_once ('includes/sys_lang.php');
|
||||
require_once ('includes/sys_log.php');
|
||||
require_once ('includes/sys_menu.php');
|
||||
require_once ('includes/sys_mysql.php');
|
||||
require_once ('includes/sys_page.php');
|
||||
|
@ -10,6 +11,9 @@ require_once ('includes/sys_shift.php');
|
|||
require_once ('includes/sys_template.php');
|
||||
require_once ('includes/sys_user.php');
|
||||
|
||||
require_once ('includes/model/LogEntries_model.php');
|
||||
require_once ('includes/model/User_model.php');
|
||||
|
||||
require_once ('config/config.php');
|
||||
require_once ('config/config_db.php');
|
||||
|
||||
|
@ -39,6 +43,10 @@ if ($p == "ical") {
|
|||
require_once ('includes/pages/user_ical.php');
|
||||
user_ical();
|
||||
}
|
||||
elseif ($p == "atom") {
|
||||
require_once ('includes/pages/user_atom.php');
|
||||
user_atom();
|
||||
}
|
||||
// Recht dafür vorhanden?
|
||||
elseif (in_array($p, $privileges)) {
|
||||
if ($p == "news") {
|
||||
|
@ -184,6 +192,7 @@ if (isset ($user) && $p != "admin_user_angeltypes")
|
|||
echo template_render('../templates/layout.html', array (
|
||||
'theme' => isset ($user) ? $user['color'] : $default_theme,
|
||||
'title' => $title,
|
||||
'atom_link' => ($p == 'news' || $p == 'user_meetings')? '<link href="' . page_link_to('atom') . (($p == 'user_meetings')? '&meetings=1' : '') . '&key=' . $user['ical_key'] . '" type="application/atom+xml" rel="alternate" title="Atom Feed">' : '',
|
||||
'menu' => make_menu(),
|
||||
'content' => $content
|
||||
));
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<form action="%link%" method="post">
|
||||
<p>
|
||||
Search Angel: <input type="text" name="search" value="%search%" /><input type="submit" name="submit" value="Search" />
|
||||
Search Angel: <input type="text" name="search" value="%search%" placeholder="Name"> %angeltypes% <label><input type="checkbox" name="confirmed_only" %confirmed_only% value="1"> Nur zugelassene</label> <input type="submit" name="submit" value="Search">
|
||||
</p>
|
||||
</form>
|
||||
<table>
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
<script type="text/javascript" src="css/forms.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="css/base.css" />
|
||||
<link rel="stylesheet" type="text/css" href="css/style%theme%.css" />
|
||||
%atom_link%
|
||||
</head>
|
||||
<body class="background">
|
||||
<header>
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
</table>
|
||||
<hr/>
|
||||
<p>
|
||||
Frage einen Orga:
|
||||
Frage einen Erzengel:
|
||||
</p>
|
||||
<form action="%link%&action=ask" method="post">
|
||||
<table>
|
||||
|
|
Loading…
Reference in New Issue