/** * Check delete / purge on a Reminder (no is_template, no is_deleted) */ public function testReminder() { $reminder = new Reminder(); // Create $id[0] = $reminder->add(array('name' => "Reminder", 'entities_id' => 0, 'users_id' => $_SESSION['glpiID'])); $this->assertGreaterThan(0, $id[0], "Fail to create Reminder"); $this->assertTrue($reminder->getFromDB($id[0]), "Fail: can't read Reminder"); // Verify DB Schema have not change $this->assertArrayNotHasKey('is_deleted', $reminder->fields, "Fail: is_deleted field"); $this->assertArrayNotHasKey('is_template', $reminder->fields, "Fail: is_template field"); // Delete (= purge) $this->assertTrue($reminder->delete(array('id' => $id[0])), "Fail: can't delete Reminder"); $this->assertFalse($reminder->getFromDB($id[0]), "Fail: can read Reminder (deleted)"); }
static function showList($is_private = 1, $is_recursive = 0) { global $DB, $CFG_GLPI, $LANG; // show reminder that are not planned $planningRight = haveRight("show_planning", "1"); $users_id = getLoginUserID(); $is_helpdesk_visible = ''; if ($_SESSION['glpiactiveprofile']['interface'] == 'helpdesk') { $is_helpdesk_visible = "AND `is_helpdesk_visible` = 1"; } if (!$is_private && $is_recursive) { // show public reminder $query = "SELECT *\n FROM `glpi_reminders`\n WHERE `is_private` = '0'\n AND `is_recursive` = '1'\n {$is_helpdesk_visible} " . getEntitiesRestrictRequest("AND", "glpi_reminders", "", "", true); $titre = $LANG['reminder'][16]; } else { if (!$is_private && !$is_recursive) { // show public reminder $query = "SELECT *\n FROM `glpi_reminders`\n WHERE `is_private` = '0'\n AND `is_recursive` = '0'\n {$is_helpdesk_visible}" . getEntitiesRestrictRequest("AND", "glpi_reminders"); $titre = $LANG['reminder'][1]; } else { // show private reminder $query = "SELECT *\n FROM `glpi_reminders`\n WHERE `users_id` = '{$users_id}'\n AND `is_private` = '1'\n {$is_helpdesk_visible}"; $titre = $LANG['reminder'][0]; } } $result = $DB->query($query); $tabremind = array(); $remind = new Reminder(); if ($DB->numrows($result) > 0) { for ($i = 0; $data = $DB->fetch_array($result); $i++) { $remind->getFromDB($data["id"]); if ($data["is_planned"]) { //Un rdv on va trier sur la date begin $sort = $data["begin"]; } else { // non programmé on va trier sur la date de modif... $sort = $data["date"]; } $tabremind[$sort . "\$\$" . $i]["reminders_id"] = $remind->fields["id"]; $tabremind[$sort . "\$\$" . $i]["users_id"] = $remind->fields["users_id"]; $tabremind[$sort . "\$\$" . $i]["entity"] = $remind->fields["entities_id"]; $tabremind[$sort . "\$\$" . $i]["begin"] = $data["is_planned"] ? "" . $data["begin"] . "" : "" . $data["date"] . ""; $tabremind[$sort . "\$\$" . $i]["end"] = $data["is_planned"] ? "" . $data["end"] . "" : ""; $tabremind[$sort . "\$\$" . $i]["name"] = resume_text($remind->fields["name"], $CFG_GLPI["cut"]); $tabremind[$sort . "\$\$" . $i]["text"] = resume_text($remind->fields["text"], $CFG_GLPI["cut"]); } } ksort($tabremind); echo "<br><table class='tab_cadre_fixehov'>"; if ($is_private) { echo "<tr><th>" . "{$titre}" . "</th><th colspan='2'>" . $LANG['common'][27] . "</th></tr>\n"; } else { echo "<tr><th colspan='5'>" . "{$titre}" . "</th></tr>\n"; echo "<tr><th>" . $LANG['entity'][0] . "</th>"; echo "<th>" . $LANG['common'][37] . "</th>"; echo "<th>" . $LANG['title'][37] . "</th>"; echo "<th colspan='2'>" . $LANG['common'][27] . "</th></tr>\n"; } if (count($tabremind) > 0) { foreach ($tabremind as $key => $val) { echo "<tr class='tab_bg_2'>"; if (!$is_private) { // preg to split line (if needed) before ">" sign in completename echo "<td>" . preg_replace("/ ([[:alnum:]])/", " \\1", Dropdown::getDropdownName("glpi_entities", $val["entity"])) . "</td>"; echo "<td>" . Dropdown::getDropdownName("glpi_users", $val["users_id"]) . "</td>"; } echo "<td width='60%' class='left'>"; echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/reminder.form.php?id=" . $val["reminders_id"] . "'>" . $val["name"] . "</a>"; echo "<div class='kb_resume'>" . resume_text($val["text"], 125) . "</div></td>"; if ($val["end"] != "") { echo "<td class='center'>"; $tab = explode(" ", $val["begin"]); $date_url = $tab[0]; if ($planningRight) { echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/planning.php?date=" . $date_url . "&type=day'>"; } echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/rdv.png' alt=\"" . $LANG['Menu'][29] . "\" title=\"" . $LANG['Menu'][29] . "\">"; if ($planningRight) { echo "</a>"; } echo "</td>"; echo "<td class='center' >" . convDateTime($val["begin"]); echo "<br>" . convDateTime($val["end"]) . ""; } else { echo "<td> </td>"; echo "<td class='center'>"; echo "<span style='color:#aaaaaa;'>" . convDateTime($val["begin"]) . "</span>"; } echo "</td></tr>\n"; } } echo "</table>\n"; }