Esempio n. 1
0
 function index()
 {
     $mid = $_GET["mid"];
     $part = $_GET["part"] - 1;
     $mail = array();
     $content = null;
     $mailClass = new Model_Mail();
     if (isset($_GET["out"]) and $_GET["out"]) {
         $mail = $mailClass->getMailOutFromId($mid);
         $out = 1;
     } else {
         $mail = $mailClass->getMailFromId($mid);
         $out = 0;
     }
     if (count($mail) > 0) {
         if (isset($mail[$part]["type"]) and $mail[$part]["type"] == "text") {
             $content = "<pre>" . $mail[$part]["text"] . "</pre>";
         }
         if (isset($mail[$part]["type"]) and $mail[$part]["type"] == "html") {
             $content = $mail[$part]["text"];
         }
         if ($content != null) {
             echo $this->view->render("mail_mailbody", array("content" => $content, "mid" => $mid, "part" => $part + 1, "out" => $out));
         }
         exit;
     }
 }
Esempio n. 2
0
 function getMail($params)
 {
     $mid = $params["mid"];
     $mailClass = new Model_Mail();
     $mail = $mailClass->getMailFromId($mid);
     $row["data"] = $this->view->render("mail_mail", array("mail" => $mail));
     $row["new"] = $mailClass->newMail;
     echo json_encode($row);
 }
Esempio n. 3
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();
 }
Esempio n. 4
0
 function getMail($params)
 {
     $mid = $params["mid"];
     $mailClass = new Model_Mail();
     $mail = $mailClass->getMailFromId($mid);
     if (is_numeric($this->registry["tt"]->issetTaskFromMid($mid))) {
         $isset = true;
     } else {
         $isset = false;
     }
     $row["data"] = $this->view->render("mail_mail", array("mail" => $mail, "isset" => $isset));
     $row["new"] = $mailClass->newMail;
     echo json_encode($row);
 }
