Exemplo n.º 1
0
 function sendNotify()
 {
     $helpers = new Helpers_Helpers();
     $users = $this->registry["user"]->getUsersList();
     foreach ($users as $uid) {
         $nowdate = date("Ymd");
         $i = 0;
         $notify = array();
         if ($uid["notify"]) {
             if (date("Ymd", strtotime($uid["last_notify"])) < date("Ymd")) {
                 if ($uid["time_notify"] < date("H:i:s")) {
                     $tasks = $this->registry["tt"]->getTasksDate($uid["id"], $nowdate);
                     foreach ($tasks as $part) {
                         if ($data = $this->registry["tt"]->getTask($part["id"])) {
                             $notify[$i]["id"] = $data[0]["id"];
                             $notify[$i]["text"] = $data[0]["text"];
                             $notify[$i]["email"] = $uid["email"];
                             $i++;
                             unset($obj);
                             unset($author);
                             unset($ruser);
                         }
                     }
                     if (count($notify) > 0) {
                         $helpers->sendNotify($notify, $i);
                     }
                     $this->registry["user"]->setNotifyTime($uid["id"]);
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
 function index()
 {
     $mailClass = new Model_Mail();
     $this->view->setTitle("Новое сообщение");
     $this->view->setLeftContent($this->view->render("left_attach", array()));
     $mailboxes = $mailClass->getUserOutMailboxes();
     if (isset($_POST["submit"])) {
         $helpers = new Helpers_Helpers();
         $smtp = $mailClass->getOutMailbox($_POST["mailbox"]);
         $fromName = $this->registry["ui"]["name"] . " " . $this->registry["ui"]["soname"];
         if (!($err = $helpers->phpmailer($_POST, $smtp, $fromName))) {
             $mailClass->saveOutMail($_POST, $smtp);
             $this->view->refresh(array("timer" => "1", "url" => "mail/"));
         } else {
             $this->view->mail_compose(array("err" => $err, "mailboxes" => $mailboxes, "post" => $_POST));
         }
     } else {
         $post = array();
         if (isset($_GET["action"]) and $_GET["action"] == "reply") {
             if (isset($_GET["mid"]) and is_numeric($_GET["mid"])) {
                 $mail = $mailClass->getMailFromId($_GET["mid"]);
                 $post["subject"] = "RE: " . $mail[0]["subject"];
                 $post["to"] = $mail[0]["email"];
                 $text = null;
                 $html = null;
                 for ($i = 0; $i < count($mail); $i++) {
                     if ($mail[0]["type"] == "text") {
                         $text = "<pre>> " . trim($mail[$i]["text"]) . "</pre>";
                     }
                     if ($mail[0]["type"] == "html") {
                         $html = "> " . trim($mail[$i]["text"]);
                     }
                 }
                 if ($html == null) {
                     $post["textfield"] = $text;
                 } else {
                     $post["textfield"] = $html;
                 }
                 $post["textfield"] = str_replace("\r\n", "\r\n> ", $post["textfield"]);
                 $post["textfield"] = $this->view->render("mail_reply", array("date" => $mail[0]["date"], "text" => $post["textfield"]));
                 $post["email"] = $mail[0]["to"];
             }
         } elseif (isset($_GET["obj"])) {
             $mail =& $_SESSION["mail"];
             $post["to"] = implode(", ", json_decode($mail["json"], true));
         }
         $this->view->mail_compose(array("mailboxes" => $mailboxes, "post" => $post));
     }
     $this->view->showPage();
 }
Exemplo n.º 3
0
Arquivo: Tt.php Projeto: norayrx/otms
 public function spamUsers($theme, $tid)
 {
     if (isset($this->registry["module_users"])) {
         $user = $this->registry["module_users"];
     }
     $helpers = new Helpers_Helpers();
     if (isset($this->registry["module_mail"])) {
         $mailClass = $this->registry["module_mail"];
     }
     $data1 = array();
     $data = array();
     $i = 0;
     $flag = TRUE;
     $sql = "SELECT tr.uid AS `uid`, users.email, users.notify, tr.gid AS `gid`, tr.all AS `all`\r\n        FROM troubles_responsible AS tr\r\n        LEFT JOIN users ON (users.id = tr.uid)\r\n        WHERE tr.tid = :tid";
     $res = $this->registry['db']->prepare($sql);
     $param = array("tid" => $tid);
     $res->execute($param);
     $resp = $res->fetchAll(PDO::FETCH_ASSOC);
     if (count($resp) > 0) {
         foreach ($resp as $part) {
             if ($part["all"]) {
                 $flag = FALSE;
                 $rusers = array();
                 $allusers = $user->getUsersList();
                 foreach ($allusers as $uid) {
                     $data1[$i]["uid"] = $uid["id"];
                     $data1[$i]["email"] = $uid["email"];
                     $data1[$i]["notify"] = $uid["notify"];
                     $i++;
                 }
             }
             if ($part["gid"] != 0 and $flag) {
                 $gusers = $user->getUserInfoFromGroup($part["gid"]);
                 foreach ($gusers as $uid) {
                     $data1[$i]["uid"] = $uid["uid"];
                     $data1[$i]["email"] = $uid["email"];
                     $data1[$i]["notify"] = $uid["notify"];
                     $i++;
                 }
             }
             if ($part["uid"] != 0 and $flag) {
                 $data1[$i]["uid"] = $part["uid"];
                 $data1[$i]["email"] = $part["email"];
                 $data1[$i]["notify"] = $part["notify"];
                 $i++;
             }
         }
     }
     $sql = "SELECT DISTINCT(ts.uid) AS uid, users.email, ts.id AS `spam`\r\n        FROM troubles_spam AS ts\r\n        LEFT JOIN users ON (users.id = ts.uid)\r\n        WHERE ts.tid = :tid\r\n        ORDER BY ts.uid DESC";
     $res = $this->registry['db']->prepare($sql);
     $param = array("tid" => $tid);
     $res->execute($param);
     $data2 = $res->fetchAll(PDO::FETCH_ASSOC);
     $data = array_merge($data1, $data2);
     $i = 0;
     $users = array();
     foreach ($data as $part) {
         $flag = true;
         for ($k = 0; $k < count($users); $k++) {
             if ($users[$k]["uid"] == $part["uid"]) {
                 $flag = false;
             }
         }
         if ($flag) {
             if (isset($part["notify"]) and $part["notify"] or isset($part["spam"])) {
                 $users[$i]["uid"] = $part["uid"];
                 $users[$i]["email"] = $part["email"];
             }
             $i++;
         }
     }
     $task = $this->getTask($tid);
     if ($task[0]["mail_id"] != 0) {
         $task[0]["text"] = $mailClass->getMailText($task[0]["mail_id"]);
     }
     $comments = $this->getComments($tid);
     foreach ($users as $part) {
         $helpers->sendMail($part["email"], $theme, $task, $comments);
     }
 }
Exemplo n.º 4
0
 function sendMailComment($params)
 {
     $email = $params["email"];
     $cid = $params["cid"];
     $_POST["to"] = $email;
     $_POST["subject"] = "Комментарий";
     $_POST["textfield"] = $this->registry["tt"]->getCommentText($cid);
     $carr = $this->registry["tt"]->getComment($cid);
     foreach ($carr as $part) {
         $_POST["attaches"][] = $this->registry["rootPublic"] . "system/settings/../../" . $part["filename"];
     }
     $mailClass = new Model_Mail();
     $helpers = new Helpers_Helpers();
     $mailboxes = $mailClass->getUserOutMailboxes();
     for ($i = 0; $i < count($mailboxes); $i++) {
         if ($mailboxes[$i]["default"]) {
             $def = $i;
         }
     }
     $smtp = $mailClass->getOutMailbox($mailboxes[$def]["id"]);
     $fromName = $this->registry["ui"]["name"] . " " . $this->registry["ui"]["soname"];
     if (!($err = $helpers->phpmailer($_POST, $smtp, $fromName))) {
         $mailClass->saveOutMail($_POST, $smtp);
         $this->registry["tt"]->addCommentSendmail($cid);
     }
 }