X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=report_send.php;h=526457bf4eafb2a57a7f80824e22f6e3cd9032c2;hb=HEAD;hp=9be9676fd65c3bf7a395379dc4d1510279431995;hpb=b401022733a9645ed701522585b2d57db936f5cc;p=timetracker.git diff --git a/report_send.php b/report_send.php index 9be9676f..526457bf 100644 --- a/report_send.php +++ b/report_send.php @@ -29,16 +29,16 @@ require_once('initialize.php'); import('form.Form'); import('form.ActionForm'); -import('ttSysConfig'); +import('ttUserConfig'); import('ttReportHelper'); // Access check. -if (!ttAccessAllowed('view_own_reports')) { +if (!(ttAccessAllowed('view_own_reports') || ttAccessAllowed('view_reports'))) { header('Location: access_denied.php'); exit(); } -$sc = new ttSysConfig($user->id); +$uc = new ttUserConfig(); if ($request->isPost()) { $cl_receiver = trim($request->getParameter('receiver')); @@ -46,9 +46,9 @@ if ($request->isPost()) { $cl_subject = trim($request->getParameter('subject')); $cl_comment = trim($request->getParameter('comment')); } else { - $cl_receiver = $sc->getValue(SYSC_LAST_REPORT_EMAIL); - $cl_cc = $sc->getValue(SYSC_LAST_REPORT_CC); - $cl_subject = $i18n->getKey('form.mail.report_subject'); + $cl_receiver = $uc->getValue(SYSC_LAST_REPORT_EMAIL); + $cl_cc = $uc->getValue(SYSC_LAST_REPORT_CC); + $cl_subject = $i18n->get('form.mail.report_subject'); } $form = new Form('mailForm'); @@ -56,24 +56,26 @@ $form->addInput(array('type'=>'text','name'=>'receiver','style'=>'width: 300px;' $form->addInput(array('type'=>'text','name'=>'cc','style'=>'width: 300px;','value'=>$cl_cc)); $form->addInput(array('type'=>'text','name'=>'subject','style'=>'width: 300px;','value'=>$cl_subject)); $form->addInput(array('type'=>'textarea','name'=>'comment','maxlength'=>'250','style'=>'width: 300px; height: 60px;')); -$form->addInput(array('type'=>'submit','name'=>'btn_send','value'=>$i18n->getKey('button.send'))); +$form->addInput(array('type'=>'submit','name'=>'btn_send','value'=>$i18n->get('button.send'))); if ($request->isPost()) { // Validate user input. - if (!ttValidEmailList($cl_receiver)) $err->add($i18n->getKey('error.field'), $i18n->getKey('form.mail.to')); - if (!ttValidEmailList($cl_cc, true)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.cc')); - if (!ttValidString($cl_subject)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.subject')); - if (!ttValidString($cl_comment, true)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.comment')); + if (!ttValidEmailList($cl_receiver)) $err->add($i18n->get('error.field'), $i18n->get('form.mail.to')); + if (!ttValidEmailList($cl_cc, true)) $err->add($i18n->get('error.field'), $i18n->get('label.cc')); + if (!ttValidString($cl_subject)) $err->add($i18n->get('error.field'), $i18n->get('label.subject')); + if (!ttValidString($cl_comment, true)) $err->add($i18n->get('error.field'), $i18n->get('label.comment')); if ($err->no()) { // Save last report emails for future use. - $sc->setValue(SYSC_LAST_REPORT_EMAIL, $cl_receiver); - $sc->setValue(SYSC_LAST_REPORT_CC, $cl_cc); + $uc->setValue(SYSC_LAST_REPORT_EMAIL, $cl_receiver); + $uc->setValue(SYSC_LAST_REPORT_CC, $cl_cc); // Obtain session bean with report attributes. $bean = new ActionForm('reportBean', new Form('reportForm')); + $options = ttReportHelper::getReportOptions($bean); + // Prepare report body. - $body = ttReportHelper::prepareReportBody($bean, $cl_comment); + $body = ttReportHelper::prepareReportBody($options, $cl_comment); import('mail.Mailer'); $mailer = new Mailer(); @@ -87,9 +89,9 @@ if ($request->isPost()) { $mailer->setReceiverBCC($user->bcc_email); $mailer->setMailMode(MAIL_MODE); if ($mailer->send($cl_subject, $body)) - $msg->add($i18n->getKey('form.mail.report_sent')); + $msg->add($i18n->get('form.mail.report_sent')); else - $err->add($i18n->getKey('error.mail_send')); + $err->add($i18n->get('error.mail_send')); } } @@ -103,7 +105,7 @@ if (function_exists('imap_mime_header_decode')) { } } -$smarty->assign('title', $i18n->getKey('title.send_report')); +$smarty->assign('title', $i18n->get('title.send_report')); $smarty->assign('forms', array($form->getName()=>$form->toArray())); $smarty->assign('onload', 'onLoad="document.mailForm.'.($cl_receiver?'comment':'receiver').'.focus()"'); $smarty->assign('content_page_name', 'mail.tpl');