Esempio n. 5
0
File: Tt.php Progetto: norayrx/otms
 public function addComment($tid, $text, $status, $attaches = false, $mid = false)
 {
     $helpers = new Helpers_Helpers();
     if (is_numeric($mid)) {
         $sql = "INSERT INTO troubles_discussion (tid, uid, mail_id, text, status) VALUES (:tid, :uid, :mail_id, :text, :status)";
         $res = $this->registry['db']->prepare($sql);
         $res->execute(array(":tid" => $tid, ":uid" => $this->uid, ":mail_id" => $mid, ":text" => "", ":status" => $status));
     } else {
         $sql = "INSERT INTO troubles_discussion (tid, uid, text, status) VALUES (:tid, :uid, :text, :status)";
         $res = $this->registry['db']->prepare($sql);
         $res->execute(array(":tid" => $tid, ":uid" => $this->uid, ":text" => $text, ":status" => $status));
     }
     $tdid = $this->registry['db']->lastInsertId();
     if (isset($attaches["attaches"])) {
         foreach ($attaches["attaches"] as $part) {
             $md5 = $this->getMD5($part);
             $sql = "INSERT INTO troubles_discussion_attach (`tdid`, `md5`) VALUES (:tdid, :md5)";
             $res = $this->registry['db']->prepare($sql);
             $param = array(":tdid" => $tdid, ":md5" => $md5);
             $res->execute($param);
         }
     }
     // email move task
     $post = $this->getTask($tid);
     if ($post[0]["remote_id"] != 0) {
         $subject = array();
         $body = array();
         $user = $this->registry["tt_user"]->getRemoteUserInfo($post[0]["who"]);
         $subject["method"] = "comment";
         $subject["name"] = "OTMS";
         $subject["tid"] = $post[0]["remote_id"];
         $subject["rc"] = true;
         $body["uemail"] = $this->registry["ui"]["email"];
         $body["uname"] = $this->registry["ui"]["name"];
         $body["usoname"] = $this->registry["ui"]["soname"];
         $body["ugname"] = $this->registry["ui"]["gname"];
         $body["uavatar"] = base64_encode(file_get_contents($this->registry["ui"]["avatarpath"]));
         $body["attaches"] = $attaches["attaches"];
         $body["text"] = $text;
         $body["status"] = $status;
         $helpers->sendTask($user["email"], $subject, $body);
     } else {
         $data["rall"] = 0;
         $data["gruser"] = array();
         $data["ruser"] = array();
         foreach ($post as $part) {
             if ($part["all"] == 1) {
                 $data["rall"] = 1;
             }
             if ($part["rgid"] != 0) {
                 $data["gruser"][] = $part["rgid"];
             }
             if ($part["uid"] != 0) {
                 $data["ruser"][] = $part["uid"];
             }
         }
         $users = $this->registry["user"]->getUniqUsers($data);
         foreach ($users as $part) {
             $subject = array();
             $body = array();
             $user = $this->registry["user"]->getUserInfo($part);
             if ($user["email_for_task"]) {
                 if (is_numeric($mid)) {
                     $mailClass = new Model_Mail();
                     $text = $mailClass->getMailText($mid);
                     $mail = $mailClass->getMailFromId($mid);
                     foreach ($mail[0]["attach"] as $part) {
                         $attaches["attaches"][] = $this->registry["rootPublic"] . "system/settings/../../" . $part["filename"];
                     }
                     $body["mail"] = true;
                     $body["mail_id"] = $mid;
                 } else {
                     $body["mail"] = false;
                 }
                 $subject["method"] = "comment";
                 $subject["name"] = "OTMS";
                 $subject["tid"] = $tid;
                 $subject["rc"] = false;
                 $body["uemail"] = $this->registry["ui"]["email"];
                 $body["uname"] = $this->registry["ui"]["name"];
                 $body["usoname"] = $this->registry["ui"]["soname"];
                 $body["ugname"] = $this->registry["ui"]["gname"];
                 $body["uavatar"] = base64_encode(file_get_contents($this->registry["ui"]["avatarpath"]));
                 $body["attaches"] = $attaches["attaches"];
                 $body["text"] = $text;
                 $body["status"] = $status;
                 $helpers->sendTask($user["email"], $subject, $body);
             }
         }
     }
     // END email move task
     $string = "Новый комментарий к задаче <a href='" . $this->registry["uri"] . "tt/" . $tid . "/'>" . $tid . "</a>";
     if ($status != 0) {
         $status_text = $this->getCommentStatusText($status);
         $tinfo["Статус"] = "<span style='padding: 2px 4px' class='info'>" . $status_text . "</span>";
     }
     if ($mid) {
         $tinfo["Текст"] = '<iframe class="mailtext" src="' . $this->registry["siteName"] . $this->registry["uri"] . 'mail/load/?mid=' . $mid . '&part=1" frameborder="0" width="100%" height="90%"></iframe>';
     } else {
         $tinfo["Текст"] = $text;
     }
     $this->registry["logs"]->uid = $this->uid;
     $this->registry["logs"]->set("com", $string, $tid, $tinfo);
 }
