GLPI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GLPI. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ /** @file * @brief */ include '../inc/includes.php'; Session::checkRight("config", "w"); Html::header(MailCollector::getTypeName(2), $_SERVER['PHP_SELF'], "config", "mailcollector"); if (!Toolbox::canUseImapPop()) { echo "<div class='center'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr><th colspan='2'>" . _n('Receiver', 'Receivers', 2) . "</th></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td class='center red'>" . __('Your PHP parser was compiled without the IMAP functions'); echo "</td></tr></table>"; echo "</div>"; Html::footer(); exit; } else { $mailcollector = new MailCollector(); $mailcollector->title(); Search::show('MailCollector'); Html::footer(); }
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GLPI. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ /** @file * @brief */ include '../inc/includes.php'; Session::checkRight("config", READ); if (!isset($_GET["id"])) { $_GET["id"] = ""; } $mailgate = new MailCollector(); if (isset($_POST["add"])) { $mailgate->check(-1, CREATE, $_POST); if ($newID = $mailgate->add($_POST)) { Event::log($newID, "mailcollector", 4, "setup", sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $_POST["name"])); if ($_SESSION['glpibackcreated']) { Html::redirect($mailgate->getFormURL() . "?id=" . $newID); } } Html::back(); } else { if (isset($_POST["purge"])) { $mailgate->check($_POST['id'], PURGE); $mailgate->delete($_POST, 1); Event::log($_POST["id"], "mailcollector", 4, "setup", sprintf(__('%s purges an item'), $_SESSION["glpiname"])); $mailgate->redirectToList();
/** * Get footer to add to content **/ function getContentFooter() { if (MailCollector::getNumberOfActiveMailCollectors()) { return self::FOOTERTAG . ' ' . __('To answer by email, write under this line') . ' ' . self::FOOTERTAG; } return ''; }
$data = Toolbox::getURLContent($url); if (!empty($data)) { echo "_OK"; } else { echo "_PROBLEM"; $ok = false; } echo "\n"; } else { echo "No CAS server\n"; } /// Check mailcollectors $mailcollectors = getAllDatasFromTable('glpi_mailcollectors', '`is_active`=1'); if (count($mailcollectors)) { echo "Check mail collectors:"; $mailcol = new MailCollector(); foreach ($mailcollectors as $mc) { echo " " . $mc['name']; if ($mailcol->getFromDB($mc['id'])) { $mailcol->connect(); if ($mailcol->marubox) { echo "_OK"; } else { echo "_PROBLEM"; $ok = false; } echo "\n"; $mailcol->close_mailbox(); } } } else {
/** * Print the config form for connections * * @return Nothing (display) **/ function showFormHelpdesk() { global $DB, $CFG_GLPI; if (!self::canView()) { return false; } $canedit = Config::canUpdate(); if ($canedit) { echo "<form name='form' action=\"" . Toolbox::getItemTypeFormURL(__CLASS__) . "\" method='post'>"; } echo "<div class='center spaced' id='tabsbody'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr><th colspan='4'>" . __('Assistance') . "</th></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td width='30%'>" . __('Step for the hours (minutes)') . "</td>"; echo "<td width='20%'>"; Dropdown::showNumber('time_step', array('value' => $CFG_GLPI["time_step"], 'min' => 30, 'max' => 60, 'step' => 30, 'toadd' => array(1 => 1, 5 => 5, 10 => 10, 15 => 15, 20 => 20))); echo "</td>"; echo "<td width='30%'>" . __('Limit of the schedules for planning') . "</td>"; echo "<td width='20%'>"; Dropdown::showHours('planning_begin', array('value' => $CFG_GLPI["planning_begin"])); echo " -> "; Dropdown::showHours('planning_end', array('value' => $CFG_GLPI["planning_end"])); echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . __('Default file size limit imported by the mails receiver') . "</td><td>"; MailCollector::showMaxFilesize('default_mailcollector_filesize_max', $CFG_GLPI["default_mailcollector_filesize_max"]); echo "</td>"; echo "<td>" . __('Use rich text for helpdesk') . "</td><td>"; $id = 'alert' . mt_rand(); $param['on_change'] = '$("#' . $id . '").html(""); if ($(this).val() == 0) { $("#' . $id . '").html("<br>' . __('You will lose the formatting of your data') . '"); }'; Dropdown::showYesNo("use_rich_text", $CFG_GLPI["use_rich_text"], -1, $param); echo "<span class='red' id='" . $id . "'></span>"; echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . __('Default heading when adding a document to a ticket') . "</td><td>"; DocumentCategory::dropdown(array('value' => $CFG_GLPI["documentcategories_id_forticket"], 'name' => "documentcategories_id_forticket")); echo "</td>"; echo "<td>" . __('By default, a software may be linked to a ticket') . "</td><td>"; Dropdown::showYesNo("default_software_helpdesk_visible", $CFG_GLPI["default_software_helpdesk_visible"]); echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . __('Keep tickets when purging hardware in the inventory') . "</td><td>"; Dropdown::showYesNo("keep_tickets_on_delete", $CFG_GLPI["keep_tickets_on_delete"]); echo "</td><td>" . __('Show personnal information in new ticket form (simplified interface)'); echo "</td><td>"; Dropdown::showYesNo('use_check_pref', $CFG_GLPI['use_check_pref']); echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . __('Allow anonymous ticket creation (helpdesk.receiver)') . "</td><td>"; Dropdown::showYesNo("use_anonymous_helpdesk", $CFG_GLPI["use_anonymous_helpdesk"]); echo "</td><td>" . __('Allow anonymous followups (receiver)') . "</td><td>"; Dropdown::showYesNo("use_anonymous_followups", $CFG_GLPI["use_anonymous_followups"]); echo "</td></tr>"; echo "</table>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr><th colspan='7'>" . __('Matrix of calculus for priority'); echo "<input type='hidden' name='_matrix' value='1'></th></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td class='b right' colspan='2'>" . __('Impact') . "</td>"; for ($impact = 5; $impact >= 1; $impact--) { echo "<td class='center'>" . Ticket::getImpactName($impact) . '<br>'; if ($impact == 3) { $isimpact[3] = 1; echo "<input type='hidden' name='_impact_3' value='1'>"; } else { $isimpact[$impact] = ($CFG_GLPI['impact_mask'] & 1 << $impact) > 0; Dropdown::showYesNo("_impact_{$impact}", $isimpact[$impact]); } echo "</td>"; } echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td class='b' colspan='2'>" . __('Urgency') . "</td>"; for ($impact = 5; $impact >= 1; $impact--) { echo "<td> </td>"; } echo "</tr>"; for ($urgency = 5; $urgency >= 1; $urgency--) { echo "<tr class='tab_bg_1'>"; echo "<td>" . Ticket::getUrgencyName($urgency) . " </td>"; echo "<td>"; if ($urgency == 3) { $isurgency[3] = 1; echo "<input type='hidden' name='_urgency_3' value='1'>"; } else { $isurgency[$urgency] = ($CFG_GLPI['urgency_mask'] & 1 << $urgency) > 0; Dropdown::showYesNo("_urgency_{$urgency}", $isurgency[$urgency]); } echo "</td>"; for ($impact = 5; $impact >= 1; $impact--) { $pri = round(($urgency + $impact) / 2); if (isset($CFG_GLPI['priority_matrix'][$urgency][$impact])) { $pri = $CFG_GLPI['priority_matrix'][$urgency][$impact]; } if ($isurgency[$urgency] && $isimpact[$impact]) { $bgcolor = $_SESSION["glpipriority_{$pri}"]; echo "<td class='center' bgcolor='{$bgcolor}'>"; Ticket::dropdownPriority(array('value' => $pri, 'name' => "_matrix_{$urgency}_{$impact}")); echo "</td>"; } else { echo "<td><input type='hidden' name='_matrix_{$urgency}_{$impact}' value='{$pri}'>\n </td>"; } } echo "</tr>\n"; } if ($canedit) { echo "<tr class='tab_bg_2'>"; echo "<td colspan='7' class='center'>"; echo "<input type='submit' name='update' class='submit' value=\"" . _sx('button', 'Save') . "\">"; echo "</td></tr>"; } echo "</table></div>"; Html::closeForm(); }
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GLPI. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ /** @file * @brief */ include '../inc/includes.php'; Session::checkRight("config", "r"); if (!isset($_GET["id"])) { $_GET["id"] = ""; } $mailgate = new MailCollector(); if (isset($_POST["add"])) { $mailgate->check(-1, 'w', $_POST); $newID = $mailgate->add($_POST); Event::log($newID, "mailcollector", 4, "setup", sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $_POST["name"])); Html::back(); } else { if (isset($_POST["delete"])) { $mailgate->check($_POST['id'], 'd'); $mailgate->delete($_POST); Event::log($_POST["id"], "mailcollector", 4, "setup", sprintf(__('%s purges an item'), $_SESSION["glpiname"])); $mailgate->redirectToList(); } else { if (isset($_POST["update"])) { $mailgate->check($_POST['id'], 'w'); $mailgate->update($_POST);
/** * Cron action on mailgate : retrieve mail and create tickets * * @return -1 : done but not finish 1 : done with success **/ static function cronMailgate($task) { global $DB; NotImportedEmail::deleteLog(); $query = "SELECT *\n FROM `glpi_mailcollectors`\n WHERE `is_active` = '1'"; if ($result = $DB->query($query)) { $max = $task->fields['param']; if ($DB->numrows($result) > 0) { $mc = new MailCollector(); while ($max > 0 && ($data = $DB->fetch_assoc($result))) { $mc->maxfetch_emails = $max; $task->log("Collect mails from " . $data["host"] . "\n"); $message = $mc->collect($data["id"]); $task->log("{$message}\n"); $task->addVolume($mc->fetch_emails); $max -= $mc->fetch_emails; } } if ($max == $task->fields['param']) { return 0; // Nothin to do } else { if ($max > 0) { return 1; // done } } return -1; // still messages to retrieve } return 0; }
/** * @since version 0.85 * * @see CommonDBTM::processMassiveActionsForOneItemtype() **/ static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids) { switch ($ma->getAction()) { case 'delete_email': case 'import_email': if (!$item->canUpdate()) { $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_NORIGHT); } else { $input = $ma->getInput(); if (count($ids)) { $mailcollector = new MailCollector(); if ($ma->getAction() == 'delete_email') { $mailcollector->deleteOrImportSeveralEmails($ids, 0); } else { $mailcollector->deleteOrImportSeveralEmails($ids, 1, $input['entities_id']); } } $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_OK); } return; } parent::processMassiveActionsForOneItemtype($ma, $item, $ids); }
$item->delete(array('id' => $key, '_replace_by' => $newid)); } } } } break; case 'delete_email': case 'import_email': $emails_ids = array(); foreach ($_POST["item"] as $key => $val) { if ($val == 1) { $emails_ids[$key] = $key; } } if (!empty($emails_ids)) { $mailcollector = new MailCollector(); if ($_POST["action"] == 'delete_email') { $mailcollector->deleteOrImportSeveralEmails($emails_ids, 0); } else { $mailcollector->deleteOrImportSeveralEmails($emails_ids, 1, $_POST['entities_id']); } } break; default: // Plugin specific actions $split = explode('_', $_POST["action"]); if ($split[0] == 'plugin' && isset($split[1])) { // Normalized name plugin_name_action // Allow hook from any plugin on any (core or plugin) type doOneHook($split[1], 'MassiveActionsProcess', $_POST); } else {
/** * @see CommonDBTM::doSpecificMassiveActions() **/ function doSpecificMassiveActions($input = array()) { $res = array('ok' => 0, 'ko' => 0, 'noright' => 0); switch ($input['action']) { case 'delete_email': case 'import_email': if (!static::canCreate()) { $res['noright']++; } else { $emails_ids = array(); foreach ($input["item"] as $key => $val) { if ($val == 1) { $emails_ids[$key] = $key; } } if (count($emails_ids)) { $mailcollector = new MailCollector(); if ($input["action"] == 'delete_email') { $mailcollector->deleteOrImportSeveralEmails($emails_ids, 0); } else { $mailcollector->deleteOrImportSeveralEmails($emails_ids, 1, $input['entities_id']); } } $res['ok']++; } break; default: return parent::doSpecificMassiveActions($input); } return $res; }
/** * Print the config form for connections * * @return Nothing (display) **/ function showFormHelpdesk() { global $DB, $LANG, $CFG_GLPI; if (!haveRight("config", "w")) { return false; } echo "<form name='form' action=\"" . getItemTypeFormURL(__CLASS__) . "\" method='post'>"; echo "<div class='center' id='tabsbody'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr><th colspan='4'>" . $LANG['title'][24] . "</th></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . $LANG['setup'][612] . " :</td><td>"; Dropdown::showYesNo("is_ticket_category_mandatory", $CFG_GLPI["is_ticket_category_mandatory"]); echo "</td><td>" . $LANG['setup'][148] . " :</td><td>"; Dropdown::showInteger('time_step', $CFG_GLPI["time_step"], 30, 60, 30, array(5 => 5, 10 => 10, 15 => 15, 20 => 20)); echo " " . $LANG['job'][22]; echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . $LANG['setup'][610] . " :</td><td>"; Dropdown::showYesNo("is_ticket_title_mandatory", $CFG_GLPI["is_ticket_title_mandatory"]); echo "</td><td>" . $LANG['setup'][223] . " :</td><td>"; Dropdown::showHours('planning_begin', $CFG_GLPI["planning_begin"]); echo " -> "; Dropdown::showHours('planning_end', $CFG_GLPI["planning_end"]); echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td> " . $LANG['setup'][611] . " :</td><td>"; Dropdown::showYesNo("is_ticket_content_mandatory", $CFG_GLPI["is_ticket_content_mandatory"]); echo "</td><td>" . $LANG['mailgate'][7] . " (" . $LANG['setup'][46] . ") :</td><td>"; MailCollector::showMaxFilesize('default_mailcollector_filesize_max', $CFG_GLPI["default_mailcollector_filesize_max"]); echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td> " . $LANG['setup'][52] . " :</td><td>"; $autoassign = array(NO_AUTO_ASSIGN => $LANG['choice'][0], AUTO_ASSIGN_HARDWARE_CATEGORY => $LANG['setup'][51], AUTO_ASSIGN_CATEGORY_HARDWARE => $LANG['setup'][50]); Dropdown::showFromArray('auto_assign_mode', $autoassign, array('value' => $CFG_GLPI["auto_assign_mode"])); echo "</td><td>" . $LANG['setup'][409] . " :</td><td>"; Dropdown::show('DocumentCategory', array('value' => $CFG_GLPI["documentcategories_id_forticket"], 'name' => "documentcategories_id_forticket")); echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . $LANG['entity'][18] . " :</td><td>"; Dropdown::showInteger('autoclose_delay', $CFG_GLPI['autoclose_delay'], 0, 99, 1, array(-10 => $LANG['setup'][307])); echo " " . $LANG['stats'][31] . "</td>"; echo "<td>" . $LANG['setup'][608] . " :</td><td>"; Dropdown::showYesNo("default_software_helpdesk_visible", $CFG_GLPI["default_software_helpdesk_visible"]); echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . $LANG['tracking'][37] . " :</td><td>"; Dropdown::showYesNo("keep_tickets_on_delete", $CFG_GLPI["keep_tickets_on_delete"]); echo "</td><td>" . $LANG['setup'][219] . " :</td><td>"; Dropdown::showYesNo("use_anonymous_helpdesk", $CFG_GLPI["use_anonymous_helpdesk"]); echo "</td></tr>"; echo "</table><br>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr><th colspan='7'>" . $LANG['help'][1]; echo "<input type='hidden' name='_matrix' value='1'></th></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td class='b right' colspan='2'>" . $LANG['joblist'][30] . " :</td>"; for ($impact = 5, $msg = 47; $impact >= 1; $impact--, $msg++) { echo "<td>" . $LANG['help'][$msg] . " : "; if ($impact == 3) { $isimpact[3] = 1; echo "<input type='hidden' name='_impact_3' value='1'>"; } else { $isimpact[$impact] = ($CFG_GLPI['impact_mask'] & 1 << $impact) > 0; Dropdown::showYesNo("_impact_{$impact}", $isimpact[$impact]); } echo "</td>"; } echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td class='b' colspan='2'>" . $LANG['joblist'][29] . " :</td>"; for ($impact = 5, $msg = 47; $impact >= 1; $impact--, $msg++) { echo "<td> </td>"; } echo "</tr>"; for ($urgency = 5, $msg = 42; $urgency >= 1; $urgency--, $msg++) { echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['help'][$msg] . " :</td>"; echo "<td>"; if ($urgency == 3) { $isurgency[3] = 1; echo "<input type='hidden' name='_urgency_3' value='1'>"; } else { $isurgency[$urgency] = ($CFG_GLPI['urgency_mask'] & 1 << $urgency) > 0; Dropdown::showYesNo("_urgency_{$urgency}", $isurgency[$urgency]); } echo "</td>"; for ($impact = 5; $impact >= 1; $impact--) { $pri = round(($urgency + $impact) / 2); if (isset($CFG_GLPI['priority_matrix'][$urgency][$impact])) { $pri = $CFG_GLPI['priority_matrix'][$urgency][$impact]; } if ($isurgency[$urgency] && $isimpact[$impact]) { $bgcolor = $_SESSION["glpipriority_{$pri}"]; echo "<td bgcolor='{$bgcolor}'>"; Ticket::dropdownPriority("_matrix_{$urgency}_{$impact}", $pri); echo "</td>"; } else { echo "<td><input type='hidden' name='_matrix_{$urgency}_{$impact}' value='{$pri}'></td>"; } } echo "</tr>\n"; } echo "<tr class='tab_bg_2'>"; echo "<td colspan='7' class='center'>"; echo "<input type='hidden' name='id' value='" . $CFG_GLPI["id"] . "'>"; echo "<input type='submit' name='update' class='submit' value=\"" . $LANG['buttons'][2] . "\">"; echo "</td></tr>"; echo "</table></div>"; echo "</form>"; }
/** * @see RuleCollection::canList() **/ function canList() { return static::canView() && Toolbox::canUseImapPop() && MailCollector::getNumberOfMailCollectors(); }
// Purpose of file: // ---------------------------------------------------------------------- define('GLPI_ROOT', '..'); include GLPI_ROOT . "/inc/includes.php"; header("Content-Type: text/html; charset=UTF-8"); header_nocache(); if (!isset($_POST["id"])) { exit; } if (!isset($_REQUEST['glpi_tab'])) { exit; } if (empty($_POST["id"])) { $_POST["id"] = -1; } $collector = new MailCollector(); if ($_POST['id'] > 0 && $collector->can($_POST['id'], 'r')) { switch ($_REQUEST['glpi_tab']) { case -1: $collector->showGetMessageForm($_POST['id']); Plugin::displayAction($collector, $_REQUEST['glpi_tab']); break; case 12: Log::showForItem($collector); break; default: if (!Plugin::displayAction($collector, $_REQUEST['glpi_tab'])) { $collector->showGetMessageForm($_POST['id']); } break; }
function canList() { return $this->canView() && canUseImapPop() && MailCollector::getNumberOfMailCollectors(); }