Ejemplo n.º 1
0
 public function actionSearch()
 {
     $condition = array();
     if (Yii::app()->request->getIsPostRequest()) {
         $search = $_POST["search"];
         $condition = EmailUtil::mergeSearchCondition($search, $this->uid);
         $conditionStr = base64_encode(serialize($condition));
     } else {
         $conditionStr = EnvUtil::getRequest("condition");
         $condition = unserialize(base64_decode($conditionStr));
     }
     if (empty($condition)) {
         $this->error(Ibos::lang("Request tainting", "error"), $this->createUrl("list/index"));
     }
     $emailData = Email::model()->fetchAllByArchiveIds("*", $condition["condition"], $condition["archiveId"], array("e", "eb"), null, null, SORT_DESC, "emailid");
     $count = count($emailData);
     $pages = PageUtil::create($count, $this->getListPageSize(), false);
     $pages->params = array("condition" => $conditionStr);
     $list = array_slice($emailData, $pages->getOffset(), $pages->getLimit(), false);
     foreach ($list as $index => &$mail) {
         $mail["fromuser"] = $mail["fromid"] ? User::model()->fetchRealnameByUid($mail["fromid"]) : "";
     }
     $data = array("list" => $list, "pages" => $pages, "condition" => $conditionStr, "folders" => $this->folders);
     $this->setPageTitle(Ibos::lang("Search result"));
     $this->setPageState("breadCrumbs", array(array("name" => Ibos::lang("Personal Office")), array("name" => Ibos::lang("Email center"), "url" => $this->createUrl("list/index")), array("name" => Ibos::lang("Search result"))));
     $this->render("search", $data);
 }
Ejemplo n.º 2
0
 function contactMe()
 {
     $form = new \SKS\LIB\Form();
     $form->post('name')->addRule('minlength', 2)->post('email')->addRule('email')->post("message")->addRule('minlength', 20);
     $errors = $form->validate();
     $email = new \SKS\DB\Entity\Email();
     $email->setName($this->getPostValue("name"));
     $email->setFrom($this->getPostValue("email"));
     $email->setContent($this->getPostValue("message"));
     $this->view->email = $email;
     if (isset($errors)) {
         $this->view->errors = $errors;
         $this->view->render('index/contactMe', false);
     } else {
         $email->persist(true);
         $sent = \EmailUtil::contact_us($email->getContent());
         if ($sent) {
             $this->view->message = "Thank you for contacting me, will get back to you soon..";
             $this->view->render('index/contactMe', false);
         } else {
             $this->view->error = "Error occured while sending email ..";
             $this->view->render('index/contactMe', false);
         }
     }
 }
 public function handleForm(Context $context, $action)
 {
     if ($action == "createReservation") {
         if (isset($_POST['equip_id']) && $_POST['equip_id'] != "" && (isset($_POST['start_date']) && $_POST['start_date'] != "") && (isset($_POST['length']) && $_POST['length'] != "")) {
             $equipId = $_POST['equip_id'];
             $equip = EquipmentDao::getEquipmentByID($equipId);
             if ($equip != null) {
                 if (SessionUtil::getUserlevel() >= $equip->minUserLevel) {
                     $startDate = $_POST['start_date'];
                     $endDate = DateUtil::incrementDate($startDate, $_POST['length']);
                     $reservations = ReservationDao::getReservationsForEquipmentByDate($equipId, $startDate, $endDate);
                     if (count($reservations) == 0) {
                         $user = UserDao::getUserByUsername(SessionUtil::getUsername());
                         $reservation = ReservationDao::createReservation($user->id, $equipId, $_POST['length'], $startDate, $endDate, $_POST['user_comment']);
                         EmailUtil::sendNewReservationNotices($user, $reservation);
                     } else {
                         $context->addError("Reservations already exist during selected dates ({$startDate} and {$endDate}).");
                     }
                 } else {
                     $context->addError("Cannot reserve equipment (User Level).");
                 }
             } else {
                 $context->addError("No such equipment.");
             }
         } else {
             $context->addError("Required Field Left Blank.");
         }
     } else {
         $context->addError("Incorrect Action.");
     }
 }