Esempio n. 6
0
 function index()
 {
     $mailClass = new Model_Mail();
     $this->view->setTitle("Правила обработки для почты");
     if (isset($_POST["submit"])) {
         $validate = new Model_Validate();
         $err = array();
         if (isset($_POST["checkbox_from"])) {
             if ($txt = $validate->email($_POST["from"])) {
                 $err[] = $txt;
             }
         } else {
             $_POST["from"] = null;
         }
         if (isset($_POST["checkbox_to"])) {
             if ($txt = $validate->email($_POST["to"])) {
                 $err[] = $txt;
             }
         } else {
             $_POST["to"] = null;
         }
         if (isset($_POST["checkbox_subject"])) {
             if ($_POST["subject"] == "") {
                 $err[] = 'Поле "Тема" не может быть пустой';
             }
         } else {
             $_POST["subject"] = null;
         }
         if (!isset($_POST["checkbox_from"]) and !isset($_POST["checkbox_to"]) and !isset($_POST["checkbox_subject"])) {
             $err[] = 'Не указано ни одного критерия для сортировки';
         }
         if (count($err) == 0) {
             $mailClass->addSort($_POST);
             $this->view->refresh(array("timer" => "1", "url" => "sort/"));
         } else {
             if (isset($_GET["mid"])) {
                 $mail = $mailClass->getMailFromId($_GET["mid"]);
             }
             $this->view->mail_addsort(array("err" => $err, "mail" => $mail, "folders" => $this->folders));
         }
     } elseif (isset($_POST["edit_sort"])) {
         if (isset($_GET["id"]) and is_numeric($_GET["id"])) {
             $param = $mailClass->getSort($_GET["id"]);
             $validate = new Model_Validate();
             $err = array();
             if (isset($_POST["from"]) and $_POST["from"] != null) {
                 if ($txt = $validate->email($_POST["from"])) {
                     $err[] = $txt;
                 } else {
                     $sort["type"] = "from";
                     $sort["val"] = $_POST["from"];
                     $sort["folder_id"] = $_POST["folder"];
                 }
             }
             if (isset($_POST["to"]) and $_POST["to"] != null) {
                 if ($txt = $validate->email($_POST["to"])) {
                     $err[] = $txt;
                 } else {
                     $sort["type"] = "to";
                     $sort["val"] = $_POST["to"];
                     $sort["folder_id"] = $_POST["folder"];
                 }
             }
             if (isset($_POST["subject"]) and $_POST["subject"] != null) {
                 if ($_POST["subject"] == "") {
                     $err[] = 'Поле "Тема" не может быть пустой';
                 } else {
                     $sort["type"] = "subject";
                     $sort["val"] = $_POST["subject"];
                     $sort["folder_id"] = $_POST["folder"];
                 }
             }
             if (!isset($_POST["from"]) and !isset($_POST["to"]) and !isset($_POST["subject"])) {
                 $err[] = 'Не указано ни одного критерия для сортировки';
             }
             if (count($err) == 0) {
                 $mailClass->delSort($_GET["id"]);
                 $mailClass->addSort($_POST);
                 $this->view->refresh(array("timer" => "1", "url" => "sort/"));
             } else {
                 $this->view->mail_editsort(array("err" => $err, "sort" => $param, "folders" => $this->folders));
             }
         }
     } elseif (isset($_GET["mid"]) or isset($_GET["add"])) {
         $mail = array();
         if (isset($_GET["mid"]) and is_numeric($_GET["mid"])) {
             $mail = $mailClass->getMailFromId($_GET["mid"]);
         }
         if (isset($_GET["id"]) and is_numeric($_GET["id"])) {
             $mail = $mailClass->getSort($_GET["id"]);
         }
         $this->view->mail_addsort(array("mail" => $mail, "folders" => $this->folders));
     } elseif (isset($_GET["id"])) {
         if (isset($_GET["id"]) and is_numeric($_GET["id"])) {
             $sort = $mailClass->getSort($_GET["id"]);
             $this->view->mail_editsort(array("sort" => $sort, "folders" => $this->folders));
         }
     } else {
         $list = $mailClass->getSorts();
         $this->view->mail_sorts(array("list" => $list));
     }
 }
