public function save_edit()
 {
     if (!isset($_SESSION['logged'])) {
         return call('pages', 'home');
     } else {
         if (!isset($_GET['code'])) {
             return call('pages', 'error', 2);
         }
         $post_data = $_POST;
         UseCase::save($post_data, $_GET['code']);
         $uploadDir = "uploads/uml/";
         $targetFile = $uploadDir . 'usecases/' . $post_data['code'] . '-' . $post_data['title'] . '.jpg';
         $uploadOk = 1;
         $imageFileType = pathinfo($targetFile, PATHINFO_EXTENSION);
         $check = getimagesize($_FILES["image"]["tmp_name"]);
         if ($check !== false) {
             if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif") {
                 $uploadOk = 0;
                 return call('pages', 'error', 4);
             } else {
                 $uploadOk = 1;
             }
         } else {
             $uploadOk = 0;
             return call('pages', 'error', 4);
         }
         if ($uploadOk == 0) {
             return call('pages', 'error', 5);
         } else {
             if (move_uploaded_file($_FILES["image"]["tmp_name"], $targetFile)) {
                 chmod($targetFile, 0755);
                 return call('usecases', 'index');
             } else {
                 return call('pages', 'error', 5);
             }
         }
         return call('usecases', 'index');
     }
 }
 public function actionCreate()
 {
     $model = new UseCase();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['UseCase'])) {
         //Creates new Source, gets generated ID
         $source = new Source();
         $source->save();
         //Gives the new external source the generated ID
         $model->attributes = $_POST['UseCase'];
         $model->id_use_case = $source->id_source;
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id_use_case));
         } else {
             $source->delete();
         }
     }
     $this->render('create', array('model' => $model));
 }