Esempio n. 1
0
 public function getCategory()
 {
     $gUid = Ibos::app()->user->uid;
     $myFolders = EmailBox::model()->fetchAllNotSysByUid($gUid);
     $notReadCount = Email::model()->countNotReadByToid($gUid, "inbox");
     $return = array("folders" => $myFolders, "notread" => $notReadCount);
     return $return;
 }
Esempio n. 2
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Email the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Email::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Esempio n. 3
0
 public function actionDel()
 {
     $fid = $this->fid;
     $cleanAll = EnvUtil::getRequest("delemail");
     $emailIds = Email::model()->fetchAllEmailIdsByFolderId($fid, $this->uid);
     if ($cleanAll) {
         $emailIds && Email::model()->completelyDelete($emailIds, $this->uid);
     } else {
         $emailIds && Email::model()->updateByPk($emailIds, array("fid" => parent::INBOX_ID));
     }
     $deleted = EmailFolder::model()->deleteByPk($fid);
     if ($deleted) {
         $this->ajaxReturn(array("isSuccess" => true));
     } else {
         $this->ajaxReturn(array("isSuccess" => false, "errorMsg" => Ibos::lang("Del failed", "message")));
     }
 }
Esempio n. 4
0
 private function getListData($operation)
 {
     $data["op"] = $operation;
     $data["fid"] = $this->fid;
     $data["webId"] = $this->webId;
     $data["folders"] = $this->folders;
     $data["archiveId"] = $this->archiveId;
     $data["allowRecall"] = Yii::app()->setting->get("setting/emailrecall");
     $uid = $this->uid;
     if ($operation == "archive") {
         if (!in_array($this->subOp, array("in", "send"))) {
             $this->subOp = "in";
         }
     }
     $data["subOp"] = $this->subOp;
     $count = Email::model()->countByListParam($operation, $uid, $data["fid"], $data["archiveId"], $data["subOp"]);
     $pages = PageUtil::create($count, $this->getListPageSize());
     $data["pages"] = $pages;
     $data["unreadCount"] = Email::model()->countUnreadByListParam($operation, $uid, $data["fid"], $data["archiveId"], $data["subOp"]);
     $data["list"] = Email::model()->fetchAllByListParam($operation, $uid, $data["fid"], $data["archiveId"], $pages->getLimit(), $pages->getOffset(), $data["subOp"]);
     return $data;
 }
Esempio n. 5
0
 public function actionMark()
 {
     $id = EnvUtil::getRequest("emailid");
     $status = false;
     if (!empty($id)) {
         $condition = "toid = " . $this->uid . " AND FIND_IN_SET(emailid,\"" . $id . "\")";
         $markFlag = EnvUtil::getRequest("ismark");
         $ismark = strcasecmp($markFlag, "true") == 0 ? 1 : 0;
         $status = Email::model()->setField("ismark", $ismark, $condition);
     }
     $errorMsg = !$status ? Ibos::lang("Operation failure", "message") : "";
     $this->ajaxReturn(array("isSuccess" => !!$status, "errorMsg" => $errorMsg), "JSONP");
 }
Esempio n. 6
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  */
 public function loadModel()
 {
     if ($this->_model === null) {
         if (isset($_GET['id'])) {
             $this->_model = Email::model()->findbyPk($_GET['id']);
         }
         if ($this->_model === null) {
             throw new CHttpException(404, 'The requested page does not exist.');
         }
     }
     return $this->_model;
 }
Esempio n. 7
0
 public function actionNotificar($id)
 {
     $eventos = Evento::model()->findAll();
     $model = Evento::model()->findByPK($id);
     $contactos = Email::model()->findAll("estatus_did = 1");
     $destinatarios = array();
     if (count($contactos) > 0) {
         foreach ($contactos as $contacto) {
             $destinatarios[] = $contacto->correo;
         }
     }
     $this->avisarAsociados($destinatarios, $model->nombre);
     $this->redirect(array("evento/listar"));
 }
