Ejemplo n.º 1
0
 private function createContact($con)
 {
     $con_model = new \Contacts();
     $con_model->attributes = $con;
     $con_model->ID_user = $this->tiUser->ID;
     try {
         if (!$con_model->save()) {
             new \Error(5, null, json_encode($con_model->getErrors()));
         }
     } catch (Exception $e) {
         new \Error(5, null, $e->getMessage());
     }
 }
Ejemplo n.º 2
0
 /**
  * Method of creating a Contact called by the Quick Create widget
  */
 public function actionQuickContact()
 {
     $model = new Contacts();
     // collect user input data
     if (isset($_POST['Contacts'])) {
         // clear values that haven't been changed from the default
         //$temp=$model->attributes;
         $model->setX2Fields($_POST['Contacts']);
         $model->visibility = 1;
         // validate user input and save contact
         // $changes = $this->calculateChanges($temp, $model->attributes, $model);
         // $model = $this->updateChangelog($model, $changes);
         $model->createDate = time();
         //if($model->validate()) {
         if ($model->save()) {
         } else {
             //echo CHtml::errorSummary ($model);
             echo CJSON::encode($model->getErrors());
         }
         return;
         //}
         //echo '';
         //echo CJSON::encode($model->getErrors());
     }
     $this->renderPartial('application.components.views.quickContact', array('model' => $model));
 }