Ejemplo n.º 4
0
 public function getMail($id)
 {
     $gUid = Ibos::app()->user->uid;
     $email = new ICEmail($id);
     $bodyAttr = $email->emailBody->attributes;
     $bodyAttr = EmailUtil::processViewData($bodyAttr);
     return $bodyAttr;
 }
Ejemplo n.º 5
0
 /**
  * Gera um link com hash e envia para o email do usuario
  *
  * @param $emailUsuario
  *
  * @return bool
  */
 public function esqueciSenha($emailUsuario)
 {
     /** @var \Application\Entity\Usuario $usuario */
     $usuario = $this->getUserMapper()->findByEmail($emailUsuario);
     if (!$usuario) {
         return false;
     }
     $link = $usuario->getId();
     $this->getUserMapper()->update($usuario);
     /** @var Url $url */
     $url = $this->getServiceManager()->get('viewhelpermanager')->get('url');
     $link = $url(RotasConst::ALTERAR_SENHA, array(), array('query' => array('userkey' => $link), 'force_canonical' => true));
     $email = new EmailUtil($this->getServiceManager());
     $email->setSender(ReiniciarSenhaEmail::getNomeRemetente(), ReiniciarSenhaEmail::getRemetente());
     $email->sendMail($usuario->getNomUsuario(), $usuario->getEmail(), ReiniciarSenhaEmail::getAssunto(), ReiniciarSenhaEmail::getEmail(array('login' => $usuario->getUsername(), 'link' => $link)));
     return true;
 }
 public static function updateReservationStatus($resId, $status, $sendEmail)
 {
     Database::doQuery("UPDATE " . Database::addPrefix(ReservationDao::table_name) . " SET mod_status = '" . Database::makeStringSafe($status) . "'" . " WHERE res_id = '" . Database::makeStringSafe($resId) . "'");
     if ($sendEmail) {
         $reservation = ReservationDao::getReservation($resId);
         $user = UserDao::getUserByID($reservation->userId);
         EmailUtil::sendUpdateReservationNotice($user, $reservation);
     }
 }
Ejemplo n.º 7
0
 public static function sendWarningNoticeToUser(Warning $warning)
 {
     $user = UserDao::getUserByID($warning->userId);
     if ($warning->type == RES_WARNING_NOTE) {
         $body = "You have been issued a Notification, you can view it at: " . Config::location . "index.php?pageid=viewWarning&warnid=" . $warning->id;
         EmailUtil::sendEmail($user->email, "New Notification", $body);
     } else {
         $body = "You have been issued an " . $warning->getTypeString() . " Warning, you can view it at: " . Config::location . "index.php?pageid=viewWarning&warnid=" . $warning->id;
         EmailUtil::sendEmail($user->email, "New " . $warning->getTypeString() . " Warning Notice", $body);
     }
 }
Ejemplo n.º 8
0
 private function search($kw)
 {
     $search["keyword"] = $kw;
     $condition = array();
     $condition = EmailUtil::mergeSearchCondition($search, Yii::app()->user->uid);
     $conditionStr = base64_encode(serialize($condition));
     if (empty($condition)) {
         $this->error(Ibos::lang("Request tainting", "error"), $this->createUrl("list/index"));
     }
     $emailData = Email::model()->fetchAllByArchiveIds("*", $condition["condition"], $condition["archiveId"], array("e", "eb"), null, null, SORT_DESC, "emailid");
     $count = count($emailData);
     $pages = PageUtil::create($count, 10, false);
     $pages->params = array("condition" => $conditionStr);
     $list = array_slice($emailData, $pages->getOffset(), $pages->getLimit(), false);
     foreach ($list as $index => &$mail) {
         $mail["fromuser"] = $mail["fromid"] ? User::model()->fetchRealnameByUid($mail["fromid"]) : "";
     }
     $return = array("datas" => $list, "pages" => array("pageCount" => $pages->getPageCount(), "page" => $pages->getCurrentPage(), "pageSize" => $pages->getPageSize()));
     $this->ajaxReturn($return, "JSONP");
 }
