shop_license.php

Go to the documentation of this file.
00001 <?php
00002 
00008 class Shop_License extends Shop_Config
00009 {
00010 
00016     protected $_sThisTemplate = "shop_license.tpl";
00017 
00018 
00024     protected $_aVersionCheckLinks = array(
00025         "EE" => "http://admin.oxid-esales.com/EE/onlinecheck.php",
00026         "PE" => "http://admin.oxid-esales.com/PE/onlinecheck.php",
00027         "CE" => "http://admin.oxid-esales.com/CE/onlinecheck.php"
00028     );
00029 
00030 
00037     public function render()
00038     {
00039         $myConfig = $this->getConfig();
00040         if ($myConfig->isDemoShop()) {
00042             $oSystemComponentException = oxNew("oxSystemComponentException", "license");
00043             throw $oSystemComponentException;
00044         }
00045 
00046         parent::render();
00047 
00048         $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
00049         if ($soxId != "-1" && isset($soxId)) {
00050             // load object
00051             $oShop = oxNew("oxshop");
00052             $oShop->load($soxId);
00053             $this->_aViewData["edit"] = $oShop;
00054         }
00055 
00056         $this->_aViewData["version"] = $myConfig->getVersion();
00057 
00058 
00059         $this->_aViewData['aCurVersionInfo'] = $this->_fetchCurVersionInfo($this->_aVersionCheckLinks["CE"]);
00060 
00061         if (!$this->_canUpdate()) {
00062             $this->_aViewData['readonly'] = true;
00063         }
00064 
00065         return $this->_sThisTemplate;
00066     }
00067 
00068 
00074     protected function _canUpdate()
00075     {
00076         $myConfig = $this->getConfig();
00077 
00078         $blIsMallAdmin = oxRegistry::getSession()->getVariable('malladmin');
00079         if (!$blIsMallAdmin) {
00080             return false;
00081         }
00082 
00083         if ($myConfig->isDemoShop()) {
00084             return false;
00085         }
00086 
00087         return true;
00088     }
00089 
00097     protected function _fetchCurVersionInfo($sUrl)
00098     {
00099         $aParams = array("myversion" => $this->getConfig()->getVersion());
00100         $oLang = oxRegistry::getLang();
00101         $iLang = $oLang->getTplLanguage();
00102         $sLang = $oLang->getLanguageAbbr($iLang);
00103 
00104         $oCurl = oxNew('oxCurl');
00105         $oCurl->setMethod("POST");
00106         $oCurl->setUrl($sUrl . "/" . $sLang);
00107         $oCurl->setParameters($aParams);
00108         $sOutput = $oCurl->execute();
00109 
00110         $sOutput = strip_tags($sOutput, "<br>, <b>");
00111         $aResult = explode("<br>", $sOutput);
00112         if (strstr($aResult[5], "update")) {
00113             $sUpdateLink = 'http://wiki.oxidforge.org/Category:Downloads';
00114             $aResult[5] = "<a id='linkToUpdate' href='$sUpdateLink' target='_blank'>" . $aResult[5] . "</a>";
00115         }
00116         $sOutput = implode("<br>", $aResult);
00117 
00118         return $sOutput;
00119     }
00120 }