예제 #1
0
파일: Logon.php 프로젝트: rtsantos/mais
 public function forgetPassword($user)
 {
     $this->newRow()->setNome($user)->retrieve();
     if (!$this->getId(true)->toPhp()) {
         throw new ZendT_Exception_Alert(_i18n('Usuário "%s" não encontrado!', $user));
     }
     if ($this->getEmail(true)->toPhp()) {
         throw new ZendT_Exception_Alert(_i18n('Não existe um e-mail configurado para o usuário "%user", entre em contato com o Administrador!', $user));
     }
     $_mail = new ZendT_Mail();
     $_mail->addTo($this->getEmail(true)->get(), $this->getDescricao(true)->get());
     $_mail->setSubject(_i18n('Recuperação de Senha'));
     $_mail->setBody(_i18n('Usuário: "%s"<br />Senha: "%s"', $this->getNome()->get(), $this->getSenha()->get()));
     $_mail->send();
     return _i18n('Senha enviada para o e-mail "%s"!', $this->getEmail(true)->get());
 }
예제 #2
0
 public function runAction()
 {
     $_job = new Profile_Model_Job_Mapper();
     $_job->setId($this->getRequest()->getParam('id'))->retrive()->setDhUltExec("SYSDATE")->update();
     $_view = new Profile_DataView_Job_Users();
     $where = new ZendT_Db_Where();
     $where->addFilter('profile_job.id', $this->getRequest()->getParam('id'));
     $where->addFilter('usuario.email', "", "!NULL");
     $data = $_view->recordset($where);
     while ($row = $data->getRow()) {
         try {
             $uri = $row['uri']->get();
             if ($uri == '') {
                 $uri = ZendT_Lib::convertObjectToUri($row['objeto']->get());
             }
             $uriOriginal = $uri . '/dynamic/profile/' . $row['id_profile']->get();
             $uri .= '/found/profile/' . $row['id_profile']->get() . '/no_location/1?' . $row['uri_token']->get();
             $client = new Zend_Http_Client($uri, array('timeout' => '80'));
             $response = $client->request();
             if ($response->getBody() == 'OK') {
                 $mail = new ZendT_Mail();
                 $mail->addTo($row['email_usuario']->get(), $row['nome_usuario']->get());
                 $mail->addFrom('*****@*****.**', 'Transportadora Americana');
                 $mail->setTitle($row['nome']->get());
                 $mail->setSubject($row['nome']->get());
                 $comment = $row['observacao']->get();
                 if (!$comment) {
                     $comment = $row['nome']->get();
                 }
                 $comment .= '<br><br>Para acessar o relatório clique <a href = "' . str_replace(array('/found/', '/no_location/1'), array('/dynamic/', ''), $uri) . '">aqui</a>';
                 $mail->setComment($comment);
                 $body = '<br>';
                 $user = array();
                 $user['id'] = $row['id_usuario']->get();
                 $user['role'] = $row['nome_papel']->get();
                 $listProfile = ZendT_Profile::listProfile($row['objeto']->get(), '', $user);
                 if (count($listProfile) > 0) {
                     $body .= '<style type="text/css">';
                     $body .= '    <!--';
                     $body .= '    td {';
                     $body .= '            font-family: Arial, Helvetica, sans-serif;';
                     $body .= '            font-size: 12px;';
                     $body .= '    }';
                     $body .= '    .TitleTable {';
                     $body .= '            font-weight: bold;';
                     $body .= '            border-bottom: 0px;';
                     $body .= '    }';
                     $body .= '    .viewTitle {';
                     $body .= '            background-color: #F9F9F9;';
                     $body .= '            font-weight: bold;';
                     $body .= '    }';
                     $body .= '    .viewTable {';
                     $body .= '            border:1px solid #CCCCCC;';
                     $body .= '    }';
                     $body .= '    -->';
                     $body .= '</style>';
                     $body .= '<table width="100%" border="0" cellpadding="5" cellspacing="0" class="viewTable">';
                     $body .= '	<tr >';
                     $body .= '		<td class="viewTitle">Visões Disponíveis</td>';
                     $body .= '	</tr>';
                     $body .= '	<tr>';
                     $body .= '		<td>';
                     $body .= '			<table width="100%" border="0" cellpadding="5" cellspacing="0">';
                     $body .= '				<tr>';
                     $body .= '					<td class="TitleTable">Tipo</td>';
                     $body .= '					<td class="TitleTable">Visão</td>';
                     $body .= '					<td class="TitleTable">Observação</td>';
                     $body .= '				</tr>';
                     foreach ($listProfile as $profile => $detailProfile) {
                         $uri = ZendT_Lib::convertObjectToUri($row['objeto']->get()) . '/found/profile/' . $profile . '?' . $row['uri_token']->get();
                         $body .= '				<tr>';
                         $body .= '					<td>' . $detailProfile['tipoDescricao'] . '</td>';
                         $body .= '					<td><a href = "' . str_replace('/found/', '/dynamic/', $uri) . '">' . $detailProfile['nome'] . '</a></td>';
                         $body .= '					<td>' . $detailProfile['observacao'] . '</td>';
                         $body .= '				</tr>';
                     }
                     $body .= '			</table>';
                     $body .= '		</td>';
                     $body .= '	</tr>';
                     $body .= '</table>';
                 }
                 $mail->setBody($body);
                 $mail->save();
             }
         } catch (Exception $ex) {
             $mail = new ZendT_Mail();
             /* $mail->addTo("*****@*****.**"); */
             $mail->addTo("*****@*****.**");
             $mail->addFrom('*****@*****.**', 'Transportadora Americana');
             $mail->setTitle('Erro no envio de e-mail pelo agendamento de tarefa');
             $mail->setSubject($mail->getTitle());
             $comment = $row['nome']->get() . '<br><br>Para acessar o relatório clique <a href = "' . $uriOriginal . '">aqui</a>';
             $mail->setComment($comment);
             $mail->setBody($ex->getMessage());
             $mail->save();
             /*echo 'Erro';
               exit;*/
         }
     }
     echo 'Processado';
     exit;
 }
예제 #3
0
파일: Mapper.php 프로젝트: rtsantos/mais
 public function insert($idConteudo = '')
 {
     if ($idConteudo) {
         $_conteudo = new Cms_Model_Conteudo_Mapper();
         $_conteudo->setId($idConteudo)->retrieve();
         $_conteudoPai = new Cms_Model_Conteudo_Mapper();
         $idCategoria = $_conteudo->getIdCategoria(true);
         $idCategoriaLike = $_conteudo->getIdCategoriaByDesc('like');
         if ($idCategoria->get() != $idCategoriaLike->get()) {
             /* Se houver um conteúdo pai, considera o ID da categoria deste */
             $idConteudoPai = $_conteudo->getIdConteudoPai(true)->get();
             if ($idConteudoPai) {
                 $_conteudoPai->setId($idConteudoPai)->retrieve();
                 if ($_conteudoPai->getId(true)->get()) {
                     $idCategoria = $_conteudoPai->getIdCategoria(true)->get();
                 }
             }
             /* Busca a categoria pai, caso exista */
             $_categoria = new Cms_Model_Categoria_Mapper();
             $_categoria->setId($idCategoria)->retrieve();
             $_categoriaPai = new Cms_Model_Categoria_Mapper();
             if ($_categoria->getIdCategoriaPai(true)->get()) {
                 $_categoriaPai->setId($_categoria->getIdCategoriaPai(true))->retrieve();
             }
             $_usuario = new Auth_Model_Usuario_Mapper();
             $usuarios = $this->_getPrivileges($idConteudo, $idConteudoPai);
             #var_dump($usuarios);die;
             /*$usuarios = array_merge($usuarios, array(
                   array('id_usuario' => '16524', 'email_usuario' => '*****@*****.**', 'env_email' => 'S'),
                   array('id_usuario' => '391', 'email_usuario' => '*****@*****.**', 'env_email' => 'S'),
                   array('id_usuario' => '27705', 'email_usuario' => '*****@*****.**', 'env_email' => 'S'),
                   array('id_usuario' => '6253', 'email_usuario' => '*****@*****.**', 'env_email' => 'S')
               ));*/
             foreach ($usuarios as $usuario) {
                 $idMailList = NULL;
                 if ($usuario['env_email'] == 'S') {
                     if (!$usuario['email_usuario']) {
                         continue;
                     }
                     $mail = new ZendT_Mail();
                     $mail->addTo($usuario['email_usuario']);
                     $_usuarioInc = new Auth_Model_Usuario_Mapper();
                     $_usuarioInc->setId($_conteudo->getIdUsuarioInc(true)->get())->retrieve();
                     if ($_usuarioInc->getId(true)->get() == 1) {
                         $mail->addFrom('*****@*****.**', 'Transportadora Americana');
                     } else {
                         $mail->addFrom($_usuarioInc->getEmail(true)->get(), $_usuarioInc->getNome(true)->get());
                     }
                     $tituloEmail = '';
                     if ($_categoriaPai->getId(true)->get()) {
                         $tituloEmail = $_categoriaPai->getDescricao()->get() . ' - ';
                     }
                     $tituloEmail .= $_categoria->getDescricao()->get();
                     $tituloEmail .= " ({$idConteudo})";
                     $mail->setTitle($tituloEmail)->setSubject($tituloEmail);
                     $url = Cms_Model_Conteudo_Mapper::getUrlView($idConteudo, false, true);
                     $titulo = '';
                     if (!$_conteudo->getIdConteudoPai(true)->get()) {
                         $titulo = $_conteudo->getTitulo()->get();
                     } else {
                         $titulo = $_conteudoPai->getTitulo(true)->get();
                     }
                     if ($titulo) {
                         $titulo .= '<br/><br/>';
                     }
                     //$remetente = $_conteudo->getSubTitulo()->get();
                     $comment = $titulo . 'Para acessar esse conteúdo, clique <a href = "' . $url . '">aqui</a>';
                     $mail->setComment($comment);
                     $body = $_conteudo->getCorpo()->get();
                     if ($_conteudoPai->getId(true)->get()) {
                         $body .= "<br/><hr/>" . $_conteudoPai->getCorpo()->get();
                     }
                     if ($body) {
                         $body .= "<br/></hr>";
                     } else {
                         $body = " ";
                     }
                     $mail->setBody($body);
                     $idMailList = $mail->save();
                 }
                 /* @todo: Remover - IF temporário */
                 if ($usuario['env_email'] == 'S') {
                     $this->setIdConteudo($idConteudo);
                     $this->setIdUsuario($usuario['id_usuario']);
                     if ($this->exists() && $idMailList) {
                         $this->delete();
                     }
                     $this->setIdMaillist($idMailList);
                     if (!$this->exists()) {
                         $this->insert();
                     }
                     $this->getModel()->getAdapter()->commit();
                 }
             }
         }
     } else {
         parent::insert();
     }
 }