Ejemplo n.º 9
0
 public function actionIndex()
 {
     $uid = $this->uid;
     $total = 0;
     $folders = $this->folders;
     foreach ($folders as &$folder) {
         $size = EmailFolder::model()->getFolderSize($uid, $folder["fid"]);
         $folder["size"] = ConvertUtil::sizeCount($size);
         $total += $size;
     }
     $inbox = EmailFolder::model()->getSysFolderSize($uid, "inbox");
     $web = EmailFolder::model()->getSysFolderSize($uid, "web");
     $sent = EmailFolder::model()->getSysFolderSize($uid, "send");
     $deleted = EmailFolder::model()->getSysFolderSize($uid, "del");
     $userSize = EmailUtil::getUserSize($uid);
     $data = array("folders" => $folders, "inbox" => ConvertUtil::sizeCount($inbox), "web" => ConvertUtil::sizeCount($web), "sent" => ConvertUtil::sizeCount($sent), "deleted" => ConvertUtil::sizeCount($deleted), "userSize" => $userSize, "total" => ConvertUtil::sizeCount(array_sum(array($total, $inbox, $web, $sent, $deleted))));
     $this->setPageTitle(Ibos::lang("Folder setting"));
     $this->setPageState("breadCrumbs", array(array("name" => Ibos::lang("Personal Office")), array("name" => Ibos::lang("Email center"), "url" => $this->createUrl("list/index")), array("name" => Ibos::lang("Folder setting"))));
     $this->render("index", $data);
 }
Ejemplo n.º 10
0
 public function handleEmailBody($data)
 {
     $data["toids"] = implode(",", StringUtil::getId($data["toids"]));
     $data["sendtime"] = TIMESTAMP;
     $data["isneedreceipt"] = isset($data["isneedreceipt"]) ? 1 : 0;
     if (empty($data["isOtherRec"])) {
         $data["copytoids"] = $data["secrettoids"] = "";
     } else {
         $data["copytoids"] = implode(",", StringUtil::getId($data["copytoids"]));
         $data["secrettoids"] = implode(",", StringUtil::getId($data["secrettoids"]));
     }
     if (empty($data["isWebRec"])) {
         $data["towebmail"] = "";
     }
     if (!isset($data["fromwebmail"])) {
         $data["fromwebmail"] = "";
     }
     !empty($data["attachmentid"]) && ($data["attachmentid"] = StringUtil::filterStr($data["attachmentid"]));
     $data["size"] = EmailUtil::getEmailSize($data["content"], $data["attachmentid"]);
     return $data;
 }
 public function handleForm(Context $context, $action)
 {
     if (UserDao::getUserByUsername(SessionUtil::getUsername())->userlevel == RES_USERLEVEL_ADMIN) {
         if ($action == "createWarning") {
             if (isset($_POST['userId']) && $_POST['userId'] != "" && (isset($_POST['reason']) && $_POST['reason'] != "") && (isset($_POST['type']) && $_POST['type'] != "")) {
                 $user = UserDao::getUserByID($_POST['userId']);
                 if ($user != null) {
                     $warning = WarningDao::warnUser($_POST['userId'], $_POST['reason'], $_POST['type']);
                     EmailUtil::sendWarningNoticeToUser($warning);
                     $context->addMessage("Successfully warned " . $user);
                 } else {
                     $context->addError("No such user.");
                 }
             } else {
                 $context->addError("Required field left blank.");
             }
         } else {
             $context->addError("Incorrect Action.");
         }
     } else {
         $context->addError("Not Authorized.");
     }
 }
