• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP engelsystem_log函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中engelsystem_log函数的典型用法代码示例。如果您正苦于以下问题:PHP engelsystem_log函数的具体用法?PHP engelsystem_log怎么用?PHP engelsystem_log使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了engelsystem_log函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: user_edit_vouchers_controller

function user_edit_vouchers_controller()
{
    global $privileges, $user;
    if (isset($_REQUEST['user_id'])) {
        $user_source = User($_REQUEST['user_id']);
    } else {
        $user_source = $user;
    }
    if (!in_array('admin_user', $privileges)) {
        redirect(page_link_to(''));
    }
    if (isset($_REQUEST['submit'])) {
        $ok = true;
        if (isset($_REQUEST['vouchers']) && test_request_int('vouchers') && trim($_REQUEST['vouchers']) >= 0) {
            $vouchers = trim($_REQUEST['vouchers']);
        } else {
            $ok = false;
            error(_("Please enter a valid number of vouchers."));
        }
        if ($ok) {
            $user_source['got_voucher'] = $vouchers;
            $result = User_update($user_source);
            if ($result === false) {
                engelsystem_error('Unable to update user.');
            }
            success(_("Saved the number of vouchers."));
            engelsystem_log(User_Nick_render($user_source) . ': ' . sprintf("Got %s vouchers", $user_source['got_voucher']));
            redirect(user_link($user_source));
        }
    }
    return array(sprintf(_("%s's vouchers"), $user_source['Nick']), User_edit_vouchers_view($user_source));
}
开发者ID:avahldiek,项目名称:engelsystem,代码行数:32,代码来源:users_controller.php


示例2: engelsystem_email

function engelsystem_email($recipient, $subject, $body)
{
    global $mailConfig;
    $transport = Swift_SmtpTransport::newInstance($mailConfig['smtp_host'], $mailConfig['smtp_port'], $mailConfig['smtp_transport'])->setUsername($mailConfig['smtp_user'])->setPassword($mailConfig['smtp_password']);
    $mailer = Swift_Mailer::newInstance($transport);
    $message = Swift_Message::newInstance($subject)->setFrom(array($mailConfig['sender_address'] => $mailConfig['sender_name']))->setTo(array($recipient))->setBody($body);
    $result = $mailer->send($message);
    engelsystem_log("Send email (result=\"{$result}\") to \"{$recipient}\" about \"{$subject}\". <br>Full message: \"{$body}\"");
    return $result;
}
开发者ID:Grreg,项目名称:engelsystem,代码行数:10,代码来源:email_helper.php


示例3: admin_news

