public function storeValue($value, $type = 'default', $inputData = null) { if ($type == 'migrate') { $iconKeyArray = $this->getId() . "_icon"; $icon = $inputData[$iconKeyArray]; $mime_types = array("image/jpeg", "image/pjpeg", "image/png", "image/gif", "image/bmp", "image/x-windows-bmp"); if ($icon['name']) { if (in_array($icon['type'], $mime_types)) { $iconDirectory = JPATH_ROOT . "/" . JUDownloadFrontHelper::getDirectory("document_icon_directory", "media/com_judownload/images/document/"); $icon_file_name = $this->doc_id . "_" . JUDownloadHelper::fileNameFilter($icon['name']); if (JFile::copy($icon['tmp_name'], $iconDirectory . "original/" . $icon_file_name) && JUDownloadHelper::renderImages($iconDirectory . "original/" . $icon_file_name, $iconDirectory . $icon_file_name, 'doc_icon', true, null, $this->doc_id) ) { $value = $icon_file_name; parent::storeValue($value, $type, $inputData); } } } elseif ($value == "" || strpos($value, 'default/') === 0) { if ($this->doc && $this->doc->icon && strpos($this->doc->icon, 'default/') === false) { $this->removeIcon(); } parent::storeValue($value, $type, $inputData); } } else { $app = JFactory::getApplication(); $icon = $app->input->files->get($this->getId() . "_icon"); $mime_types = array("image/jpeg", "image/pjpeg", "image/png", "image/gif", "image/bmp", "image/x-windows-bmp"); if ($icon['name']) { if (in_array($icon['type'], $mime_types)) { $this->removeIcon(); $iconDirectory = JPATH_ROOT . "/" . JUDownloadFrontHelper::getDirectory("document_icon_directory", "media/com_judownload/images/document/"); $icon_file_name = $this->doc_id . "_" . JUDownloadHelper::fileNameFilter($icon['name']); if (JFile::upload($icon['tmp_name'], $iconDirectory . "original/" . $icon_file_name) && JUDownloadHelper::renderImages($iconDirectory . "original/" . $icon_file_name, $iconDirectory . $icon_file_name, 'doc_icon', true, null, $this->doc_id) ) { $value = $icon_file_name; parent::storeValue($value, $type, $inputData); } } else { JError::raise( E_NOTICE, 500, JText::sprintf('COM_JUDOWNLOAD_ICON_IS_NOT_VALID_MIME_TYPE') ); } } elseif ($value == "" || strpos($value, 'default/') === 0) { if ($this->doc && $this->doc->icon && strpos($this->doc->icon, 'default/') === false) { $this->removeIcon(); } parent::storeValue($value, $type, $inputData); } } }
public function storeValue($value, $type = 'default', $inputData = null) { $app = JFactory::getApplication(); if ($app->isAdmin()) { if ($this->is_new) { if (!$value) { $user = JFactory::getUser(); $value = $user->id; } } return parent::storeValue($value, $type, $inputData); } else { return true; } }