------------------------------------------------------------------------- LICENSE This file is part of GLPI. GLPI is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 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 * @since version 0.85 */ define('GLPI_ROOT', '..'); include GLPI_ROOT . "/inc/includes.php"; Session::checkRight("queuedmail", READ); Html::header(QueuedMail::getTypeName(), $_SERVER['PHP_SELF'], "admin", "queuedmail"); Search::show('QueuedMail'); Html::footer();
/** * Check zombie crontask * * @param $task for log **/ static function cronWatcher($task) { global $CFG_GLPI, $DB; $cron_status = 0; // Crontasks running for more than 1 hour or 2 frequency $query = "SELECT *\n FROM `glpi_crontasks`\n WHERE `state` = '" . self::STATE_RUNNING . "'\n AND ((unix_timestamp(`lastrun`) + 2 * `frequency` < unix_timestamp(now()))\n OR (unix_timestamp(`lastrun`) + 2*" . HOUR_TIMESTAMP . " < unix_timestamp(now())))"; $crontasks = array(); foreach ($DB->request($query) as $data) { $crontasks[$data['id']] = $data; } if (count($crontasks)) { $task = new self(); $task->getFromDBByQuery("WHERE `itemtype` = 'Crontask' AND `name` = 'watcher'"); if (NotificationEvent::raiseEvent("alert", $task, array('items' => $crontasks))) { $cron_status = 1; $task->addVolume(1); } QueuedMail::forceSendFor($task->getType(), $task->fields['id']); } return 1; }
/** * Send password recovery for a user. * * @param $email email of the user * * @return nothing : send email or display error message **/ function forgetPassword($email) { global $CFG_GLPI; echo "<div class='center'>"; if ($this->getFromDBbyEmail($email, "`glpi_users`.`is_active`\n AND NOT `glpi_users`.`is_deleted`\n AND (`glpi_users`.`begin_date` IS NULL\n OR `glpi_users`.`begin_date` < NOW())\n AND (`glpi_users`.`end_date` IS NULL\n OR `glpi_users`.`end_date` > NOW())")) { // Send token if auth DB or not external auth defined if ($this->fields["authtype"] == Auth::DB_GLPI || !Auth::useAuthExt()) { if (NotificationMail::isUserAddressValid($email)) { $input['password_forget_token'] = sha1(Toolbox::getRandomString(30)); $input['password_forget_token_date'] = $_SESSION["glpi_currenttime"]; $input['id'] = $this->fields['id']; $this->update($input); // Notication on root entity (glpi_users.entities_id is only a pref) NotificationEvent::raiseEvent('passwordforget', $this, array('entities_id' => 0)); QueuedMail::forceSendFor($this->getType(), $this->fields['id']); _e('An email has been sent to your email address. The email contains information for reset your password.'); } else { _e('Invalid email address'); } } else { _e("The authentication method configuration doesn't allow you to change your password."); } } else { _e('Email address not found.'); } echo "<br>"; echo "<a href=\"" . $CFG_GLPI['root_doc'] . "/index.php\">" . __s('Back') . "</a>"; echo "</div>"; }
LICENSE This file is part of GLPI. GLPI is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 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 * @since version 0.85 */ include '../inc/includes.php'; Session::checkRight('queuedmail', READ); if (!isset($_GET["id"])) { $_GET["id"] = ""; } $mail = new QueuedMail(); Html::header(QueuedMail::getTypeName(), $_SERVER['PHP_SELF'], "admin", "queuedmail"); $mail->display($_GET); Html::footer();
/** * @param $options array **/ function sendNotification($options = array()) { $data = array(); $data['itemtype'] = $options['_itemtype']; $data['items_id'] = $options['_items_id']; $data['notificationtemplates_id'] = $options['_notificationtemplates_id']; $data['entities_id'] = $options['_entities_id']; $data["headers"]['Auto-Submitted'] = "auto-generated"; $data["headers"]['X-Auto-Response-Suppress'] = "OOF, DR, NDR, RN, NRN"; $data['sender'] = $options['from']; $data['sendername'] = $options['fromname']; if ($options['replyto']) { $data['replyto'] = $options['replyto']; $data['replytoname'] = $options['replytoname']; } $data['name'] = $options['subject']; $data['body_text'] = $options['content_text']; if (!empty($options['content_html'])) { $data['body_html'] = $options['content_html']; } $data['recipient'] = $options['to']; $data['recipientname'] = $options['toname']; if (!empty($options['messageid'])) { $data['messageid'] = $options['messageid']; } if (isset($options['documents'])) { $data['documents'] = $options['documents']; } $mailqueue = new QueuedMail(); if (!$mailqueue->add(Toolbox::addslashes_deep($data))) { $senderror = true; Session::addMessageAfterRedirect(__('Error inserting email to queue'), true); } else { //TRANS to be written in logs %1$s is the to email / %2$s is the subject of the mail Toolbox::logInFile("mail", sprintf(__('%1$s: %2$s'), sprintf(__('An email to %s was added to queue'), $options['to']), $options['subject'] . "\n")); } return true; }
/** * Restore an item put in the dustbin in the database. * * @param $input array the _POST vars returned by the item form when press restore * @param $history boolean do history log ? (default 1) * * @return boolean : true on success **/ function restore(array $input, $history = 1) { if (!$this->getFromDB($input[static::getIndexName()])) { return false; } if (isset($input['restore'])) { $input['_restore'] = $input['restore']; unset($input['restore']); } // Store input in the object to be available in all sub-method / hook $this->input = $input; Plugin::doHook("pre_item_restore", $this); if ($this->restoreInDB()) { $this->addMessageOnRestoreAction(); if ($this->dohistory && $history) { $changes[0] = 0; $changes[1] = $changes[2] = ""; $logaction = Log::HISTORY_RESTORE_ITEM; if ($this->useDeletedToLockIfDynamic() && $this->isDynamic()) { $logaction = Log::HISTORY_UNLOCK_ITEM; } Log::history($this->input["id"], $this->getType(), $changes, 0, $logaction); } $this->post_restoreItem(); Plugin::doHook("item_restore", $this); if ($this->mailqueueonaction) { QueuedMail::forceSendFor($this->getType(), $this->fields['id']); } return true; } return false; }