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); } }
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; }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = DatasetLog::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
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; }