Example #1
0
 public function uploadGalleryAction()
 {
     $ilchdate = new IlchDate();
     $mediaMapper = new MediaMapper();
     $this->getLayout()->getHmenu()->add($this->getTranslator()->trans('media'), array('action' => 'index'))->add($this->getTranslator()->trans('mediaUpload'), array('action' => 'upload'));
     if (!is_writable(APPLICATION_PATH . '/../' . $this->getConfig()->get('usergallery_uploadpath'))) {
         $this->addMessage('writableMedia', 'danger');
     }
     if ($this->getRequest()->isPost()) {
         if (!is_dir(APPLICATION_PATH . '/../' . $this->getConfig()->get('usergallery_uploadpath') . $this->getUser()->getId())) {
             mkdir(APPLICATION_PATH . '/../' . $this->getConfig()->get('usergallery_uploadpath') . $this->getUser()->getId(), 0777);
         }
         $upload = new \Ilch\Upload();
         $upload->setFile($_FILES['upl']['name']);
         $upload->setTypes($this->getConfig()->get('usergallery_filetypes'));
         $upload->setPath($this->getConfig()->get('usergallery_uploadpath') . $this->getUser()->getId() . '/');
         $upload->upload();
         $model = new MediaModel();
         $model->setUserId($this->getUser()->getId());
         $model->setUrl($upload->getUrl());
         $model->setUrlThumb($upload->getUrlThumb());
         $model->setEnding($upload->getEnding());
         $model->setName($upload->getName());
         $model->setDatetime($ilchdate->toDb());
         $mediaMapper->save($model);
     }
 }
Example #2
0
 /**
  * Inserts Media
  *
  * @param MediaModel $model
  */
 public function save(MediaModel $model)
 {
     $this->db()->insert('users_media')->values(array('user_id' => $model->getUserId(), 'name' => $model->getName(), 'url' => $model->getUrl(), 'url_thumb' => $model->getUrlThumb(), 'ending' => $model->getEnding(), 'datetime' => $model->getDatetime()))->execute();
 }