Ejemplo n.º 12
0
 /**
  * Trata o erro ocorrido na autenticação do usuário
  *
  * @param $auth
  * @return bool|\Zend\Http\Response
  */
 private function processaErroAutenticacao($auth)
 {
     return true;
     switch ($auth->getCode()) {
         case UsuarioConst::ERRO_SENHA_EXPIRADA:
             return $this->redirect()->toUrl($this->url()->fromRoute(Rotas::ALTERAR_SENHA));
             break;
         case UsuarioConst::ERRO_PRIMEIRO_ACESSO:
             $this->flashMessenger()->addMessage($auth, 'loginAuth');
             return $this->redirect()->toUrl($this->url()->fromRoute(Rotas::VALIDAR_CHAVE_ACESSO));
             break;
         case UsuarioConst::ERRO_USUARIO_INATIVO:
             /** @var Usuario $user */
             $user = $auth->getIdentity();
             /** @var UsuarioDao $usuarioDao */
             $usuarioDao = $this->getServiceLocator()->get('UsuarioDao');
             /** @var Usuario $gestor */
             $gestor = $usuarioDao->getGestorUnidade($user->getUnidadeOrganizacional());
             if (!$gestor) {
                 return false;
             }
             $email = new EmailUtil($this->getServiceLocator());
             $email->setSender(UsuarioSemPerfilAssociadoEmail::getNomeRemetente(), UsuarioSemPerfilAssociadoEmail::getRemetente());
             $email->sendMail($gestor->getNomUsuario(), $gestor->getEmail(), UsuarioSemPerfilAssociadoEmail::getAssunto(), UsuarioSemPerfilAssociadoEmail::getEmail(array('nome' => $user->getNomUsuario(), 'login' => $user->getUsername())));
             return true;
             break;
         default:
             break;
     }
 }
Ejemplo n.º 13
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;
     }
 }
Ejemplo n.º 14
0
<?php

/* add in custom route */
Routing::custom('lunor', function ($extra) {
    if (isset($_POST['type']) && !empty($_POST['type'])) {
        $type = $_POST['type'];
        $return['sucess'] = false;
        switch ($type) {
            case 'content_block':
                contentBlock($_POST['content_block']);
                break;
            case 'contactus':
                EmailUtil::fromContactUs($return);
                break;
            default:
                $return['error'] = 'Invalid Type.';
                break;
        }
        echo json_encode($return);
        return true;
    }
    return false;
});
Ejemplo n.º 15
0
 public static function contact_us($htmlMessage)
 {
     $htmlMessage = $htmlMessage;
     return EmailUtil::send(array("*****@*****.**" => "Sunil"), "Contact Me", $htmlMessage);
 }
Ejemplo n.º 16
0
 public static function contact_us($htmlMessage)
 {
     $htmlMessage = str_replace(":content", $htmlMessage, file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . '/template/contact_us.html'));
     return EmailUtil::send(array("*****@*****.**" => "Sunil"), "Contact Me", $htmlMessage);
 }
Ejemplo n.º 17
0
Archivo: User.php Proyecto: sks40gb/jnv
 public function sendActivationCode()
 {
     $email = $_POST["email"];
     $model = new \SKS\MODEL\UserModel();
     $code = $model->getActivationCode($email);
     if ($code == null) {
         $this->view->error = "Invalid Email : " . $email;
     } else {
         $htmlMessage = LINK_RESET_PASSWORD . $code;
         $sent = \EmailUtil::send(array($email => $email), "JNV | Reset your password", $htmlMessage);
         //\EmailUtil::contact_us(array($email=>$email), "JNV | Reset your password",$htmlMessage);
         if ($sent) {
             $this->view->message = "Reset email has been sent. Please check your email.";
         } else {
             $this->view->error = "Error encountered while sending activation code";
         }
     }
     $this->view->render('login/include/reset_password', false);
 }
