/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Subdomain(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Subdomain'])) { $model->attributes = $_POST['Subdomain']; if ($model->save()) { $this->redirect(array('domain/admin')); } } $this->render('create', array('model' => $model)); }
public function actionAdminView($id) { $model = DomainSuggestion::model()->findByPk($id); if (strcasecmp($model->status, "pending") == 0) { if (isset($_POST['button1'])) { $model->status = "Accepted"; $model->description = $_POST['DomainSuggestion']['description']; $domainID = $_POST['DomainSuggestion']['Domain']; $dom = Domain::model()->findByPk($domainID); if (is_null($dom)) { $dom = new Domain(); $dom->name = $model->name; $dom->description = $model->description; $dom->need = "Medium"; $dom->need_amount = 5; $dom->validator = 5; $dom->save(); } else { $subDom = new Subdomain(); $subDom->need = "Medium"; $subDom->name = $model->name; $subDom->description = $model->description; $subDom->validator = 5; $subDom->need_amount = 5; $subDom->domain_id = $dom->id; $subDom->save(); } if ($model->save()) { $this->redirect(array('view', 'id' => $model->suggestion_id)); } } if (isset($_POST['button2'])) { $model->status = "Rejected"; if ($model->save()) { $this->redirect(array('view', 'id' => $model->suggestion_id)); } } $this->render('adminView', array('model' => $model)); } else { $this->actionView($id); } }