Commit 98f355cd authored by Philip Häusler's avatar Philip Häusler

added angeltype description

parent 893bb5a9
This diff is collapsed.
......@@ -33,3 +33,4 @@ ALTER TABLE `AngelTypes` DROP `Man`;
ALTER TABLE `AngelTypes` CHANGE `TID` `id` INT( 11 ) NOT NULL AUTO_INCREMENT;
ALTER TABLE `AngelTypes` CHANGE `Name` `name` VARCHAR( 25 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '';
ALTER TABLE `AngelTypes` ADD `restricted` INT( 1 ) NOT NULL;
ALTER TABLE `AngelTypes` ADD `description` TEXT NOT NULL;
\ No newline at end of file
......@@ -77,6 +77,8 @@ function angeltype_edit_controller() {
$name = "";
$restricted = false;
$description = "";
if (isset($_REQUEST['angeltype_id'])) {
$angeltype = AngelType($_REQUEST['angeltype_id']);
if ($angeltype === false)
......@@ -86,6 +88,7 @@ function angeltype_edit_controller() {
$name = $angeltype['name'];
$restricted = $angeltype['restricted'];
$description = $angeltype['description'];
}
if (isset($_REQUEST['submit'])) {
......@@ -101,16 +104,19 @@ function angeltype_edit_controller() {
$restricted = isset($_REQUEST['restricted']);
if (isset($_REQUEST['description']))
$description = strip_request_item_nl('description');
if ($ok) {
$restricted = $restricted ? 1 : 0;
if (isset($angeltype)) {
$result = AngelType_update($angeltype['id'], $name, $restricted);
$result = AngelType_update($angeltype['id'], $name, $restricted, $description);
if ($result === false)
engelsystem_error("Unable to update angeltype.");
engelsystem_log("Updated angeltype: " . $name . ", restricted: " . $restricted);
$angeltype_id = $angeltype['id'];
} else {
$angeltype_id = AngelType_create($name, $restricted);
$angeltype_id = AngelType_create($name, $restricted, $description);
if ($angeltype_id === false)
engelsystem_error("Unable to create angeltype.");
engelsystem_log("Created angeltype: " . $name . ", restricted: " . $restricted);
......@@ -123,7 +129,7 @@ function angeltype_edit_controller() {
return array(
isset($angeltype) ? sprintf(_("Edit %s"), $name) : _("Add new angeltype"),
AngelType_edit_view($name, $restricted)
AngelType_edit_view($name, $restricted, $description)
);
}
......
......@@ -17,12 +17,14 @@ function AngelType_delete($angeltype) {
* @param int $angeltype_id
* @param string $name
* @param boolean $restricted
* @param string $description
*/
function AngelType_update($angeltype_id, $name, $restricted) {
function AngelType_update($angeltype_id, $name, $restricted, $description) {
return sql_query("
UPDATE `AngelTypes` SET
`name`='" . sql_escape($name) . "',
`restricted`=" . sql_escape($restricted ? 1 : 0) . "
`restricted`=" . sql_escape($restricted ? 1 : 0) . ",
`description`='" . sql_escape($description) . "'
WHERE `id`=" . sql_escape($angeltype_id) . "
LIMIT 1");
}
......@@ -32,13 +34,15 @@ function AngelType_update($angeltype_id, $name, $restricted) {
*
* @param string $name
* @param boolean $restricted
* @param string $description
* @return New Angeltype id
*/
function AngelType_create($name, $restricted) {
function AngelType_create($name, $restricted, $description) {
$result = sql_query("
INSERT INTO `AngelTypes` SET
`name`='" . sql_escape($name) . "',
`restricted`=" . sql_escape($restricted ? 1 : 0));
`restricted`=" . sql_escape($restricted ? 1 : 0) . "
`description`='" . sql_escape($description) . "'");
if ($result === false)
return false;
return sql_id();
......
......@@ -10,7 +10,7 @@ function AngelType_delete_view($angeltype) {
));
}
function AngelType_edit_view($name, $restricted) {
function AngelType_edit_view($name, $restricted, $description) {
return page(array(
buttons(array(
button(page_link_to('angeltypes'), _("Angeltypes"), 'back')
......@@ -20,6 +20,8 @@ function AngelType_edit_view($name, $restricted) {
form_text('name', _("Name"), $name),
form_checkbox('restricted', _("Restricted"), $restricted),
form_info("", _("Restricted angel types can only be used by an angel if enabled by an archangel (double opt-in).")),
form_textarea('description', _("Description"), $description),
form_info("", _("Please use markdown for the description.")),
form_submit('submit', _("Save"))
))
));
......@@ -48,8 +50,11 @@ function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angel
buttons($buttons)
);
// $page[] = '<h3>' . _("Info") . '</h3>';
// Description + Team-Coordinators
$page[] = '<h3>' . _("Description") . '</h3>';
$parsedown = new Parsedown();
$page[] = $parsedown->parse($angeltype['description']);
// Team-Coordinators list missing
$page[] = '<h3>' . _("Members") . '</h3>';
$members_confirmed = array();
......
<?php
// path and include settings
$rootpath = str_replace(DIRECTORY_SEPARATOR . 'bootstrap.php', '', __FILE__);
$rootpath = __DIR__ . DIRECTORY_SEPARATOR . '..';
define('ROOTPATH', $rootpath);
$includePath = ini_get('include_path');
$includePath .= PATH_SEPARATOR . ROOTPATH . DIRECTORY_SEPARATOR . '..';
$includePath .= PATH_SEPARATOR . ROOTPATH;
ini_set('include_path', $includePath);
?>
......@@ -58,6 +58,8 @@ require_once ('includes/pages/user_settings.php');
require_once ('includes/pages/user_shifts.php');
require_once ('includes/pages/user_wakeup.php');
require_once ('vendor/parsedown-0.9.0/Parsedown.php');
session_start();
gettext_init();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment