/**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new ApplicationDomainMentor();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['ApplicationDomainMentor'])) {
         $model->attributes = $_POST['ApplicationDomainMentor'];
         if ($model->save()) {
         }
         $this->redirect(array('view', 'id' => $model->id));
     }
     $this->render('create', array('model' => $model));
 }
 public function actionDomain()
 {
     $application = new ApplicationDomainMentor();
     $domains = new Domain();
     if (Yii::app()->getRequest()->isPostRequest) {
         $user = User::model()->getCurrentUser();
         $application->attributes = $_POST['ApplicationDomainMentor'];
         $application->status = 'Admin';
         $application->user_id = $user->id;
         $application->date_created = new CDbExpression('NOW()');
         $application->save(false);
         $picks = $_POST['domPicks'];
         $picks = explode(',', $picks);
         foreach ($picks as $pick) {
             $dbpick = new ApplicationDomainMentorPick();
             $dbpick->app_id = $application->id;
             $temp = explode(':', $pick);
             $dbpick->domain_id = $temp[0];
             $dbpick->proficiency = $temp[1];
             $dbpick->approval_status = 'Proposed by Mentor';
             $dbpick->save(false);
         }
         $picks = $_POST['subPicks'];
         if (isset($picks) && $picks != "") {
             $picks = explode(',', $picks);
             foreach ($picks as $pick) {
                 $dbpick = new ApplicationSubdomainMentorPick();
                 $dbpick->app_id = $application->id;
                 $temp = explode(':', $pick);
                 $dbpick->subdomain_id = $temp[0];
                 $dbpick->proficiency = $temp[1];
                 $dbpick->approval_status = 'Proposed by Mentor';
                 $dbpick->save(false);
             }
         }
         $this->redirect("/coplat/index.php/application/portal");
     } else {
         // on initial load
         $domains->unsetAttributes();
         $domain = Domain::model()->getDomainsForApp($domains->searchNoPagination());
     }
     $error = '';
     $this->render('domain', array('application' => $application, 'domain' => $domain, 'error' => $error));
 }