예제 #4
0
파일: Action.php 프로젝트: rtsantos/mais
 public function mailAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     $driver = $this->getRequest()->getParam('driver');
     $to = $this->getRequest()->getParam('to');
     $subject = $this->getRequest()->getParam('subject');
     $comment = $this->getRequest()->getParam('comment');
     /**
      * Controle de cache 
      */
     $userId = Zend_Auth::getInstance()->getStorage()->read();
     if (is_object($userId)) {
         $userName = $userId->getName();
         $userEmail = $userId->getEmail();
         $userId = $userId->getId();
     } else {
         $userName = '******';
         $userEmail = '*****@*****.**';
         $userId = 0;
     }
     $idCache = 'profile' . $this->getRequest()->getParam('profile') . 'user' . $userId;
     $cache = new ZendT_Cache($idCache);
     $json = new ZendT_Json_Result();
     try {
         if (!$to) {
             $form = new Profile_Form_ObjectView_Mail();
             $params = $this->getRequest()->getParams();
             foreach ($params as $name => $value) {
                 if (!in_array($name, array('module', 'controller', 'action'))) {
                     $hidden = new ZendT_Form_Element_Hidden($name);
                     $hidden->setValue($value);
                     $form->addElement($hidden);
                 }
             }
             $form->loadElements();
             $dataCache = $cache->get();
             if ($dataCache) {
                 $form->populate($dataCache);
             }
             $form->setAction(ZendT_Url::getUri());
             throw new ZendT_Exception_Confirm($form->render());
         } else {
             $data = array();
             $data['to'] = $to;
             $data['subject'] = $subject;
             $data['comment'] = $comment;
             $cache->set($data);
         }
         $objectName = get_class($this->_mapper);
         $config = ZendT_Profile::get($objectName, 'C');
         if ($config['id']) {
             $view = new ZendT_Report_View_Dynamic($driver, $this->_mapper, $config);
             $file = $view->renderFile($subject);
             $mail = new ZendT_Mail();
             $to = str_replace(';', ',', trim($to));
             $to = explode(',', $to);
             foreach ($to as $email) {
                 $mail->addTo($email);
             }
             $mail->addFrom($userEmail, $userName);
             $mail->setTitle($subject);
             $mail->setSubject($subject);
             $mail->addAttachment($file->getFilename(), $file->getName(), 'Blob');
             $mail->setComment($comment);
             $mail->setBody(' ');
             $mail->save();
         }
         $json->setResult(true);
     } catch (Exception $ex) {
         $json->setException($ex);
     }
     echo $json->render();
 }