public function createLog($dataset_id, $message) { #only save the log when dataset is public $dataset = Dataset::model()->findByPk($dataset_id); if ($dataset->IsPublic) { $log = new DatasetLog(); $log->dataset_id = $dataset_id; $log->message = $message; $log->model = $this->Owner->tableName(); $log->model_id = $this->Owner->id; $log->save(false); } }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new DatasetLog(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['DatasetLog'])) { $model->attributes = $_POST['DatasetLog']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
public function afterSave() { $log = new DatasetLog(); $log->dataset_id = $this->file->dataset_id; if ($this->isNewRecord) { $log->message = $this->file->name . ': additional file attribute added'; } else { $log->message = $this->file->name . ': file attribute updated'; } $log->model_id = $this->id; $log->model = get_class($this); $log->url = Yii::app()->createUrl('/adminFile/update', array('id' => $this->file->id)); if ($this->file->dataset->isPublic) { $log->save(); } return true; }
public function beforeDelete() { $log = new DatasetLog(); $log->dataset_id = $this->dataset_id; $log->message = 'File ' . $this->name . ' removed'; $log->model_id = $this->id; $log->model = get_class($this); $log->url = ''; if ($this->dataset->isPublic) { $log->save(); } return true; }