예제 #1
0
 static function checkSafePath($safePath = 0)
 {
     if ($safePath == 0) {
         $safePath = VmConfig::get('forSale_path', 0);
         if (self::$tested) {
             return $safePath;
         }
     }
     $warn = FALSE;
     $uri = JFactory::getURI();
     $configlink = $uri->root() . 'administrator/index.php?option=com_virtuemart&view=config';
     VmConfig::loadJLang('com_virtuemart');
     if (empty($safePath)) {
         $warn = 'COM_VIRTUEMART_WARN_NO_SAFE_PATH_SET';
     } else {
         //jimport('joomla.filesystem.folder');
         if (!class_exists('JFolder')) {
             require_once JPATH_VM_LIBRARIES . DS . 'joomla' . DS . 'filesystem' . DS . 'folder.php';
         }
         $exists = JFolder::exists($safePath);
         if (!$exists) {
             $warn = 'COM_VIRTUEMART_WARN_SAFE_PATH_WRONG';
         } else {
             if (!is_writable($safePath)) {
                 VmConfig::loadJLang('com_virtuemart_config');
                 VmError('COM_VIRTUEMART_WARN_SAFE_PATH_NOT_WRITEABLE', vmText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'), $safePath, $configlink);
             } else {
                 if (!is_writable(self::getInvoicePath($safePath))) {
                     VmConfig::loadJLang('com_virtuemart_config');
                     VmError('COM_VIRTUEMART_WARN_SAFE_PATH_INV_NOT_WRITEABLE', vmText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'), $safePath, $configlink);
                 }
             }
         }
     }
     if ($warn) {
         $suggestedPath = shopFunctions::getSuggestedSafePath();
         VmConfig::loadJLang('com_virtuemart_config');
         VmWarn($warn, vmText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'), $suggestedPath, $configlink);
         return FALSE;
     }
     return $safePath;
 }
예제 #2
0
 static function checkSafePath($sPath = 0)
 {
     static $safePath = null;
     if (isset($safePath)) {
         return $safePath;
     }
     if ($sPath == 0) {
         $safePath = VmConfig::get('forSale_path', 0);
     } else {
         $safePath = $sPath;
     }
     $warn = false;
     $uri = JFactory::getURI();
     VmConfig::loadJLang('com_virtuemart');
     if (empty($safePath)) {
         $warn = 'COM_VIRTUEMART_WARN_NO_SAFE_PATH_SET';
     } else {
         if (!class_exists('JFolder')) {
             require_once VMPATH_LIBS . DS . 'joomla' . DS . 'filesystem' . DS . 'folder.php';
         }
         $exists = JFolder::exists($safePath);
         if (!$exists) {
             $warn = 'COM_VIRTUEMART_WARN_SAFE_PATH_WRONG';
         } else {
             if (!is_writable($safePath)) {
                 VmConfig::loadJLang('com_virtuemart_config');
                 vmdebug('checkSafePath $safePath not writeable ' . $safePath);
                 VmError(vmText::sprintf('COM_VIRTUEMART_WARN_SAFE_PATH_INV_NOT_WRITEABLE', vmText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'), $safePath), vmText::sprintf('COM_VIRTUEMART_WARN_SAFE_PATH_INV_NOT_WRITEABLE', '', ''));
             } else {
                 if (!is_writable(self::getInvoicePath($safePath))) {
                     VmConfig::loadJLang('com_virtuemart_config');
                     vmdebug('checkSafePath $safePath/invoice not writeable ' . addslashes($safePath));
                     VmError(vmText::sprintf('COM_VIRTUEMART_WARN_SAFE_PATH_INV_NOT_WRITEABLE', vmText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'), $safePath), vmText::sprintf('COM_VIRTUEMART_WARN_SAFE_PATH_INV_NOT_WRITEABLE', '', ''));
                 }
             }
         }
     }
     if ($warn) {
         $safePath = false;
         $suggestedPath = shopFunctions::getSuggestedSafePath();
         $suggestedPath2 = VMPATH_ADMIN . DS . self::generateRandomString(12) . DS;
         VmConfig::loadJLang('com_virtuemart_config');
         $configlink = $uri->root() . 'administrator/index.php?option=com_virtuemart&view=config';
         VmError(vmText::sprintf($warn, vmText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'), $suggestedPath, $configlink, $suggestedPath2));
     }
     return $safePath;
 }
예제 #3
0
 static function checkSafePath($safePath = 0)
 {
     if ($safePath == 0) {
         $safePath = VmConfig::get('forSale_path', 0);
         if (self::$tested) {
             return $safePath;
         }
     }
     $warn = FALSE;
     $uri = JFactory::getURI();
     $configlink = $uri->root() . 'administrator/index.php?option=com_virtuemart&view=config';
     VmConfig::loadJLang('com_virtuemart');
     if (empty($safePath)) {
         $warn = 'COM_VIRTUEMART_WARN_NO_SAFE_PATH_SET';
     } else {
         $exists = JFolder::exists($safePath);
         if (!$exists) {
             $warn = 'COM_VIRTUEMART_WARN_SAFE_PATH_WRONG';
         } else {
             if (!is_writable($safePath)) {
                 VmConfig::loadJLang('com_virtuemart_config');
                 VmWarn('COM_VIRTUEMART_WARN_SAFE_PATH_NOT_WRITEABLE', JText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'), $safePath, $configlink);
             } else {
                 if (!is_writable(self::getInvoicePath($safePath))) {
                     VmConfig::loadJLang('com_virtuemart_config');
                     VmWarn('COM_VIRTUEMART_WARN_SAFE_PATH_INV_NOT_WRITEABLE', JText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'), $safePath, $configlink);
                 }
             }
         }
     }
     if ($warn) {
         self::$tested = true;
         $suggestedPath = shopFunctions::getSuggestedSafePath();
         VmConfig::loadJLang('com_virtuemart_config');
         VmWarn($warn, JText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'), $suggestedPath, $configlink);
         return FALSE;
     }
     return $safePath;
 }
예제 #4
0
 static function checkSafePath($safePath = 0)
 {
     if ($safePath == 0) {
         $safePath = VmConfig::get('forSale_path', 0);
     }
     if (empty($safePath)) {
         $suggestedPath = shopFunctions::getSuggestedSafePath();
         $uri = JFactory::getURI();
         $configlink = $uri->root() . 'administrator/index.php?option=com_virtuemart&view=config';
         VmWarn('COM_VIRTUEMART_WARN_NO_SAFE_PATH_SET', JText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'), $suggestedPath, $configlink);
         return FALSE;
     } else {
         $exists = JFolder::exists($safePath);
         if (!$exists) {
             $uri = JFactory::getURI();
             $configlink = $uri->root() . 'administrator/index.php?option=com_virtuemart&view=config';
             $suggestedPath = shopFunctions::getSuggestedSafePath();
             VmWarn('COM_VIRTUEMART_WARN_SAFE_PATH_WRONG', JText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'), $suggestedPath, $configlink);
             return FALSE;
         } else {
             return $safePath;
         }
     }
 }
 /**
  * @static
  * @return null|string
  */
 static function getKlarna_pc_type()
 {
     $safePath = VmConfig::get('forSale_path', '');
     if ($safePath) {
         return $safePath . "klarna/klarna.json";
     } else {
         $suggestedPath = shopFunctions::getSuggestedSafePath();
         //VmError('COM_VIRTUEMART_WARN_NO_SAFE_PATH_SET',JText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'),$suggestedPath);
         $uri = JFactory::getURI();
         $link = $uri->root() . 'administrator/index.php?option=com_virtuemart&view=config';
         VmError(JText::sprintf('VMPAYMENT_KLARNA_CANNOT_STORE_CONFIG', '<a href="' . $link . '">' . $link . '</a>', JText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH')));
         return NULL;
     }
 }
 /**
  * The type of the media determines the used path for storing them
  *
  * @author Max Milbers
  * @param string $type type of the media, allowed values product, category, shop, vendor, manufacturer, forSale
  */
 public function getMediaUrlByView($type)
 {
     //the problem is here, that we use for autocreatoin the name of the model, here products
     //But for storing we use the product to build automatically the table out of it (product_medias)
     $choosed = false;
     if ($type == 'product' || $type == 'products') {
         $relUrl = VmConfig::get('media_product_path');
         $choosed = true;
     } else {
         if ($type == 'category' || $type == 'categories') {
             $relUrl = VmConfig::get('media_category_path');
             $choosed = true;
         } else {
             if ($type == 'shop') {
                 $relUrl = VmConfig::get('media_path');
                 $choosed = true;
             } else {
                 if ($type == 'vendor' || $type == 'vendors') {
                     $relUrl = VmConfig::get('media_vendor_path');
                     //	$relUrl = 'components/com_virtuemart/assets/images/vendors/';
                     $choosed = true;
                 } else {
                     if ($type == 'manufacturer' || $type == 'manufacturers') {
                         $relUrl = VmConfig::get('media_manufacturer_path');
                         $choosed = true;
                     } else {
                         if ($type == 'forSale' || $type == 'file_is_forSale') {
                             //todo add this path to config
                             $safePath = VmConfig::get('forSale_path', 0);
                             if (empty($safePath)) {
                                 $suggestedPath = shopFunctions::getSuggestedSafePath();
                                 VmWarn('COM_VIRTUEMART_WARN_NO_SAFE_PATH_SET', JText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'), $suggestedPath);
                             } else {
                                 $relUrl = $safePath;
                                 $choosed = true;
                                 $this->file_is_forSale = 1;
                             }
                         }
                     }
                 }
             }
         }
     }
     // 		$this->type = $type;
     // 		$this->setRole=false;
     if ($choosed && empty($relUrl)) {
         $uri = JFactory::getURI();
         $link = $uri->root() . 'administrator/index.php?option=com_virtuemart&view=config';
         vmInfo('COM_VIRTUEMART_MEDIA_NO_PATH_TYPE', $type, $link);
         //Todo add general media_path to config
         //$relUrl = VmConfig::get('media_path');
         $relUrl = 'images/stories/virtuemart/';
         $this->setRole = true;
         // 		} else if(!$choosed and empty($relUrl) and $this->file_is_forSale==0){
     } else {
         if (!$choosed and empty($relUrl)) {
             vmWarn('COM_VIRTUEMART_MEDIA_CHOOSE_TYPE', $this->file_title);
             // 			vmError('Ignore this message, when it appears while the media synchronisation process, else report to http://forum.virtuemart.net/index.php?board=127.0 : cant create media of unknown type, a programmers error, used type ',$type);
             //$relUrl = VmConfig::get('media_path');
             $relUrl = 'images/stories/virtuemart/typeless/';
             $this->setRole = true;
         } else {
             if (!$choosed and $this->file_is_forSale == 1) {
                 $relUrl = '';
                 $this->setRole = false;
             }
         }
     }
     return $relUrl;
 }