Esempio n. 8
0
 public static function receiveMail($web)
 {
     self::$_web = $web;
     @set_time_limit(0);
     ignore_user_abort(true);
     list($prefix) = explode(".", $web["server"]);
     $user = User::model()->fetchByUid($web["uid"]);
     $pwd = StringUtil::authCode($web["password"], "DECODE", $user["salt"]);
     if ($prefix == "imap") {
         $obj = new WebMailImap();
     } else {
         $obj = new WebMailPop();
     }
     $conn = $obj->connect($web["server"], $web["username"], $pwd, $web["ssl"], $web["port"], "plain");
     if (!$conn) {
         return implode(",", $obj->getError());
     } else {
         $totalNum = $obj->countMessages($conn, "INBOX");
         if (0 < $totalNum) {
             $messagesStr = "1:" . $totalNum;
         } else {
             $messagesStr = "";
         }
         if ($messagesStr != "") {
             $headers = $obj->fetchHeaders($conn, "INBOX", $messagesStr);
             $headers = $obj->sortHeaders($headers, "DATE", "DESC");
         } else {
             $headers = false;
         }
         if ($headers == false) {
             $headers = array();
         }
         $count = 0;
         if (0 < count($headers)) {
             while (list($key, $val) = each($headers)) {
                 $header = $headers[$key];
                 $time = $header->timestamp + 28800;
                 if ($web["lastrectime"] == 0 || $web["lastrectime"] < $time) {
                     $count++;
                     $data = array();
                     $data["subject"] = str_replace(array("<", ">"), array("&lt;", "&gt;"), EmailLangUtil::langDecodeSubject($header->subject, CHARSET));
                     $data["sendtime"] = $time;
                     $data["towebmail"] = $web["address"];
                     $data["issend"] = 1;
                     $data["fromid"] = $data["secrettoids"] = "";
                     $data["fromwebmail"] = EmailLangUtil::langGetParseAddressList($header->from);
                     if (isset($header->to) && !empty($header->to)) {
                         $data["toids"] = EmailLangUtil::langGetParseAddressList($header->to, ",");
                     } else {
                         $data["toids"] = "";
                     }
                     if (isset($header->cc) && !empty($header->cc)) {
                         $data["copytoids"] = EmailLangUtil::langGetParseAddressList($header->cc, ",");
                     } else {
                         $data["copytoids"] = "";
                     }
                     $body = self::getBody($header->id, $conn, $obj, $header);
                     $data["content"] = implode("", $body);
                     $data["size"] = EmailUtil::getEmailSize($data["content"]);
                     $bodyId = EmailBody::model()->add($data, true);
                     if ($bodyId) {
                         $email = array("toid" => $web["uid"], "isread" => 0, "fid" => $web["fid"], "isweb" => 1, "bodyid" => $bodyId);
                         Email::model()->add($email);
                     }
                 }
             }
             EmailWeb::model()->updateByPk($web["webid"], array("lastrectime" => TIMESTAMP));
         }
         return $count;
     }
 }
Esempio n. 9
0
 public function actionMark()
 {
     $op = EnvUtil::getRequest("op");
     $opList = array("todo", "read", "unread", "sendreceipt", "cancelreceipt", "del", "restore", "batchdel", "move");
     if (!in_array($op, $opList)) {
         exit;
     }
     $ids = EnvUtil::getRequest("emailids");
     $id = StringUtil::filterStr($ids);
     $extends = array();
     $condition = "toid = " . $this->uid . " AND FIND_IN_SET(emailid,\"" . $id . "\")";
     $valueDriver = array("read" => array("isread", 1), "unread" => array("isread", 0), "sendreceipt" => array("isreceipt", 1), "cancelreceipt" => array("isreceipt", 2), "restore" => array("isdel", 0));
     switch ($op) {
         case "del":
         case "batchdel":
             if ($op == "del") {
                 $next = Email::model()->fetchNext($id, $this->uid, $this->fid, $this->archiveId);
                 if (!empty($next)) {
                     $extends["url"] = $this->createUrl("content/show", array("id" => $next["emailid"], "archiveid" => $this->archiveId));
                 } else {
                     $extends["url"] = $this->createUrl("list/index");
                 }
             }
             $status = Email::model()->setField("isdel", 3, $condition);
             break;
         case "move":
             $fid = intval(EnvUtil::getRequest("fid"));
             $status = Email::model()->updateAll(array("fid" => $fid, "isdel" => 0), $condition);
             break;
         case "todo":
             $markFlag = EnvUtil::getRequest("ismark");
             $ismark = strcasecmp($markFlag, "true") == 0 ? 1 : 0;
             $status = Email::model()->setField("ismark", $ismark, $condition);
             break;
         case "sendreceipt":
             $fromInfo = Ibos::app()->db->createCommand()->select("eb.bodyid,eb.subject,eb.fromid")->from("{{email_body}} eb")->leftJoin("{{email}} e", "e.bodyid = eb.bodyid")->where("e.emailid = " . intval($id))->queryRow();
             if ($fromInfo) {
                 $config = array("{reader}" => Ibos::app()->user->realname, "{url}" => Ibos::app()->urlManager->createUrl("email/content/show", array("id" => $fromInfo["bodyid"])), "{title}" => $fromInfo["subject"]);
                 Notify::model()->sendNotify($fromInfo["fromid"], "email_receive_message", $config);
             }
         default:
             if (isset($valueDriver[$op])) {
                 $value = $valueDriver[$op][1][0];
                 $valueDriver;
                 $status = Email::model()->setField($key, $value, $condition);
             } else {
                 $status = false;
             }
             break;
     }
     $errorMsg = !$status ? Ibos::lang("Operation failure", "message") : "";
     $this->ajaxReturn(array_merge(array("isSuccess" => !!$status, "errorMsg" => $errorMsg), $extends));
 }