Esempio n. 7
0
 function index()
 {
     $mailClass = new Model_Mail();
     $this->view->setTitle("Правила обработки для почты");
     $this->view->setLeftContent($this->view->render("left_mail", array("folders" => $this->folders, "enableCheck" => $this->enableCheck)));
     if (isset($_POST["submit"])) {
         $validate = new Model_Validate();
         $err = array();
         if (isset($_POST["checkbox_from"])) {
             if ($txt = $validate->email($_POST["from"])) {
                 $err[] = $txt;
             }
         } else {
             $_POST["from"] = null;
         }
         if (isset($_POST["checkbox_to"])) {
             if ($txt = $validate->email($_POST["to"])) {
                 $err[] = $txt;
             }
         } else {
             $_POST["to"] = null;
         }
         if (isset($_POST["checkbox_subject"])) {
             if ($_POST["subject"] == "") {
                 $err[] = 'Поле "Тема" не может быть пустой';
             }
         } else {
             $_POST["subject"] = null;
         }
         if (!isset($_POST["checkbox_from"]) and !isset($_POST["checkbox_to"]) and !isset($_POST["checkbox_subject"])) {
             $err[] = 'Не указано ни одного критерия для сортировки';
         }
         if (count($err) == 0) {
             $mailClass->addSort($_POST);
             $this->view->refresh(array("timer" => "1", "url" => "mail/sort/"));
         } else {
             if (isset($_GET["mid"])) {
                 $mail = $mailClass->getMailFromId($_GET["mid"]);
             }
             $rusers = $this->registry["user"]->getUsers();
             $formtask = $this->registry["module_tt"]->formtask();
             $this->view->mail_addsort(array("formtask" => $formtask, "err" => $err, "mail" => $mail, "folders" => $this->folders, "rusers" => $rusers));
         }
     } elseif (isset($_POST["edit_sort"])) {
         if (isset($_GET["id"]) and is_numeric($_GET["id"])) {
             $param = $mailClass->getSort($_GET["id"]);
             $validate = new Model_Validate();
             $err = array();
             if (isset($_POST["from"]) and $_POST["from"] != null) {
                 if ($txt = $validate->email($_POST["from"])) {
                     $err[] = $txt;
                 } else {
                     $sort["type"] = "from";
                     $sort["val"] = $_POST["from"];
                     $sort["folder_id"] = $_POST["folder"];
                 }
             }
             if (isset($_POST["to"]) and $_POST["to"] != null) {
                 if ($txt = $validate->email($_POST["to"])) {
                     $err[] = $txt;
                 } else {
                     $sort["type"] = "to";
                     $sort["val"] = $_POST["to"];
                     $sort["folder_id"] = $_POST["folder"];
                 }
             }
             if (isset($_POST["subject"]) and $_POST["subject"] != null) {
                 if ($_POST["subject"] == "") {
                     $err[] = 'Поле "Тема" не может быть пустой';
                 } else {
                     $sort["type"] = "subject";
                     $sort["val"] = $_POST["subject"];
                     $sort["folder_id"] = $_POST["folder"];
                 }
             }
             if (!isset($_POST["from"]) and !isset($_POST["to"]) and !isset($_POST["subject"])) {
                 $err[] = 'Не указано ни одного критерия для сортировки';
             }
             if (count($err) == 0) {
                 $mailClass->delSort($_GET["id"]);
                 $mailClass->addSort($_POST);
                 $this->view->refresh(array("timer" => "1", "url" => "mail/sort/"));
             } else {
                 $task[0] = $param[0]["task"];
                 $formtask = $this->registry["module_tt"]->formtask($task);
                 $this->view->mail_editsort(array("formtask" => $formtask, "err" => $err, "sort" => $param, "folders" => $this->folders));
             }
         }
     } elseif (isset($_GET["mid"]) or isset($_GET["add"])) {
         $mail = array();
         if (isset($_GET["mid"]) and is_numeric($_GET["mid"])) {
             $mail = $mailClass->getMailFromId($_GET["mid"]);
         }
         if (isset($_GET["id"]) and is_numeric($_GET["id"])) {
             $mail = $mailClass->getSort($_GET["id"]);
         }
         $rusers = $this->registry["user"]->getUsers();
         $formtask = $this->registry["module_tt"]->formtask();
         $this->view->mail_addsort(array("formtask" => $formtask, "mail" => $mail, "folders" => $this->folders, "rusers" => $rusers));
     } elseif (isset($_GET["id"])) {
         if (isset($_GET["id"]) and is_numeric($_GET["id"])) {
             $sort = $mailClass->getSort($_GET["id"]);
             $rusers = $this->registry["user"]->getUsers();
             $issRusers = array();
             $k = 0;
             if (isset($sort[0]["task"]["ruser"])) {
                 foreach ($sort[0]["task"]["ruser"] as $part) {
                     $row = $this->registry["user"]->getUserInfo($part);
                     $k++;
                     $issRusers[$k]["desc"] = '<p><span style="font-size: 11px; margin-right: 10px;" id="udesc[' . $row["uid"] . ']">' . $row["name"] . ' ' . $row["soname"] . '</span>';
                     $issRusers[$k]["desc"] .= '<input id="uhid[' . $row["uid"] . ']" type="hidden" name="ruser[]" value="' . $row["uid"] . '" /></p>';
                 }
             }
             if (isset($sort[0]["task"]["gruser"])) {
                 foreach ($sort[0]["task"]["gruser"] as $part) {
                     $gname = $this->registry["user"]->getGroupName($part);
                     $k++;
                     $issRusers[$k]["desc"] = '<p style="font-size: 11px; margin-right: 10px">' . $gname . '<input type="hidden" name="gruser[]" value="' . $part["rgid"] . '" /></p>';
                 }
             }
             if (isset($sort[0]["rall"])) {
                 $k++;
                 $issRusers[$k]["desc"] = '<p style="font-size: 11px; margin-right: 10px">Все<input type="hidden" name="rall" value="1" /></p>';
             }
             $task[0] = $sort[0]["task"];
             $formtask = $this->registry["module_tt"]->formtask($task);
             $this->view->mail_editsort(array("formtask" => $formtask, "sort" => $sort, "folders" => $this->folders, "rusers" => $rusers, "issRusers" => $issRusers));
         }
     } else {
         $list = $mailClass->getSorts();
         $formtask = $this->registry["module_tt"]->formtask();
         $this->view->mail_sorts(array("list" => $list, "formtask" => $formtask));
     }
     $this->view->showPage();
 }