Beispiel #1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $this->addToolbar();
     $model = new Logo();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Logo'])) {
         $model->attributes = $_POST['Logo'];
         if ($model->save()) {
             $this->redirect(array('index'));
         }
     }
     $this->render('form', array('model' => $model));
 }
 function __construct()
 {
     adminGateKeeper();
     $logos = getEntities(array("type" => "Logo"));
     if ($logos) {
         foreach ($logos as $logo) {
             $logo->delete();
         }
     }
     $logo = new Logo();
     $logo->save();
     $logo->createAvatar();
     new SystemMessage("Your avatar has been uploaded.");
     forward("admin/logo");
 }
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['submit'])) {
         $posts_1 = Configurations::model()->findByAttributes(array('id' => 1));
         $posts_1->config_value = $_POST['collegename'];
         $posts_1->save();
         $posts_2 = Configurations::model()->findByAttributes(array('id' => 2));
         $posts_2->config_value = $_POST['address'];
         $posts_2->save();
         $posts_3 = Configurations::model()->findByAttributes(array('id' => 3));
         $posts_3->config_value = $_POST['phone'];
         $posts_3->save();
         $posts_4 = Configurations::model()->findByAttributes(array('id' => 4));
         $posts_4->config_value = $_POST['attentance'];
         $posts_4->save();
         $posts_5 = Configurations::model()->findByAttributes(array('id' => 13));
         $posts_5->config_value = $_POST['startyear'];
         $posts_5->save();
         $posts_6 = Configurations::model()->findByAttributes(array('id' => 14));
         $posts_6->config_value = $_POST['endyear'];
         $posts_6->save();
         $posts_7 = Configurations::model()->findByAttributes(array('id' => 14));
         $posts_7->config_value = $_POST['currency'];
         $posts_7->save();
         $posts_8 = Configurations::model()->findByAttributes(array('id' => 5));
         $posts_8->config_value = $_POST['currency'];
         $posts_8->save();
         $posts_9 = Configurations::model()->findByAttributes(array('id' => 6));
         $posts_9->config_value = $_POST['language'];
         $posts_9->save();
         if ($file = CUploadedFile::getInstance($model, 'logo')) {
             $logo = new Logo();
             $logo->photo_file_name = $file->name;
             $logo->photo_content_type = $file->type;
             $logo->photo_file_size = $file->size;
             $logo->photo_data = file_get_contents($file->tempName);
             $logo->save();
             $posts_10 = Configurations::model()->findByAttributes(array('id' => 18));
             $posts_10->config_value = Yii::app()->db->getLastInsertId();
             $posts_10->save();
         }
         $posts_11 = Configurations::model()->findByAttributes(array('id' => 12));
         $posts_11->config_value = $_POST['network'];
         $posts_11->save();
         $posts_12 = Configurations::model()->findByAttributes(array('id' => 7));
         $posts_12->config_value = $_POST['admission_number'];
         $posts_12->save();
         $posts_13 = Configurations::model()->findByAttributes(array('id' => 8));
         $posts_13->config_value = $_POST['employee_number'];
         $posts_13->save();
         $this->redirect(array('create'));
     }
     $this->render('update', array('model' => $model));
 }
 /**
  * upload de l image dans la collection Mongo Logo
  * @return type
  */
 private function logoUpload()
 {
     if (Yii::app()->user->isAdmin()) {
         $biobank_id = $_SESSION['biobank_id'];
     } else {
         $biobank_id = Yii::app()->user->biobank_id;
     }
     $model = new Logo();
     $_SESSION['biobank_id'] = $biobank_id;
     if (isset($_FILES['Biobank'])) {
         $tempFilename = $_FILES["Biobank"]["tmp_name"]['vitrine']['logo'];
         $filename = $_FILES["Biobank"]["name"]['vitrine']['logo'];
         if ($_FILES['Biobank']['size']['vitrine']['logo'] < 1000000) {
             if (in_array(substr($filename, -4), array('.jpg', '.png')) || in_array(substr($filename, -5), array('.jpeg'))) {
                 $model->filename = $tempFilename;
                 $model->metadata['biobank_id'] = $biobank_id;
                 $model->uploadDate = new MongoDate();
                 if ($model->save()) {
                     $model->filename = $filename;
                     if ($model->save()) {
                         return $model->_id;
                     }
                 }
             } else {
                 Yii::app()->user->setFlash('error', "le fichier '{$filename}' n\\'est pas une image valide.");
             }
         } else {
             Yii::app()->user->setFlash('error', "le fichier '{$filename}' est trop volumineux.");
         }
     }
 }
 private function storeLogo($logo, $biobank)
 {
     //  print_r($logo);
     $model = new Logo();
     $tempFilename = $logo["tmp_name"]['filename'];
     //$fileName = $logo["name"]['filename'];
     $ext = pathinfo($logo['name']['filename'], PATHINFO_EXTENSION);
     if (in_array($ext, array('jpg', 'png', 'jpeg'))) {
         $model->filename = $tempFilename;
         $model->metadata['biobank_id'] = (string) $biobank->_id;
         $model->uploadDate = new MongoDate();
         if ($model->save()) {
             $model->filename = 'logo' . $biobank->identifier . ".{$ext}";
             if ($model->save()) {
                 echo 'saved';
                 return $model->_id;
             } else {
                 echo 'not save second';
             }
         } else {
             echo 'not saved first';
         }
     }
 }