Esempio n. 10
0
 public static function exportExcel($id)
 {
     $data = Email::model()->fetchById($id);
     if ($data) {
         $users = UserUtil::loadUser();
         header("Cache-control: private");
         header("Content-type: application/vnd.ms-excel");
         header("Content-Disposition: attachment; filename=" . ConvertUtil::iIconv($data["subject"], CHARSET, "GBK") . "(" . date("Y-m-d") . ").xls");
         //$html = "            <html xmlns:o=\"urn:schemas-microsoft-com:office:office\"\r\n\t\txmlns:x=\"urn:schemas-microsoft-com:office:excel\"\r\n\t\txmlns=\"http://www.w3.org/TR/REC-html40\">\r\n\t\t<head>\r\n\t\t<title></title>\r\n\t\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r\n\t\t</head>\r\n\t\t<body topmargin=\"5\">\r\n\t\t <table border=\"1\" cellspacing=\"1\" width=\"95%\" class=\"small\" cellpadding=\"3\">\r\n\t\t\t<tr style=\"BACKGROUND: #D3E5FA; color: #000000; font-weight: bold;\">\r\n\t\t\t  <td align=\"center\">收件人:</td>\r\n\t\t\t  <td align=\"center\">发件人:</td>\r\n\t\t\t  <td align=\"center\">抄送:</td>\r\n\t\t\t  <td align=\"center\">重要性:</td>\r\n\t\t\t  <td align=\"center\">标题:</td>\r\n\t\t\t  <td align=\"center\">发送时间:</td>\r\n\t\t\t  <td align=\"center\">内容:</td>\r\n\t\t\t  <td align=\"center\">附件名称:</td>\r\n\t\t\t</tr>      ";
         $html = '<html xmlns:o="urn:schemas-microsoft-com:office:office"
     xmlns:x="urn:schemas-microsoft-com:office:excel"
     xmlns="http://www.w3.org/TR/REC-html40">
     <head>
     <title></title>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
     </head>
     <body topmargin="5">
      <table border="1" cellspacing="1" width="95%" class="small" cellpadding="3">
         <tr style="BACKGROUND: #D3E5FA; color: #000000; font-weight: bold;">
           <td align="center">收件人:</td>
           <td align="center">发件人:</td>
           <td align="center">抄送:</td>
           <td align="center">重要性:</td>
           <td align="center">标题:</td>
           <td align="center">发送时间:</td>
           <td align="center">内容:</td>
           <td align="center">附件名称:</td>
         </tr>';
         $data["toname"] = self::joinStringByArray($data["toids"], $users, "realname", ";");
         $data["content"] = str_replace("  ", "&nbsp;&nbsp;", $data["content"]);
         $data["content"] = str_replace("\n", "<br>", $data["content"]);
         $data["fromname"] = isset($users[$data["fromid"]]) ? $users[$data["fromid"]]["realname"] : "";
         $data["copytoname"] = self::joinStringByArray($data["copytoids"], $users, "realname", ";");
         $important_desc = "";
         if ($data["important"] == "0") {
             $important_desc = "";
         } elseif ($data["important"] == "1") {
             $important_desc = "<font color=\"#ff6600\">一般邮件</font>";
         } elseif ($data["important"] == "2") {
             $important_desc = "<font color=\"#FF0000\">重要邮件</font>";
         }
         $attachmentname = "";
         if ($data["attachmentid"] !== "") {
             $tempdata = AttachUtil::getAttach($data["attachmentid"]);
             foreach ($tempdata as $value) {
                 $attachmentname .= $value["filename"] . "; ";
             }
         }
         $data["sendtime"] = ConvertUtil::formatDate($data["sendtime"]);
         //$html .= "\r\n                <tr>\r\n                    <td nowrap align=\"center\">" . $data["toname"] . "</td>\r\n                    <td nowrap align=\"center\">" . $data["fromname"] . "</td>\r\n                    <td>" . $data["copytoname"] . "</td>\r\n                    <td nowrap align=\"center\">" . $important_desc . "</td>\r\n                    <td nowrap>" . $data["subject"] . "</td>\r\n                    <td nowrap align=\"center\" x:str=\"" . $data["sendtime"] . "\">" . $data["sendtime"] . "</td>\r\n                    <td>" . $data["content"] . "</td>\r\n                    <td>" . $attachmentname . "</td>\r\n                </tr>\r\n            </table>";
         $html .= '<tr>
                     <td nowrap align="center">' . $data["toname"] . '</td>
                     <td nowrap align="center">' . $data["fromname"] . '</td>
                     <td>' . $data["copytoname"] . '</td>
                     <td nowrap align="center">' . $important_desc . '</td>
                     <td nowrap>' . $data["subject"] . '</td>
                     <td nowrap align="center" x:str="' . $data["sendtime"] . '">' . $data["sendtime"] . '</td>
                     <td>' . $data["content"] . '</td>
                     <td>' . $attachmentname . '</td>
                 </tr></table>';
         echo $html;
     }
 }
