Esempio n. 1
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     Event::on(BaseMailer::className(), BaseMailer::EVENT_AFTER_SEND, function ($event) {
         AuditMail::record($event);
     });
 }
Esempio n. 2
0
 /**
  * Download an AuditMail file as eml.
  * @param $id
  * @throws NotFoundHttpException
  */
 public function actionDownload($id)
 {
     $model = AuditMail::findOne($id);
     if (!$model) {
         throw new NotFoundHttpException('The requested mail does not exist.');
     }
     Yii::$app->response->sendContentAsFile(Helper::uncompress($model->data), $model->id . '.eml');
 }
 /**
  * @param $params
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = AuditMail::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
     // load the search form data and validate
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     // adjust the query by adding the filters
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['entry_id' => $this->entry_id]);
     $query->andFilterWhere(['successful' => $this->successful]);
     $query->andFilterWhere(['like', 'to', $this->to]);
     $query->andFilterWhere(['like', 'from', $this->from]);
     $query->andFilterWhere(['like', 'reply', $this->reply]);
     $query->andFilterWhere(['like', 'cc', $this->cc]);
     $query->andFilterWhere(['like', 'bcc', $this->bcc]);
     $query->andFilterWhere(['like', 'subject', $this->subject]);
     $query->andFilterWhere(['like', 'created', $this->created]);
     return $dataProvider;
 }
Esempio n. 4
0
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('audit', 'Audit Module');
$this->params['breadcrumbs'][] = $this->title;
$this->registerCss('canvas {width: 100% !important;height: 400px;}');
$dataSet = ['fillColor' => "rgba(151,187,205,0.5)", 'strokeColor' => "rgba(151,187,205,1)", 'pointColor' => "rgba(151,187,205,1)", 'pointStrokeColor' => "#fff"];
$options = ['height' => 400, 'width' => 400];
$days = [];
$count = ['entry' => [], 'trail' => [], 'javascript' => [], 'error' => []];
foreach (range(-6, 0) as $day) {
    $date = strtotime($day . 'days');
    $days[] = date('D: Y-m-d', $date);
    $count['entry'][] = AuditEntry::find()->where(['between', 'created', date('Y-m-d 00:00:00', $date), date('Y-m-d 23:59:59', $date)])->count();
    $count['trail'][] = AuditTrail::find()->where(['between', 'created', date('Y-m-d 00:00:00', $date), date('Y-m-d 23:59:59', $date)])->count();
    $count['mail'][] = AuditMail::find()->where(['between', 'created', date('Y-m-d 00:00:00', $date), date('Y-m-d 23:59:59', $date)])->count();
    $count['javascript'][] = AuditJavascript::find()->where(['between', 'created', date('Y-m-d 00:00:00', $date), date('Y-m-d 23:59:59', $date)])->count();
    $count['error'][] = AuditError::find()->where(['between', 'created', date('Y-m-d 00:00:00', $date), date('Y-m-d 23:59:59', $date)])->count();
}
//fake data
//foreach ($count as $type => $data) {
//    foreach ($data as $k => $v) {
//        if (!$v) {
//            $v = $type == 'entry' ? rand(100, 1000) : rand(0, 100);
//            $count[$type][$k] = $v;
//        }
//    }
//}
?>
<div class="audit-index">
Esempio n. 5
0
 /**
  * Returns all linked AuditMail instances
  * @return ActiveQuery
  */
 public function getMails()
 {
     return static::hasMany(AuditMail::className(), ['entry_id' => 'id']);
 }
Esempio n. 6
0
 /**
  * @inheritdoc
  */
 public function cleanup($maxAge = null)
 {
     $maxAge = $maxAge !== null ? $maxAge : $this->maxAge;
     if ($maxAge === null) {
         return false;
     }
     return AuditMail::deleteAll(['<=', 'created', date('Y-m-d 23:59:59', strtotime("-{$maxAge} days"))]);
 }