/**
  * @param Event $event
  * @param CUploadedFile $image
  */
 public function __construct(Event $event, CUploadedFile $image)
 {
     $name = EventsUploadedImage::createName($event, $image);
     $fullPath = EventsUploadedImage::getSavePath() . '/' . $name;
     $image->saveAs($fullPath);
     @chmod($fullPath, 0666);
     // Check if event has main image
     $is_main = (int) EventImage::model()->countByAttributes(array('event_id' => $event->id));
     $imageModel = new EventImage();
     $imageModel->event_id = $event->id;
     $imageModel->image = $name;
     $imageModel->save();
     $this->resize($fullPath);
     $this->watermark($fullPath);
 }
 /**
  * @param $id EventImage id
  */
 public function actionDeleteImage($id)
 {
     if (Yii::app()->request->getIsPostRequest()) {
         $model = EventImage::model()->findByPk($id);
         if ($model) {
             $model->delete();
         }
     }
 }
Example #3
0
 public function save_imageorder()
 {
     $event_array = $_POST['eventimage_id'];
     $event_id = $_POST['event_id'];
     $order_array = $_POST['order'];
     $eventImg = new EventImage();
     foreach ($event_array as $key => $value) {
         $eventimg_id = $value;
         $eventimg_order = $order_array[$key];
         $eventImg->update('EventImage', array('sequence' => $eventimg_order), 'id=' . $eventimg_id);
     }
     Flash::set('success', __('The event image sequence has been saved.'));
     redirect(get_url('event/edit/' . $event_id));
 }