Reminder::showListForCentral PHP Method

showListForCentral() static public method

Show list for central view
static public showListForCentral ( $personal = true ) : Nothing
$personal boolean : display reminders created by me ? (true by default)
return Nothing (display function)
    static function showListForCentral($personal = true)
    {
        global $DB, $CFG_GLPI;
        $users_id = Session::getLoginUserID();
        $today = date('Y-m-d');
        $now = date('Y-m-d H:i:s');
        $restrict_visibility = " AND (`glpi_reminders`.`begin_view_date` IS NULL\n                                    OR `glpi_reminders`.`begin_view_date` < '{$now}')\n                              AND (`glpi_reminders`.`end_view_date` IS NULL\n                                   OR `glpi_reminders`.`end_view_date` > '{$now}') ";
        if ($personal) {
            /// Personal notes only for central view
            if ($_SESSION['glpiactiveprofile']['interface'] == 'helpdesk') {
                return false;
            }
            $query = "SELECT `glpi_reminders`.*\n                   FROM `glpi_reminders`\n                   WHERE `glpi_reminders`.`users_id` = '{$users_id}'\n                         AND (`glpi_reminders`.`end` >= '{$today}'\n                              OR `glpi_reminders`.`is_planned` = '0')\n                         {$restrict_visibility}\n                   ORDER BY `glpi_reminders`.`name`";
            $titre = "<a href='" . $CFG_GLPI["root_doc"] . "/front/reminder.php'>" . _n('Personal reminder', 'Personal reminders', Session::getPluralNumber()) . "</a>";
        } else {
            // Show public reminders / not mines : need to have access to public reminders
            if (!self::canView()) {
                return false;
            }
            $restrict_user = '1';
            // Only personal on central so do not keep it
            if ($_SESSION['glpiactiveprofile']['interface'] == 'central') {
                $restrict_user = "`glpi_reminders`.`users_id` <> '{$users_id}'";
            }
            $query = "SELECT `glpi_reminders`.*\n                   FROM `glpi_reminders` " . self::addVisibilityJoins() . "\n                   WHERE {$restrict_user}\n                         {$restrict_visibility}\n                         AND " . self::addVisibilityRestrict() . "\n                   ORDER BY `glpi_reminders`.`name`";
            if ($_SESSION['glpiactiveprofile']['interface'] != 'helpdesk') {
                $titre = "<a href=\"" . $CFG_GLPI["root_doc"] . "/front/reminder.php\">" . _n('Public reminder', 'Public reminders', Session::getPluralNumber()) . "</a>";
            } else {
                $titre = _n('Public reminder', 'Public reminders', Session::getPluralNumber());
            }
        }
        $result = $DB->query($query);
        $nb = $DB->numrows($result);
        echo "<br><table class='tab_cadrehov'>";
        echo "<tr class='noHover'><th><div class='relative'><span>{$titre}</span>";
        if ($personal && self::canCreate() || !$personal && Session::haveRight(self::$rightname, CREATE)) {
            echo "<span class='floatright'>";
            echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/reminder.form.php'>";
            echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/plus.png' alt='" . __s('Add') . "'\n                title=\"" . __s('Add') . "\"></a></span>";
        }
        echo "</div></th></tr>\n";
        if ($nb) {
            $rand = mt_rand();
            while ($data = $DB->fetch_assoc($result)) {
                echo "<tr class='tab_bg_2'><td>";
                $link = "<a id='content_reminder_" . $data["id"] . $rand . "'\n                      href='" . $CFG_GLPI["root_doc"] . "/front/reminder.form.php?id=" . $data["id"] . "'>" . $data["name"] . "</a>";
                $tooltip = Html::showToolTip(Toolbox::unclean_html_cross_side_scripting_deep($data["text"]), array('applyto' => "content_reminder_" . $data["id"] . $rand, 'display' => false));
                printf(__('%1$s %2$s'), $link, $tooltip);
                if ($data["is_planned"]) {
                    $tab = explode(" ", $data["begin"]);
                    $date_url = $tab[0];
                    echo "<span class='floatright'>";
                    echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/planning.php?date=" . $date_url . "&amp;type=day'>";
                    echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/rdv.png' alt=\"" . __s('Planning') . "\" title=\"" . sprintf(__s('From %1$s to %2$s'), Html::convDateTime($data["begin"]), Html::convDateTime($data["end"])) . "\">";
                    echo "</a></span>";
                }
                echo "</td></tr>\n";
            }
        }
        echo "</table>\n";
    }

Usage Example

Example #1
0
} else {
    Html::helpHeader(__('Home'), $_SERVER['PHP_SELF'], $_SESSION["glpiname"]);
    echo "<table class='tab_cadre_postonly'><tr class='noHover'>";
    echo "<td class='top' width='50%'><br>";
    echo "<table class='central'>";
    if (Session::haveRight('ticket', CREATE)) {
        echo "<tr class='noHover'><td class='top'>";
        Ticket::showCentralCount(true);
        echo "</td></tr>";
        echo "<tr class='noHover'><td class='top'>";
        Ticket::showCentralList(0, "survey", false);
        echo "</td></tr>";
    }
    if (Session::haveRight("reminder_public", READ)) {
        echo "<tr class='noHover'><td class='top'>";
        Reminder::showListForCentral(false);
        echo "</td></tr>";
    }
    if (Session::haveRight("rssfeed_public", READ)) {
        echo "<tr class='noHover'><td class='top'>";
        RSSFeed::showListForCentral(false);
        echo "</td></tr>";
    }
    echo "</table></td>";
    echo "<td class='top' width='50%'><br>";
    echo "<table class='central'>";
    // Show KB items
    if (Session::haveRight('knowbase', KnowbaseItem::READFAQ)) {
        echo "<tr class='noHover'><td class='top'>";
        KnowbaseItem::showRecentPopular("popular");
        echo "</td></tr>";
All Usage Examples Of Reminder::showListForCentral