Ejemplo n.º 18
0
 public function fetchFolderContent($userid, $folderName, $lastupdate, $type)
 {
     Logger::log("fetching folder: " . $folderName);
     $details = self::$gmailDAO->getGmailAccessDetailsForUser($userid);
     $username = "";
     $password = "";
     foreach ($details as $key => $value) {
         if ($key == 'username') {
             $username = $value;
         } else {
             if ($key == 'password') {
                 $password = $value;
             }
         }
     }
     $inbox = $this->getImapConnection($username, $password, $folderName);
     $tomorrow = date('d-M-Y', mktime(0, 0, 0, date("m", time()), date("d", time()) + 1, date("Y", time())));
     Logger::log("Tomorrow: " . $tomorrow);
     $startDate = date('d-M-Y', mktime(0, 0, 0, date("m", strtotime($lastupdate)), date("d", strtotime($lastupdate)) - 1, date("Y", strtotime($lastupdate))));
     while ($startDate != $tomorrow) {
         try {
             set_time_limit(1800);
             Logger::log("fetching Gmail content for date: " . $startDate);
             $emails = imap_search($inbox, 'ON ' . $startDate);
             if ($emails) {
                 $output = '';
                 Logger::log("Found (" . sizeof($emails) . ") communications [" . $type . "]");
                 rsort($emails);
                 foreach ($emails as $email_number) {
                     set_time_limit(0);
                     $overview = imap_fetch_overview($inbox, $email_number, 0);
                     if ($type == 'sms') {
                         $message = quoted_printable_decode(imap_fetchbody($inbox, $email_number, 1));
                     } else {
                         $dataTxt = EmailUtil::get_part($inbox, $email_number, "TEXT/PLAIN");
                         // GET HTML BODY
                         $dataHtml = EmailUtil::get_part($inbox, $email_number, "TEXT/HTML");
                         if ($dataHtml != "") {
                             $message = $dataHtml;
                             $mailformat = "html";
                         } else {
                             $message = ereg_replace("\n", "<br>", $dataTxt);
                             $mailformat = "text";
                         }
                     }
                     $messageDate = $overview[0]->date;
                     $gmtTimezone = new DateTimeZone('Africa/Johannesburg');
                     $myDateTime = new DateTime($messageDate, $gmtTimezone);
                     $theDate = date('c', $myDateTime->format('U') + 1);
                     $theDate = date('Y-m-d H:i:s', strtotime($theDate));
                     $recipient = quoted_printable_decode($overview[0]->to);
                     $subject = Util::ShortenString(quoted_printable_decode($overview[0]->subject), 250);
                     $from = quoted_printable_decode($overview[0]->from);
                     $dayid = self::$pictureDAO->createDay($userid, $theDate);
                     //Logger::log($messageDate." --- ".$message);
                     //Logger::log($message);
                     try {
                         self::$gmailDAO->saveCommunication($subject, $message, $theDate, $dayid, $from, $type, $recipient);
                     } catch (Exception $e) {
                     }
                 }
             }
         } catch (Exception $e) {
             Logger::log($e->getMessage());
         }
         self::$gmailDAO->updateLastUpdate($userid, $type . "_gmail", date("Y-m-d", strtotime($startDate)));
         $tempDate = mktime(0, 0, 0, date("m", strtotime($startDate)), date("d", strtotime($startDate)) + 1, date("Y", strtotime($startDate)));
         $startDate = date("d-M-Y", $tempDate);
     }
     imap_close($inbox);
 }
Ejemplo n.º 19
0
 protected function checkUserSize()
 {
     $userSize = EmailUtil::getUserSize($this->uid);
     $usedSize = EmailFolder::model()->getUsedSize($this->uid);
     if (ConvertUtil::ConvertBytes($userSize . "m") < $usedSize) {
         $this->error(Ibos::lang("Capacity overflow", "", array("{size}" => $usedSize)), $this->createUrl("email/list"));
     }
 }