Exemplo n.º 1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate($company_listing_type)
 {
     try {
         $model = new Listing('CreateListingCompany');
         $model->user_id = Yii::app()->user->id;
         $model->company_listing_type = $company_listing_type;
         $model->company_listing_status = Listing::STATUS_COMPANY_AVAILABLE;
         if (isset($_POST['Listing'])) {
             $model->attributes = $_POST['Listing'];
             $model->validate();
             if (!$model->hasErrors()) {
                 Listing::SaveCompanyListing($model);
                 $this->redirect(array('view', 'id' => $model->id));
             }
         }
         $this->render('create', array('model' => $model, 'actions' => $this->listActionsCanAccess));
     } catch (Exception $e) {
         Yii::log("Exception " . print_r($e, true), 'error');
         throw new CHttpException("Exception " . print_r($e, true));
     }
 }