function admin_news()
{
    global $user;
    if (!isset($_GET["action"])) {
        redirect(page_link_to("news"));
    } else {
        $html = '<div class="col-md-12"><h1>' . _("Edit news entry") . '</h1>' . msg();
        if (isset($_REQUEST['id']) && preg_match("/^[0-9]{1,11}\$/", $_REQUEST['id'])) {
            $id = $_REQUEST['id'];
        } else {
            return error("Incomplete call, missing News ID.", true);
        }
        $news = sql_select("SELECT * FROM `News` WHERE `ID`='" . sql_escape($id) . "' LIMIT 1");
        if (count($news) > 0) {
            switch ($_REQUEST["action"]) {
                default:
                    redirect(page_link_to('news'));
                case 'edit':
                    list($news) = $news;
                    $user_source = User($news['UID']);
                    if ($user_source === false) {
                        engelsystem_error("Unable to load user.");
                    }
                    $html .= form(array(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=' . $id));
                    $html .= '<a class="btn btn-danger" href="' . page_link_to('admin_news&action=delete&id=' . $id) . '"><span class="glyphicon glyphicon-trash"></span> ' . _("Delete") . '</a>';
                    break;
                case 'save':
                    list($news) = $news;
                    sql_query("UPDATE `News` SET \n              `Datum`='" . sql_escape(time()) . "', \n              `Betreff`='" . sql_escape($_POST["eBetreff"]) . "', \n              `Text`='" . sql_escape($_POST["eText"]) . "', \n              `UID`='" . sql_escape($user['UID']) . "', \n              `Treffen`='" . sql_escape($_POST["eTreffen"]) . "' \n              WHERE `ID`='" . sql_escape($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($id) . "' LIMIT 1");
                    engelsystem_log("News deleted: " . $news['Betreff']);
                    success(_("News entry deleted."));
                    redirect(page_link_to("news"));
                    break;
            }
        } else {
            return error("No News found.", true);
        }
    }
    return $html . '</div>';
}
开发者ID:max-weller,项目名称:engelsystem,代码行数:47,代码来源:admin_news.php


示例4: user_got_voucher_controller

function user_got_voucher_controller()
{
    global $privileges, $user;
    if (isset($_REQUEST['user_id'])) {
        $user_source = User($_REQUEST['user_id']);
    } else {
        $user_source = $user;
    }
    $admin_user_privilege = in_array('admin_user', $privileges);
    if (!in_array('admin_user', $privileges)) {
        redirect(page_link_to(''));
    }
    if (!isset($_REQUEST['got_voucher'])) {
        redirect(page_link_to(''));
    }
    $user_source['got_voucher'] = $_REQUEST['got_voucher'] == 'true';
    $result = User_update($user_source);
    if ($result === false) {
        engelsystem_error('Unable to update user.');
    }
    success($user_source['got_voucher'] ? _('User got vouchers.') : _('User didnt got vouchers.'));
    engelsystem_log(User_Nick_render($user_source) . ($user_source['got_voucher'] ? ' got vouchers' : ' didnt got vouchers'));
    redirect(user_link($user_source));
}
开发者ID:20-100,项目名称:engelsystem,代码行数:24,代码来源:users_controller.php


示例5: angeltype_edit_controller

/**
 * Change an Angeltype.
 */
function angeltype_edit_controller()
{
    global $privileges, $user;
    $name = "";
    $restricted = false;
    $description = "";
    if (isset($_REQUEST['angeltype_id'])) {
        $angeltype = AngelType($_REQUEST['angeltype_id']);
        if ($angeltype === false) {
            engelsystem_error("Unable to load angeltype.");
        }
        if ($angeltype == null) {
            redirect(page_link_to('angeltypes'));
        }
        $name = $angeltype['name'];
        $restricted = $angeltype['restricted'];
        $description = $angeltype['description'];
        if (!User_is_AngelType_coordinator($user, $angeltype)) {
            redirect(page_link_to('angeltypes'));
        }
    } else {
        if (!in_array('admin_angel_types', $privileges)) {
            redirect(page_link_to('angeltypes'));
        }
    }
    // In coordinator mode only allow to modify description
    $coordinator_mode = !in_array('admin_angel_types', $privileges);
    if (isset($_REQUEST['submit'])) {
        $ok = true;
        if (!$coordinator_mode) {
            if (isset($_REQUEST['name'])) {
                list($valid, $name) = AngelType_validate_name($_REQUEST['name'], $angeltype);
                if (!$valid) {
                    $ok = false;
                    error(_("Please check the name. Maybe it already exists."));
                }
            }
            $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, $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, $description);
                if ($angeltype_id === false) {
                    engelsystem_error("Unable to create angeltype.");
                }
                engelsystem_log("Created angeltype: " . $name . ", restricted: " . $restricted);
            }
            success("Angel type saved.");
            redirect(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype_id);
        }
    }
    return array(sprintf(_("Edit %s"), $name), AngelType_edit_view($name, $restricted, $description, $coordinator_mode));
}
开发者ID:max-weller,项目名称:engelsystem,代码行数:67,代码来源:angeltypes_controller.php


示例6: user_driver_license_edit_controller

/**
 * Edit a users driver license information.
 */
function user_driver_license_edit_controller()
{
    global $privileges, $user;
    if (isset($_REQUEST['user_id'])) {
        $user_source = User($_REQUEST['user_id']);
        if ($user_source === false) {
            engelsystem_error('Unable to load angeltype.');
        }
        if ($user_source == null) {
            redirect(user_driver_license_edit_link());
        }
        // only privilege admin_user can edit other users driver license information
        if ($user['UID'] != $user_source['UID'] && !in_array('admin_user', $privileges)) {
            redirect(user_driver_license_edit_link());
        }
    } else {
        $user_source = $user;
    }
    $wants_to_drive = false;
    $has_car = false;
    $has_license_car = false;
    $has_license_3_5t_transporter = false;
    $has_license_7_5t_truck = false;
    $has_license_12_5t_truck = false;
    $has_license_forklift = false;
    $user_driver_license = UserDriverLicense($user_source['UID']);
    if ($user_driver_license === false) {
        engelsystem_error('Unable to load user driver license.');
    }
    if ($user_driver_license != null) {
        $wants_to_drive = true;
        $has_car = $user_driver_license['has_car'];
        $has_license_car = $user_driver_license['has_license_car'];
        $has_license_3_5t_transporter = $user_driver_license['has_license_3_5t_transporter'];
        $has_license_7_5t_truck = $user_driver_license['has_license_7_5t_truck'];
        $has_license_12_5t_truck = $user_driver_license['has_license_12_5t_truck'];
        $has_license_forklift = $user_driver_license['has_license_forklift'];
    }
    if (isset($_REQUEST['submit'])) {
        $ok = true;
        $wants_to_drive = isset($_REQUEST['wants_to_drive']);
        $has_car = isset($_REQUEST['has_car']);
        $has_license_car = isset($_REQUEST['has_license_car']);
        $has_license_3_5t_transporter = isset($_REQUEST['has_license_3_5t_transporter']);
        $has_license_7_5t_truck = isset($_REQUEST['has_license_7_5t_truck']);
        $has_license_12_5t_truck = isset($_REQUEST['has_license_12_5t_truck']);
        $has_license_forklift = isset($_REQUEST['has_license_forklift']);
        if ($wants_to_drive && !$has_license_car && !$has_license_3_5t_transporter && !$has_license_7_5t_truck && !$has_license_12_5t_truck && !$has_license_forklift) {
            $ok = false;
            error(_("Please select at least one driving license."));
        }
        if ($ok) {
            if (!$wants_to_drive && $user_driver_license != null) {
                $result = UserDriverLicenses_delete($user_source['UID']);
                if ($result === false) {
                    engelsystem_error("Unable to remove user driver license information");
                }
                engelsystem_log("Driver license information removed.");
                success(_("Your driver license information has been removed."));
            } else {
                if ($wants_to_drive) {
                    if ($user_driver_license == null) {
                        $result = UserDriverLicenses_create($user_source['UID'], $has_car, $has_license_car, $has_license_3_5t_transporter, $has_license_7_5t_truck, $has_license_12_5t_truck, $has_license_forklift);
                    } else {
                        $result = UserDriverLicenses_update($user_source['UID'], $has_car, $has_license_car, $has_license_3_5t_transporter, $has_license_7_5t_truck, $has_license_12_5t_truck, $has_license_forklift);
                    }
                    if ($result === false) {
                        engelsystem_error("Unable to save user driver license information.");
                    }
                    engelsystem_log("Driver license information updated.");
                }
                success(_("Your driver license information has been saved."));
            }
            redirect(user_link($user_source));
        }
    }
    return [sprintf(_("Edit %s driving license information"), $user_source['Nick']), UserDriverLicense_edit_view($user_source, $wants_to_drive, $has_car, $has_license_car, $has_license_3_5t_transporter, $has_license_7_5t_truck, $has_license_12_5t_truck, $has_license_forklift)];
}
开发者ID:bjelline,项目名称:engelsystem,代码行数:81,代码来源:user_driver_licenses_controller.php


示例7: admin_arrive

function admin_arrive()
{
    $msg = "";
    $search = "";
    if (isset($_REQUEST['search'])) {
        $search = strip_request_item('search');
    }
    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, `arrival_date` = NULL WHERE `UID`='" . sql_escape($id) . "' LIMIT 1");
            engelsystem_log("User set to not available: " . User_Nick_render($user_source));
            $msg = success(_("Reset done. Angel is not available."), 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, `arrival_date`='" . time() . "' WHERE `UID`='" . sql_escape($id) . "' LIMIT 1");
            engelsystem_log("User is available: " . User_Nick_render($user_source));
            $msg = success(_("Angel has been marked as available."), true);
        } else {
            $msg = error(_("Angel not found."), true);
        }
    }
    $users = sql_select("SELECT * FROM `User` ORDER BY `Nick`");
    $arrival_count_at_day = [];
    $planned_arrival_count_at_day = [];
    $planned_departure_count_at_day = [];
    $table = "";
    $users_matched = [];
    if ($search == "") {
        $tokens = [];
    } else {
        $tokens = explode(" ", $search);
    }
    foreach ($users as $usr) {
        if (count($tokens) > 0) {
            $match = false;
            $index = join(" ", $usr);
            foreach ($tokens as $t) {
                if (stristr($index, trim($t))) {
                    $match = true;
                    break;
                }
            }
            if (!$match) {
                continue;
            }
        }
        $usr['nick'] = User_Nick_render($usr);
        if ($usr['planned_departure_date'] != null) {
            $usr['rendered_planned_departure_date'] = date('Y-m-d', $usr['planned_departure_date']);
        } else {
            $usr['rendered_planned_departure_date'] = '-';
        }
        $usr['rendered_planned_arrival_date'] = date('Y-m-d', $usr['planned_arrival_date']);
        $usr['rendered_arrival_date'] = $usr['arrival_date'] > 0 ? date('Y-m-d', $usr['arrival_date']) : "-";
        $usr['arrived'] = $usr['Gekommen'] == 1 ? _("yes") : "";
        $usr['actions'] = $usr['Gekommen'] == 1 ? '<a href="' . page_link_to('admin_arrive') . '&reset=' . $usr['UID'] . '&search=' . $search . '">' . _("reset") . '</a>' : '<a href="' . page_link_to('admin_arrive') . '&arrived=' . $usr['UID'] . '&search=' . $search . '">' . _("available") . '</a>';
        if ($usr['arrival_date'] > 0) {
            $day = date('Y-m-d', $usr['arrival_date']);
            if (!isset($arrival_count_at_day[$day])) {
                $arrival_count_at_day[$day] = 0;
            }
            $arrival_count_at_day[$day]++;
        }
        if ($usr['planned_arrival_date'] != null) {
            $day = date('Y-m-d', $usr['planned_arrival_date']);
            if (!isset($planned_arrival_count_at_day[$day])) {
                $planned_arrival_count_at_day[$day] = 0;
            }
            $planned_arrival_count_at_day[$day]++;
        }
        if ($usr['planned_departure_date'] != null && $usr['Gekommen'] == 1) {
            $day = date('Y-m-d', $usr['planned_departure_date']);
            if (!isset($planned_departure_count_at_day[$day])) {
                $planned_departure_count_at_day[$day] = 0;
            }
            $planned_departure_count_at_day[$day]++;
        }
        $users_matched[] = $usr;
    }
    ksort($arrival_count_at_day);
    ksort($planned_arrival_count_at_day);
    ksort($planned_departure_count_at_day);
    $arrival_at_day = [];
    $arrival_sum = 0;
    foreach ($arrival_count_at_day as $day => $count) {
        $arrival_sum += $count;
        $arrival_at_day[$day] = ['day' => $day, 'count' => $count, 'sum' => $arrival_sum];
    }
    $planned_arrival_sum_at_day = [];
    $planned_arrival_sum = 0;
    foreach ($planned_arrival_count_at_day as $day => $count) {
        $planned_arrival_sum += $count;
        $planned_arrival_at_day[$day] = ['day' => $day, 'count' => $count, 'sum' => $planned_arrival_sum];
//.........这里部分代码省略.........
开发者ID:kekru,项目名称:engelsystem,代码行数:101,代码来源:admin_arrive.php


示例8: user_shifts

function user_shifts()
{
    global $user, $privileges, $max_freeloadable_shifts;
    if (User_is_freeloader($user)) {
        redirect(page_link_to('user_myshifts'));
    }
    // Locations laden
    $rooms = sql_select("SELECT * FROM `Room` WHERE `show`='Y' ORDER BY `Name`");
    $room_array = array();
    foreach ($rooms as $room) {
        $room_array[$room['RID']] = $room['Name'];
    }
    // Löschen einzelner Schicht-Einträge (Also Belegung einer Schicht von Engeln) durch Admins
    if (isset($_REQUEST['entry_id']) && in_array('user_shifts_admin', $privileges)) {
        if (isset($_REQUEST['entry_id']) && test_request_int('entry_id')) {
            $entry_id = $_REQUEST['entry_id'];
        } else {
            redirect(page_link_to('user_shifts'));
        }
        $shift_entry_source = sql_select("\n        SELECT `User`.`Nick`, `ShiftEntry`.`Comment`, `ShiftEntry`.`UID`, `ShiftTypes`.`name`, `Shifts`.*, `Room`.`Name`, `AngelTypes`.`name` as `angel_type` \n        FROM `ShiftEntry` \n        JOIN `User` ON (`User`.`UID`=`ShiftEntry`.`UID`) \n        JOIN `AngelTypes` ON (`ShiftEntry`.`TID` = `AngelTypes`.`id`) \n        JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID`) \n        JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`)\n        JOIN `Room` ON (`Shifts`.`RID` = `Room`.`RID`) \n        WHERE `ShiftEntry`.`id`='" . sql_escape($entry_id) . "'");
        if (count($shift_entry_source) > 0) {
            $shift_entry_source = $shift_entry_source[0];
            $result = ShiftEntry_delete($entry_id);
            if ($result === false) {
                engelsystem_error('Unable to delete shift entry.');
            }
            engelsystem_log("Deleted " . User_Nick_render($shift_entry_source) . "'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(_("Shift entry deleted."));
        } else {
            error(_("Entry not found."));
        }
        redirect(page_link_to('user_shifts'));
    } elseif (isset($_REQUEST['edit_shift']) && in_array('admin_shifts', $privileges)) {
        $msg = "";
        $ok = true;
        if (isset($_REQUEST['edit_shift']) && test_request_int('edit_shift')) {
            $shift_id = $_REQUEST['edit_shift'];
        } else {
            redirect(page_link_to('user_shifts'));
        }
        $shift = sql_select("\n        SELECT `ShiftTypes`.`name`, `Shifts`.*, `Room`.* FROM `Shifts` \n        JOIN `Room` ON (`Shifts`.`RID` = `Room`.`RID`) \n        JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`)\n        WHERE `SID`='" . sql_escape($shift_id) . "'");
        if (count($shift) == 0) {
            redirect(page_link_to('user_shifts'));
        }
        $shift = $shift[0];
        // Engeltypen laden
        $types = sql_select("SELECT * FROM `AngelTypes` ORDER BY `name`");
        $angel_types = array();
        $needed_angel_types = array();
        foreach ($types as $type) {
            $angel_types[$type['id']] = $type;
            $needed_angel_types[$type['id']] = 0;
        }
        $shifttypes_source = ShiftTypes();
        $shifttypes = [];
        foreach ($shifttypes_source as $shifttype) {
            $shifttypes[$shifttype['id']] = $shifttype['name'];
        }
        // 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`");
        foreach ($needed_angel_types_source as $type) {
            if ($type['count'] != "") {
                $needed_angel_types[$type['id']] = $type['count'];
            }
        }
        // Benötigte Engeltypen von der Schicht
        $needed_angel_types_source = sql_select("SELECT `AngelTypes`.*, `NeededAngelTypes`.`count` FROM `AngelTypes` LEFT JOIN `NeededAngelTypes` ON (`NeededAngelTypes`.`angel_type_id` = `AngelTypes`.`id` AND `NeededAngelTypes`.`shift_id`='" . sql_escape($shift_id) . "') ORDER BY `AngelTypes`.`name`");
        foreach ($needed_angel_types_source as $type) {
            if ($type['count'] != "") {
                $needed_angel_types[$type['id']] = $type['count'];
            }
        }
        $shifttype_id = $shift['shifttype_id'];
        $title = $shift['title'];
        $rid = $shift['RID'];
        $start = $shift['start'];
        $end = $shift['end'];
        if (isset($_REQUEST['submit'])) {
            // Name/Bezeichnung der Schicht, darf leer sein
            $title = strip_request_item('title');
            // Auswahl der sichtbaren Locations für die Schichten
            if (isset($_REQUEST['rid']) && preg_match("/^[0-9]+\$/", $_REQUEST['rid']) && isset($room_array[$_REQUEST['rid']])) {
                $rid = $_REQUEST['rid'];
            } else {
                $ok = false;
                $rid = $rooms[0]['RID'];
                $msg .= error(_("Please select a room."), true);
            }
            if (isset($_REQUEST['shifttype_id']) && isset($shifttypes[$_REQUEST['shifttype_id']])) {
                $shifttype_id = $_REQUEST['shifttype_id'];
            } else {
                $ok = false;
                $msg .= error(_('Please select a shifttype.'), true);
            }
            if (isset($_REQUEST['start']) && ($tmp = DateTime::createFromFormat("Y-m-d H:i", trim($_REQUEST['start'])))) {
                $start = $tmp->getTimestamp();
            } else {
                $ok = false;
                $msg .= error(_("Please enter a valid starting time for the shifts."), true);
            }
//.........这里部分代码省略.........
开发者ID:Bartzi,项目名称:engelsystem,代码行数:101,代码来源:user_shifts.php


示例9: user_angeltype_add_controller

/**
 * User joining an Angeltype (Or Coordinator doing this for him).
 */
function user_angeltype_add_controller()
{
    global $user, $privileges;
    if (!isset($_REQUEST['angeltype_id'])) {
        error(_("Angeltype doesn't exist."));
        redirect(page_link_to('angeltypes'));
    }
    $angeltype = AngelType($_REQUEST['angeltype_id']);
    if ($angeltype === false) {
        engelsystem_error("Unable to load angeltype.");
    }
    if ($angeltype == null) {
        error(_("Angeltype doesn't exist."));
        redirect(page_link_to('angeltypes'));
    }
    if (User_is_AngelType_coordinator($user, $angeltype)) {
        // Allow to add any user
        $user_id = $user['UID'];
        $users_source = Users_by_angeltype_inverted($angeltype);
        if ($users_source === false) {
            engelsystem_error("Unable to load users.");
        }
        if (isset($_REQUEST['submit'])) {
            $ok = true;
            if (isset($_REQUEST['user_id']) && in_array($_REQUEST['user_id'], array_map(function ($user) {
                return $user['UID'];
            }, $users_source))) {
                $user_id = $_REQUEST['user_id'];
            } else {
                $ok = false;
                error(_("Please select a user."));
            }
            if ($ok) {
                foreach ($users_source as $user_source) {
                    if ($user_source['UID'] == $user_id) {
                        $user_angeltype_id = UserAngelType_create($user_source, $angeltype);
                        if ($user_angeltype_id === false) {
                            engelsystem_error("Unable to create user angeltype.");
                        }
                        engelsystem_log(sprintf("User %s added to %s.", User_Nick_render($user_source), AngelType_name_render($angeltype)));
                        success(sprintf(_("User %s added to %s."), User_Nick_render($user_source), AngelType_name_render($angeltype)));
                        $result = UserAngelType_confirm($user_angeltype_id, $user_source);
                        if ($result === false) {
                            engelsystem_error("Unable to confirm user angeltype.");
                        }
                        engelsystem_log(sprintf("User %s confirmed as %s.", User_Nick_render($user), AngelType_name_render($angeltype)));
                        redirect(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id']);
                    }
                }
            }
        }
        return array(_("Add user to angeltype"), UserAngelType_add_view($angeltype, $users_source, $user_id));
    } else {
        // Allow only me
        $user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
        if ($user_angeltype === false) {
            engelsystem_error("Unable to load user angeltype.");
        }
        if ($user_angeltype != null) {
            error(sprintf(_("You are already a %s."), $angeltype['name']));
            redirect(page_link_to('angeltypes'));
        }
        if (isset($_REQUEST['confirmed'])) {
            $user_angeltype_id = UserAngelType_create($user, $angeltype);
            if ($user_angeltype_id === false) {
                engelsystem_error("Unable to create user angeltype.");
            }
            $success_message = sprintf(_("You joined %s."), $angeltype['name']);
            engelsystem_log(sprintf("User %s joined %s.", User_Nick_render($user), AngelType_name_render($angeltype)));
            success($success_message);
            if (in_array('admin_user_angeltypes', $privileges)) {
                $result = UserAngelType_confirm($user_angeltype_id, $user);
                if ($result === false) {
                    engelsystem_error("Unable to confirm user angeltype.");
                }
                engelsystem_log(sprintf("User %s confirmed as %s.", User_Nick_render($user), AngelType_name_render($angeltype)));
            }
            redirect(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id']);
        }
        return array(sprintf(_("Become a %s"), $angeltype['name']), UserAngelType_join_view($user, $angeltype));
    }
}
开发者ID:bjelline,项目名称:engelsystem,代码行数:85,代码来源:user_angeltypes_controller.php


示例10: admin_shifts


//.........这里部分代码省略.........
                $shift_start = $start;
                do {
                    $shift_end = $shift_start + $length * 60;
                    if ($shift_end > $end) {
                        $shift_end = $end;
                    }
                    if ($shift_start >= $shift_end) {
                        break;
                    }
                    $shifts[] = array('start' => $shift_start, 'end' => $shift_end, 'RID' => $rid, 'title' => $title, 'shifttype_id' => $shifttype_id);
                    $shift_start = $shift_end;
                } while ($shift_end < $end);
            } elseif ($mode == 'variable') {
                rsort($change_hours);
                $day = DateTime::createFromFormat("Y-m-d H:i", date("Y-m-d", $start) . " 00:00")->getTimestamp();
                $change_index = 0;
                // Ersten/nächsten passenden Schichtwechsel suchen
                foreach ($change_hours as $i => $change_hour) {
                    if ($start < $day + $change_hour * 60 * 60) {
                        $change_index = $i;
                    } elseif ($start == $day + $change_hour * 60 * 60) {
                        // Start trifft Schichtwechsel
                        $change_index = ($i + count($change_hours) - 1) % count($change_hours);
                        break;
                    } else {
                        break;
                    }
                }
                $shift_start = $start;
                do {
                    $day = DateTime::createFromFormat("Y-m-d H:i", date("Y-m-d", $shift_start) . " 00:00")->getTimestamp();
                    $shift_end = $day + $change_hours[$change_index] * 60 * 60;
                    if ($shift_end > $end) {
                        $shift_end = $end;
                    }
                    if ($shift_start >= $shift_end) {
                        $shift_end += 24 * 60 * 60;
                    }
                    $shifts[] = array('start' => $shift_start, 'end' => $shift_end, 'RID' => $rid, 'title' => $title, 'shifttype_id' => $shifttype_id);
                    $shift_start = $shift_end;
                    $change_index = ($change_index + count($change_hours) - 1) % count($change_hours);
                } while ($shift_end < $end);
            }
            $shifts_table = array();
            foreach ($shifts as $shift) {
                $shifts_table_entry = ['timeslot' => '<span class="glyphicon glyphicon-time"></span> ' . date("Y-m-d H:i", $shift['start']) . ' - ' . date("H:i", $shift['end']) . '<br />' . Room_name_render(Room($shift['RID'])), 'title' => ShiftType_name_render(ShiftType($shifttype_id)) . ($shift['title'] ? '<br />' . $shift['title'] : ''), 'needed_angels' => ''];
                foreach ($types as $type) {
                    if (isset($needed_angel_types[$type['id']]) && $needed_angel_types[$type['id']] > 0) {
                        $shifts_table_entry['needed_angels'] .= '<b>' . AngelType_name_render($type) . ':</b> ' . $needed_angel_types[$type['id']] . '<br />';
                    }
                }
                $shifts_table[] = $shifts_table_entry;
            }
            // Fürs Anlegen zwischenspeichern:
            $_SESSION['admin_shifts_shifts'] = $shifts;
            $_SESSION['admin_shifts_types'] = $needed_angel_types;
            $hidden_types = "";
            foreach ($needed_angel_types as $type_id => $count) {
                $hidden_types .= form_hidden('type_' . $type_id, $count);
            }
            return page_with_title(_("Preview"), array(form(array($hidden_types, form_hidden('shifttype_id', $shifttype_id), form_hidden('title', $title), form_hidden('rid', $rid), form_hidden('start', date("Y-m-d H:i", $start)), form_hidden('end', date("Y-m-d H:i", $end)), form_hidden('mode', $mode), form_hidden('length', $length), form_hidden('change_hours', implode(', ', $change_hours)), form_hidden('angelmode', $angelmode), form_submit('back', _("back")), table(array('timeslot' => _('Time and location'), 'title' => _('Type and title'), 'needed_angels' => _('Needed angels')), $shifts_table), form_submit('submit', _("Save"))))));
        }
    } elseif (isset($_REQUEST['submit'])) {
        if (!is_array($_SESSION['admin_shifts_shifts']) || !is_array($_SESSION['admin_shifts_types'])) {
            redirect(page_link_to('admin_shifts'));
        }
        foreach ($_SESSION['admin_shifts_shifts'] as $shift) {
            $shift['URL'] = null;
            $shift['PSID'] = null;
            $shift_id = Shift_create($shift);
            if ($shift_id === false) {
                engelsystem_error('Unable to create shift.');
            }
            engelsystem_log("Shift created: " . $shifttypes[$shift['shifttype_id']] . " with title " . $shift['title'] . " 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));
        success("Schichten angelegt.");
        redirect(page_link_to('admin_shifts'));
    } else {
        unset($_SESSION['admin_shifts_shifts']);
        unset($_SESSION['admin_shifts_types']);
    }
    if (!isset($_REQUEST['rid'])) {
        $_REQUEST['rid'] = null;
    }
    $room_select = html_select_key('rid', 'rid', $room_array, $_REQUEST['rid']);
    $angel_types = "";
    foreach ($types as $type) {
        $angel_types .= form_spinner('type_' . $type['id'], $type['name'], $needed_angel_types[$type['id']]);
    }
    return page_with_title(admin_shifts_title(), array(msg(), form(array(form_select('shifttype_id', _('Shifttype'), $shifttypes, $shifttype_id), form_text('title', _("Title"), $title), form_select('rid', _("Room"), $room_array, $_REQUEST['rid']), '<div class="row">', '<div class="col-md-6">', form_text('start', _("Start"), date("Y-m-d H:i", $start)), form_text('end', _("End"), date("Y-m-d H:i", $end)), form_info(_("Mode"), ''), form_radio('mode', _("Create one shift"), $mode == 'single', 'single'), form_radio('mode', _("Create multiple shifts"), $mode == 'multi', 'multi'), form_text('length', _("Length"), !empty($_REQUEST['length']) ? $_REQUEST['length'] : '120'), form_radio('mode', _("Create multiple shifts with variable length"), $mode == 'variable', 'variable'), form_text('change_hours', _("Shift change hours"), !empty($_REQUEST['change_hours']) ? $_REQUEST['change_hours'] : '00, 04, 08, 10, 12, 14, 16, 18, 20, 22'), '</div>', '<div class="col-md-6">', form_info(_("Needed angels"), ''), form_radio('angelmode', _("Take needed angels from room settings"), $angelmode == 'location', 'location'), form_radio('angelmode', _("The following angels are needed"), $angelmode == 'manually', 'manually'), $angel_types, '</div>', '</div>', form_submit('preview', _("Preview"))))));
}
开发者ID:20-100,项目名称:engelsystem,代码行数:101,代码来源:admin_shifts.php


示例11: admin_arrive

function admin_arrive()
{
    $msg = "";
    $search = "";
    if (isset($_REQUEST['search'])) {
        $search = strip_request_item('search');
    }
    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, `arrival_date` = NULL WHERE `UID`='" . sql_escape($id) . "' LIMIT 1");
            engelsystem_log("User set to not arrived: " . User_Nick_render($user_source));
            $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, `arrival_date`='" . time() . "' WHERE `UID`='" . sql_escape($id) . "' LIMIT 1");
            engelsystem_log("User set has arrived: " . User_Nick_render($user_source));
            $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`");
    $arrival_count_at_day = array();
    $table = "";
    $users_matched = array();
    if ($search == "") {
        $tokens = array();
    } else {
        $tokens = explode(" ", $search);
    }
    foreach ($users as $usr) {
        if (count($tokens) > 0) {
            $match = false;
            $index = join(" ", $usr);
            foreach ($tokens as $t) {
                if (stristr($index, trim($t))) {
                    $match = true;
                    break;
                }
            }
            if (!$match) {
                continue;
            }
        }
        $usr['nick'] = User_Nick_render($usr);
        $usr['rendered_planned_arrival_date'] = date('Y-m-d', $usr['planned_arrival_date']);
        $usr['rendered_arrival_date'] = $usr['arrival_date'] > 0 ? date('Y-m-d', $usr['arrival_date']) : "-";
        $usr['arrived'] = $usr['Gekommen'] == 1 ? _("yes") : "";
        $usr['actions'] = $usr['Gekommen'] == 1 ? '<a href="' . page_link_to('admin_arrive') . '&reset=' . $usr['UID'] . '&search=' . $search . '">' . _("reset") . '</a>' : '<a href="' . page_link_to('admin_arrive') . '&arrived=' . $usr['UID'] . '&search=' . $search . '">' . _("arrived") . '</a>';
        $day = $usr['arrival_date'] > 0 ? date('Y-m-d', $usr['arrival_date']) : date('Y-m-d', $usr['planned_arrival_date']);
        if (!isset($arrival_count_at_day[$day])) {
            $arrival_count_at_day[$day] = 0;
        }
        $arrival_count_at_day[$day]++;
        $users_matched[] = $usr;
    }
    ksort($arrival_count_at_day);
    $arrival_count = array();
    $arrival_sums = array();
    $arrival_sum = 0;
    foreach ($arrival_count_at_day as $day => $count) {
        $arrival_sum += $count;
        $arrival_sums[$day] = $arrival_sum;
        $arrival_count[] = array('day' => $day, 'count' => $count, 'sum' => $arrival_sum);
    }
    return page_with_title(admin_arrive_title(), array(msg(), form(array(form_text('search', _("Search"), $search), form_submit('submit', _("Search")))), table(array('nick' => _("Nickname"), 'rendered_planned_arrival_date' => _("Planned date"), 'arrived' => _("Arrived?"), 'rendered_arrival_date' => _("Arrival date"), 'actions' => ""), $users_matched), heading(_("Arrival statistics"), 2), '<canvas id="daily_arrives" style="width: 100%; height: 300px;"></canvas>
      <script type="text/javascript">
      $(function(){
        var ctx = $("#daily_arrives").get(0).getContext("2d");
        var chart = new Chart(ctx).Bar(' . json_encode(array('labels' => array_keys($arrival_count_at_day), 'datasets' => array(array('label' => _("arrived"), 'fillColor' => "#444", 'data' => array_values($arrival_count_at_day)), array('label' => _("arrived sum"), 'fillColor' => "#888", 'data' => array_values($arrival_sums))))) . ');
      });
      </script>', table(array('day' => _("Date"), 'count' => _("arrived"), 'sum' => _("arrived sum")), $arrival_count)));
}
开发者ID:Bartzi,项目名称:engelsystem,代码行数:80,代码来源:admin_arrive.php


示例12: admin_arrive

function admin_arrive()
{
    $msg = "";
    $search = "";
    if (isset($_REQUEST['search'])) {
        $search = strip_request_item('search');
    }
    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, `arrival_date` = NULL WHERE `UID`='" . sql_escape($id) . "' LIMIT 1");
            engelsystem_log("User set to not arrived: " . User_Nick_render($user_source));
            $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, `arrival_date`='" . time() . "' WHERE `UID`='" . sql_escape($id) . "' LIMIT 1");
            engelsystem_log("User set has arrived: " . User_Nick_render($user_source));
            $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`");
    $table = "";
    $users_matched = array();
    if ($search == "") {
        $tokens = array();
    } else {
        $tokens = explode(" ", $search);
    }
    foreach ($users as $usr) {
        if (count($tokens) > 0) {
            $match = false;
            $index = join(" ", $usr);
            foreach ($tokens as $t) {
                if (stristr($index, trim($t))) {
                    $match = true;
                    break;
                }
            }
            if (!$match) {
                continue;
            }
        }
        $table .= '<tr>';
        $table .= '<td>' . User_Nick_render($usr) . '</td>';
        $usr['nick'] = User_Nick_render($usr);
        $usr['planned_arrival_date'] = date('Y-m-d', $usr['planned_arrival_date']);
        $usr['arrival_date'] = $usr['arrival_date'] > 0 ? date('Y-m-d', $usr['arrival_date']) : "-";
        $usr['arrived'] = $usr['Gekommen'] == 1 ? _("yes") : "";
        $usr['actions'] = $usr['Gekommen'] == 1 ? '<a href="' . page_link_to('admin_arrive') . '&reset=' . $usr['UID'] . '&search=' . $search . '">' . _("reset") . '</a>' : '<a href="' . page_link_to('admin_arrive') . '&arrived=' . $usr['UID'] . '&search=' . $search . '">' . _("arrived") . '</a>';
        if ($usr['Gekommen'] == 1) {
            $table .= '<td>yes</td><td><a href="' . page_link_to('admin_arrive') . '&reset=' . $usr['UID'] . '&search=' . $search . '">reset</a></td>';
        } else {
            $table .= '<td></td><td><a href="' . page_link_to('admin_arrive') . '&arrived=' . $usr['UID'] . '&search=' . $search . '">arrived</a></td>';
        }
        $table .= '</tr>';
        $users_matched[] = $usr;
    }
    return page_with_title(admin_arrive_title(), array(msg(), form(array(form_text('search', _("Search"), $search), form_submit('submit', _("Search")))), table(array('nick' => _("Nickname"), 'planned_arrival_date' => _("Planned date"), 'arrived' => _("Arrived?"), 'arrival_date' => _("Arrival date"), 'actions' => ""), $users_matched)));
}
开发者ID:20-100,项目名称:engelsystem,代码行数:67,代码来源:admin_arrive.php


示例13: admin_rooms

<

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP english_date函数代码示例发布时间:2022-05-15
下一篇:
PHP engelsystem_error函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap