Exemplo n.º 1
0
 public function prepare_fileupload($map_id, $mapimage)
 {
     $app = JFactory::getApplication();
     $model = $this->getModel();
     $user = JFactory::getUser();
     $dir = JPATH_SITE . DS . 'images' . DS . 'htraininglogs' . DS . $user->id . DS . 'maps' . DS;
     $file = JRequest::getVar('file_upload2', null, 'files', 'array');
     if ($file['name'] != '') {
         $filename = HTraininglogsHelper::uploadmediafile($file, $mapimage, $dir, 1, 100);
         if (!$filename) {
             return false;
             $this->setRedirect(JRoute::_('index.php?option=com_htraininglogs&view=session&layout=edit&sub_id=' . $sub_id, false));
         } else {
             $model->storeimage($filename, $map_id);
             return true;
         }
     }
 }
Exemplo n.º 2
0
 public function add_competitionmedia()
 {
     $model = $this->getModel();
     $sub_id = JRequest::getVar('sub_id');
     $newmedia = JRequest::getVar('newmedia');
     $mtitle = JRequest::getVar('mtitle');
     $file = JRequest::getVar('media_upload', null, 'files', 'array');
     $filename = JFile::makeSafe($file['name']);
     $user = JFactory::getUser();
     $dir = JPATH_SITE . '/images/htraininglogs/' . $user->id . '/' . 'media/';
     if ($newmedia) {
         $model->savemedialink(0, $sub_id, $newmedia);
     }
     if ($file['name'] != '') {
         $filename = HTraininglogsHelper::uploadmediafile($file, $mediafile, $dir, 0, 150);
         if (!$filename) {
             return false;
             $this->setRedirect(JRoute::_('index.php?option=com_htraininglogs&view=session&layout=edit&sub_id=' . $sub_id, false));
         } else {
             $upload_id = $model->storemedia($filename, $mtitle);
             $model->savemedialink(0, $sub_id, $upload_id);
             return true;
         }
     }
     $i = 0;
     while ($link_id = JRequest::getVar('mlink_id' . $i)) {
         $media_id = JRequest::getVar('media' . $i);
         $model->savemedialink($link_id, $sub_id, $media_id);
         $i++;
     }
 }