public function actionChoose() { $model = new Sample('search'); $model->unsetAttributes(); // clear any default values if (isset($_GET['samples'])) { $result = $this->storeDataset(); $dataset_id = $result[0]; $samples_id = $_GET['samples']; $samples_array = explode(",", $samples_id); foreach ($samples_array as $key => $value) { $datasetSample = new DatasetSample(); $datasetSample->dataset_id = $dataset_id; $datasetSample->sample_id = $value; if ($datasetSample->save()) { } } $this->redirect(array('/dataset/' . $result[1])); } // if (isset($_POST['DatasetSample'])) { // $model->attributes = $_POST['DatasetSample']; // if ($model->save()) // $this->redirect(array('view', 'id' => $model->id)); // } if (isset($_GET['Sample'])) { $model->attributes = $_GET['Sample']; } //$model->getPagination()->pageSize = $model->count(); $this->render('choose', array('model' => $model)); }
public function actionDeleteSample() { if (isset($_POST['ds_id'])) { $transaction = Yii::app()->db->beginTransaction(); try { $ds = DatasetSample::model()->findByPk($_POST['ds_id']); if ($ds->delete()) { $transaction->commit(); Util::returnJSON(array("success" => true)); } } catch (Exception $e) { $message = $e->getMessage(); Yii::log(print_r($message, true), 'error'); $transaction->rollback(); Util::returnJSON(array("success" => false, "message" => Yii::t("app", "Delete Error."))); } Util::returnJSON(array("success" => false, "message" => Yii::t("app", "Delete Error."))); } }
public function actionSampleManagement() { if (!isset($_GET['id'])) { $this->redirect("/user/view_profile"); } else { $dataset = Dataset::model()->findByPk($_GET['id']); if (!$dataset) { $this->redirect("/user/view_profile"); } if ($dataset->submitter_id != Yii::app()->user->id) { Yii::app()->user->setFlash('keyword', "You are not the owner of dataset"); $this->redirect("/user/view_profile"); } $dss = DatasetSample::model()->findAllByAttributes(array('dataset_id' => $dataset->id), array('order' => 'sample_id asc')); $this->render('sampleManagement', array('model' => $dataset, 'dss' => $dss)); } }