Esempio n. 11
0
 public function getSysFolderSize($uid, $alias)
 {
     $param = Email::model()->getListParam($alias, $uid);
     $count = Yii::app()->db->createCommand()->select("SUM(eb.size) AS sum")->from("{{email}} e")->leftJoin("{{email_body}} eb", "e.bodyid = eb.bodyid")->where($param["condition"])->queryScalar();
     return intval($count);
 }
Esempio n. 12
0
 private function save($bodyId, $bodyData)
 {
     if (!empty($bodyData["attachmentid"]) && $bodyId) {
         AttachUtil::updateAttach($bodyData["attachmentid"], $bodyId);
     }
     if ($bodyData["issend"]) {
         Email::model()->send($bodyId, $bodyData);
         if (!empty($bodyData["towebmail"])) {
             $toUsers = StringUtil::filterStr($bodyData["towebmail"], ";");
             if (!empty($toUsers)) {
                 $webBox = EmailWeb::model()->fetchByPk($bodyData["fromwebid"]);
                 WebMailUtil::sendWebMail($toUsers, $bodyData, $webBox);
             }
         }
         UserUtil::updateCreditByAction("postmail", $this->uid);
         $message = Ibos::lang("Send succeed");
     } else {
         $message = Ibos::lang("Save succeed", "message");
     }
     if (Yii::app()->request->getIsAjaxRequest()) {
         $this->ajaxReturn(array("isSuccess" => true, "messsage" => $message));
     } else {
         $this->success($message, $this->createUrl("list/index"));
     }
 }
Esempio n. 13
0
 public function actionEnviar()
 {
     $model = new Email();
     $contactos = Email::model()->findAll("estatus_did = 1");
     if (count($contactos) <= 0) {
         Yii::app()->user->setFlash('danger', "No tiene destinatarios, agregue uno por lo menos");
         $this->redirect(array("create"));
     }
     if (isset($_POST["Email"]["correo"])) {
         $destinatarios = $_POST["Email"]["correo"];
         $destinatarios = array_values($destinatarios);
         $this->avisarResponsable($destinatarios, $_POST["mensaje"]);
         Yii::app()->user->setFlash('info', "Su Email se ha enviado correctamente");
         $this->redirect(array("index"));
     }
     $this->render("enviar", array("contactos" => $contactos, "model" => $model));
 }