OXID eShop CE  4.9.6
 All Classes Files Functions Variables Pages
shop_license.php
Go to the documentation of this file.
1 <?php
2 
8 class Shop_License extends Shop_Config
9 {
10 
16  protected $_sThisTemplate = "shop_license.tpl";
17 
18 
24  protected $_aVersionCheckLinks = array(
25  "EE" => "http://admin.oxid-esales.com/EE/onlinecheck.php",
26  "PE" => "http://admin.oxid-esales.com/PE/onlinecheck.php",
27  "CE" => "http://admin.oxid-esales.com/CE/onlinecheck.php"
28  );
29 
30 
37  public function render()
38  {
39  $myConfig = $this->getConfig();
40  if ($myConfig->isDemoShop()) {
42  $oSystemComponentException = oxNew("oxSystemComponentException", "license");
43  throw $oSystemComponentException;
44  }
45 
47 
48  $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
49  if ($soxId != "-1" && isset($soxId)) {
50  // load object
51  $oShop = oxNew("oxshop");
52  $oShop->load($soxId);
53  $this->_aViewData["edit"] = $oShop;
54  }
55 
56  $this->_aViewData["version"] = $myConfig->getVersion();
57 
58 
59  $this->_aViewData['aCurVersionInfo'] = $this->_fetchCurVersionInfo($this->_aVersionCheckLinks["CE"]);
60 
61  if (!$this->_canUpdate()) {
62  $this->_aViewData['readonly'] = true;
63  }
64 
65  return $this->_sThisTemplate;
66  }
67 
68 
74  protected function _canUpdate()
75  {
76  $myConfig = $this->getConfig();
77 
78  $blIsMallAdmin = oxRegistry::getSession()->getVariable('malladmin');
79  if (!$blIsMallAdmin) {
80  return false;
81  }
82 
83  if ($myConfig->isDemoShop()) {
84  return false;
85  }
86 
87  return true;
88  }
89 
97  protected function _fetchCurVersionInfo($sUrl)
98  {
99  $aParams = array("myversion" => $this->getConfig()->getVersion());
100  $oLang = oxRegistry::getLang();
101  $iLang = $oLang->getTplLanguage();
102  $sLang = $oLang->getLanguageAbbr($iLang);
103 
104  $oCurl = oxNew('oxCurl');
105  $oCurl->setMethod("POST");
106  $oCurl->setUrl($sUrl . "/" . $sLang);
107  $oCurl->setParameters($aParams);
108  $sOutput = $oCurl->execute();
109 
110  $sOutput = strip_tags($sOutput, "<br>, <b>");
111  $aResult = explode("<br>", $sOutput);
112  if (strstr($aResult[5], "update")) {
113  $sUpdateLink = 'http://wiki.oxidforge.org/Category:Downloads';
114  $aResult[5] = "<a id='linkToUpdate' href='$sUpdateLink' target='_blank'>" . $aResult[5] . "</a>";
115  }
116  $sOutput = implode("<br>", $aResult);
117 
118  return $sOutput;
119  }
120 }