/**
  * 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['ImageCatalogue'])) {
         $model->attributes = $_POST['ImageCatalogue'];
         //unlink old image
         $model->attributes = $_POST['ImageCatalogue'];
         $model = CommonUtils::fillUpdateDate($model);
         $tempFile = CUploadedFile::getInstance($model, 'url');
         if ($model->validate()) {
             if ($tempFile != null) {
                 if ($model->url != null) {
                     unlink(Yii::getPathOfAlias('webroot') . '/' . $model->url);
                 }
                 $filename = pathinfo($tempFile, PATHINFO_FILENAME);
                 $ext = pathinfo($tempFile, PATHINFO_EXTENSION);
                 $model->url = 'images/' . md5(date("mdYhisu", time()) . $filename) . '.' . $ext;
                 $path = Yii::getPathOfAlias('webroot') . '/' . $model->url;
                 $tempFile->saveAs($path);
                 Yii::app()->user->setFlash('ok', 'Data berhasil di update.');
             }
             if ($model->save()) {
                 $this->redirect(array('view', 'id' => $model->image_id));
             }
         }
     }
     $this->render('update', array('model' => $model));
 }